[NeXus-definitions-tickets] [NeXusDefinitions] #128: Stride & Offset Approach to MultiDim Array Storage Order (related to #32)

NeXus Base Classes and Instrument Definitions noreply at nexusformat.org
Tue Oct 12 16:44:13 BST 2010


#128: Stride & Offset Approach to MultiDim Array Storage Order (related to #32)
------------------------+---------------------------------------------------
Reporter:  Pete Jemian  |       Owner:                  
    Type:  enhancement  |      Status:  new             
Priority:  major        |   Milestone:  release NXDL 1.0
Keywords:               |  
------------------------+---------------------------------------------------
 At NIAC2010, attached are email comments resulting from a discussion about
 use of the ''Stride & Offset Approach to (describe) MultiDimensional Array
 Storage Order''

 = Jim Kohl =
 {{{
 NeXus "Strides" Specification Example/Proposal

 In working through the examples below, it occurred to me
 that we probably need an "offset[]" to go along with the
 "stride[]" array, to indicate where to find the "1st" element
 along each axis...  :-)

 1-D:
 ----

   * raw data = 0 1 2 3 4 5 6 7 8 9
      size[1] = { 10 }  // assume uniform overall array dimensions

   * default stride:
      stride[1] = { 1 }
      offset[1] = { 0 }
      for i:
         result[i]:
            0 1 2 3 4 5 6 7 8 9

   * reverse stride:
      stride[1] = { -1 }
      offset[1] = { 9 }
      for i:
         result[i]:
            9 8 7 6 5 4 3 2 1 0

 2-D:
 ----

   * raw data = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
      size[2] = { 4, 5 }  // assume uniform overall array dimensions

   * row major (C) stride:
      stride[2] = { 5, 1 }
      offset[2] = { 0, 0 }
      for i:
         for j:
            result[i][j]:
               0 1 2 3 4
               5 6 7 8 9
               10 11 12 13 14
               15 16 17 18 19

   * column major (Fortran) stride:
      stride[2] = { 1, 4 }
      offset[2] = { 0, 0 }
      for i:
         for j:
            result[i][j]:
               0 4 8 12 16
               1 5 9 13 17
               2 6 10 14 18
               3 7 11 15 19

   * "crazy reverse" row major (C) stride:
      stride[2] = { -5, -1 }
      offset[2] = { 4, 5 }
      for i:
         for j:
            result[i][j]:
               19 18 17 16 15
               14 13 12 11 10
               9 8 7 6 5
               4 3 2 1 0

 3-D:
 ----

   * raw data = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
         20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
         40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
      size[3] = { 3, 4, 5 }  // assume uniform overall array dimensions

   * row major (C) stride:
      stride[3] = { 20, 5, 1 }
      offset[3] = { 0, 0, 0 }
      for i:
         for j:
            for k:
               result[i][j][k]:
                  0 1 2 3 4
                  5 6 7 8 9
                  10 11 12 13 14
                  15 16 17 18 19

                  20 21 22 23 24
                  25 26 27 28 29
                  30 31 32 33 34
                  35 36 37 38 39

                  40 41 42 43 44
                  45 46 47 48 49
                  50 51 52 53 54
                  55 56 57 58 59

   * column major (Fortran) stride:
      stride[3] = { 1, 3, 12 }
      offset[3] = { 0, 0, 0 }
      for i:
         for j:
            for k:
               result[i][j][k]:
                  0 12 24 36 48
                  3 15 27 39 51
                  6 18 30 42 54
                  9 21 33 45 57

                  1 13 25 37 49
                  4 16 28 40 52
                  7 19 31 43 55
                  10 22 34 46 58

                  2 14 26 38 50
                  5 17 29 41 53
                  8 20 32 44 56
                  11 23 35 47 59
 }}}

 = Freddie Akeroyd =
  * http://davis.lbl.gov/Manuals/HDF5-1.4.3/Tutor/phypereg.html

-- 
Ticket URL: <http://trac.nexusformat.org/definitions/ticket/128>
NeXus Base Classes and Instrument Definitions <http://www.nexusformat.org/>
NeXus Base Classes and Instrument Definitions



More information about the NeXus-definitions-tickets mailing list