3

My problem is this: I've an array with values from 0 to 8(a[9]=[0,1,2,....,8] and I would map the indexes of array to a matrix 3x3. This is useful for me to develop the "Broadcast Multiply Rolling" algorithm to make the product of two matrices. Thank to everyone

3
  • Why not write the matrix array right away if values are fixed? Commented Dec 7, 2013 at 18:19
  • You should at least give it a try yourself before asking for help. What problems did you face, what errors you got? Commented Dec 7, 2013 at 18:21
  • I'm glad you found my answer useful. Now ask yourself how you would calculate the indexes for an n-dimensional array. It's not complex, it's a general concept, and it's something any C programmer should understand. Commented Dec 8, 2013 at 0:00

1 Answer 1

2

If index is an index into a single-dimensional array of 9 elements, the array can be viewed as a two-dimensional 3x3 array with this:

int row = index / 3;
int column = index % 3;
int foo = array[row][column];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.