Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!shelby!portia.stanford.edu!fangchin From: fangchin@portia.Stanford.EDU (Chin Fang) Newsgroups: comp.lang.c Subject: Re: Column-wise data storage for matrices in C, any advantage(s)? Keywords: store data in rows/columns, memory traffic, gaxpy rich Message-ID: <1991Feb2.071930.9879@portia.Stanford.EDU> Date: 2 Feb 91 07:19:30 GMT References: <1991Feb1.214342.4982@portia.Stanford.EDU> <1748@lee.SEAS.UCLA.EDU> Distribution: na Organization: AIR, Stanford University Lines: 40 In article <1748@lee.SEAS.UCLA.EDU> willing@pantheon.seas.ucla.edu (Scott Willingham) writes: >In article <1991Feb1.214342.4982@portia.Stanford.EDU> fangchin@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@portia.stanford.edu