06-14-2010 03:14 AM
Hi, I have made up a little example that reads a table from the UIR, transposes it and displays data on an output table.
This is done by reading data in a single array and passing it to Transpose.
An interesting trick of tables is that you can obtain the same effect by reading data in column major order and writing them back in row major order (or vice-versa): this method also is included in the example.
You could think to use it in your app duplicating the original table in a new, hidden one to use only for transposition of the matrix: read transposed data back from the new table and discard it afterwards.
06-15-2010 12:02 PM - edited 06-15-2010 12:05 PM
Hi cat87,
Something like this should work for what you are doing.
int vector[100] = {0};
int matrix[10][10] = {0};
//Fake Data
for (int hundred = 0; hundred<100; hundred++)
{
vector[hundred]=hundred;
}
//Into Matrix
for (int tens = 0; tens < 10; tens++)
{
for(int ones = 0; ones <10; ones++)
{
matrix[tens][ones]=vector[(10*tens)+ones]; //(10*tens)+ones = the absoulte index of the vector
}
}
Hope this helps!
Regards,
06-16-2010 12:39 AM
Hi Dustin,
in my contribution to this problem I was trying to suggest that readable code is a valuable aspect - trying to avoid calling a vector 'matrix'... In that sense your sample code
hundred = 0; hundred<100; hundred++
is not exactly what I had in mind