C# Translating a few smaller arrays to one big -


title may not explain want do, made image.

enter image description here

you can see there 4 1d arrays(red numbers, black colored numbers indexes), each of array goes 0 63. want somehow translate them, example, index 16 point first index of second array.

what thinking of, function give list of arrays , index want input, , returns me index of array , exact index in array output.

i have hints or suggestions on how proceed here achieve functionality.

ok, image shows interleaved data of 16 elements, want have (showing example of 2 matrices because of space :d)

global index  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 ----------------------------------------------------------------------------------------------------- array0 indexes                                  - array1 indexes  0  1  2  3  4  5  6  7  8  9   b  c  d  e  f -  0  1  2  3  4  5  6  7  8  9   b  c  d  e  f -------------------------------------------------------------------------------------------------  global index 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 60 61 62 63 64 65 ----------------------------------------------------------------------------------------------------- array0 indexes                                  - array1 indexes 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f - 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 

to can this:

public class compositeindex {     public int arraynumber { get; set; }     public int elementnumber { get; set; } }  public static compositeindex getindex(int globalindex, int arraycount, int elementstointerleave) {     compositeindex index = new compositeindex();     int fullarrays = globalindex / elementstointerleave; //in example: 16 / 16 = 1;     index.arraynumber = fullarrays % arraycount; //in example: 1 mod 4 = 1;      index.elementnumber = globalindex - (fullarrays * elementstointerleave); //in example: 16 - (1 * 16) = 0;     return index; } 

then, if have 4 matrices , want "global" index 16 do:

var index = getindex(16, 4, 16); 

this function allows use indeterminated number of arrays , interleaved elements.

btw, time ask better question, lot more people if don't have solve puzzles understand want...


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -