help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fortran indexing? (was Re: oct file: multiply a matrix by a vector)


From: Paul Kienzle
Subject: Re: fortran indexing? (was Re: oct file: multiply a matrix by a vector)
Date: Sun, 3 Jul 2005 22:52:45 -0400


On Jul 2, 2005, at 3:31 PM, Brian Blais wrote:

David Bateman wrote:
To reduce the number of cache misses you should traverse the matrix in the way it is stored in memory. Octave uses Fortran conventions for the storage and so you should reverse the for loops

this is the first time that I have heard that Octave uses Fortran
conventions for storage.  Is there a reason for this?  It seems like it
would be more difficult, given that both the scripting language, and
C++, indexes arrays down the column, row by row.

In practice, C's builtin array reference syntax is rarely used. That's because C doesn't let you pass the dimensions of the array as arguments. Instead you pass a simple vector and translate i,j into a single index. This technique doesn't favour one array layout over another.

Fortran does allow you to pass the array dimensions so the array layout does matter. IIRC, the original Matlab was coded in Fortran and they kept that convention when they recoded it in C.

Octave/Matlab let you treat a matrix as a simple vector by only using one index argument and it is easier to get this consistent if they use the same internal format.

- Paul



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]