The C approach to doing transpose typically involves swapping the indices when they are used, and not bothering to make a fresh copy (or updated copy) of the data.
This of course yields a fair bit of complexity which gets pushed into the code (or into the objects) but that's how it's usually done. That said, you can achieve the same thing by explicitly copying the matrix using swapped indices. In a loop; b[j][k]= a[k][j] Or am I overlooking something important? (Also, perhaps this thread should be in chat?) Thanks, -- Raul On Mon, Jan 28, 2013 at 12:58 PM, Brian Schott <[email protected]> wrote: > I am trying to use objective C and am using j to develop some > pieces. I have the verb `transposeSquare` which transposes a square matrix's > indices using indices and reproduces j's Transpose. In C code the indices > are named ii and are being generated in a for loop as follows, where width > and height are actually both 13 but my j examples use 3 instead of 13. > > for (int ii = 0 ; ii < width * height ; ++ii) > > transposeSquare =: (] <.@% %:@#)+#| %:@# *] > transposeSquare i. 9 > 0 3 6 1 4 7 2 5 8 > ,|:i. 3 3 NB. this is the "J way" > 0 3 6 1 4 7 2 5 8 > > Now with C code for loop in mind I need a verb which first does what > transposeSquare does and then reverses the indices using the operators > available to C so that the result of the verb would be as follows. > > ,|.|:i. 3 3 NB. this is the "J way" > 2 5 8 1 4 7 0 3 6 > > That is, I need a verb (say, reverseOfTranspose, rOT), which gives > the same result as ,|.|:i. 3 3 but with the scalar argument 3 and is limited > to C operators. > > (B=) > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
