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

Scott Willingham willing at pantheon.seas.ucla.edu
Sun Feb 3 07:22:55 AEST 1991


In article <1991Feb2.071930.9879 at portia.Stanford.EDU> fangchin at portia.Stanford.EDU (Chin Fang) writes:
>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.

Why do you insist on naming C array indices as row & column indices?
They are simply 1st, 2nd, 3rd, etc. indices.  Their syntax makes sense
in the context of a computer language's design.  I agree that it is
convenient for a programming language's systax to correspond directly
to common mathematical notation, but I wouldn't call it a kludge to
be otherwise.  Further, I don't consider it all that confusing -- and
most mathematicians seem to adapt to many notational changes much better
than I do.  I would suggest that you stay with such notation and be sure
to comment your code well.

Then again, maybe FORTRAN is better suited to your programming needs.
However, it has its own set of "inconveniences".  It seems to me
that a translation of a mathematical algorithm to computer code
requires an intimate familiarity with both notations, no matter
what language is chosen.

Maybe some other net contributers can come up with a more creative
solution that I have suggested.  I wish you good luck on your project.

-- Scott D. Willingham



More information about the Comp.lang.c mailing list