Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!ucla-cs!ucla-seas!pantheon!willing From: willing@pantheon.seas.ucla.edu (Scott Willingham) 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: <1750@lee.SEAS.UCLA.EDU> Date: 2 Feb 91 20:22:55 GMT References: <1991Feb1.214342.4982@portia.Stanford.EDU> <1748@lee.SEAS.UCLA.EDU> <1991Feb2.071930.9879@portia.Stanford.EDU> Sender: news@SEAS.UCLA.EDU Distribution: na Organization: University of California at Los Angeles, EE dept. Lines: 42 In article <1991Feb2.071930.9879@portia.Stanford.EDU> fangchin@portia.Stanford.EDU (Chin Fang) writes: >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. 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