Column-wise data storage for matrices in C, any advantage(s)?

Chin Fang fangchin at portia.Stanford.EDU
Sat Feb 2 18:19:30 AEST 1991


In article <1748 at lee.SEAS.UCLA.EDU> willing at pantheon.seas.ucla.edu (Scott Willingham) writes:
>In article <1991Feb1.214342.4982 at portia.Stanford.EDU> fangchin at elaine46.stanford.edu (Chin Fang) writes:
>>...
>>Now, note that this algorithm requires most rapid changes in indixing occuring
>>in COLUMNS, not rows!
>>
>...
>
>It seems to me that this is just a matter of syntax.  Whether you assign
>the first or second _index_ of a C array to correspond to a matrix row
>or column is arbitrary.  You just must be consistent in your usage
>throughout the algorithm.
>
Scott, yes. if you are willing to accept row index as column index.  You 
can use gaxpy ops. But, what a contortion!

In addition, for people not aware the importance of gaxpy ops, each 
"seemly" trivial column element access in fact involves a long ptr jump
equal the length of entire row. ie. when they use row index as row index,
col index as col index.

To me, reversing index would fall into the catagory of "kuldge".  But you 
are right, you can do gaxpy ops with such matrix declarations.  Remember I 
didn't say in my 1st posting that it couldn't be done.

In fact, the reason that I posted the question because I used the "kludge"
way of using matrices and got teased by my fellow FORTRAN programmers and 
so far I haven't come up any less kludgy way yet.

Finally, I want to make it clear that when I said most rapid changes in 
indixing occuring in COLUMNS, I meant that the ops "marching" in columns,
not rows.  The index used in the sentence didn't mean array element index!
I was using MATLAB syntax, not C.
 
Regards,
 
Chin Fang
Mechanical Engineering Department
Stanford University
fangchin at portia.stanford.edu



More information about the Comp.lang.c mailing list