Home > Archive > Fortran > September 2005 > Re: What do the symbols do in the following example:
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: What do the symbols do in the following example:
|
|
| Ron Shepard 2005-09-11, 6:57 pm |
| In article <1126446231.792231.220300@o13g2000cwo.googlegroups.com>,
"jdturner" <jamesdanielturner@hotmail.com> wrote:
> I found the following code on the WEB for inverting a matrix, but I
> have not found any documentation for the function of the bracket
> symbols. I would like to know what they mean, are the standard, will
> they port easily, .....
In f90 and f95, arrays may be specified, for example, with the
notation (/m,k/). In f2003, the somewhat shorter notation [m,k] has
been introduced, and some f95 compilers support that notation as an
extension. I did not check the actual algorithm in your code, but I
think if you just make the above syntax substitution it should
compile on any f90 or f95 standard compiler. When f2003 compilers
become common, you would not even have to make that syntax change.
$.02 -Ron Shepard
| |
| Richard Maine 2005-09-11, 6:57 pm |
| In article
<ron-shepard-D618F8.09125311092005@comcast.dca.giganews.com>,
Ron Shepard <ron-shepard@NOSPAM.comcast.net> wrote:
> In f90 and f95, arrays may be specified, for example, with the
> notation (/m,k/). In f2003, the somewhat shorter notation [m,k] has
> been introduced, and some f95 compilers support that notation as an
> extension.
So the portability today is... I'd say so-so. Some, but not all,
compilers accept it. More will probably do so in the future (it being a
pretty simple f2003 feature to implement).
However... I wouldn't use arrays for the purpose at all, even with the
standard f90/f95 syntax. The [k,m] forms are being used here as vector
subscripts. It is sort of a "cute" way to write the code, but I suspect
you will find the performance abysmal in this case. This has a fair
chance of causing the compiler to generate array temporaries, which
aren't really needed and would kill performance. Maybe some compilers
might be smart enough to figure out how to avoid the array temporary,
but I wouldn't count on it. I'd just write out the loops... or...
even better, use a tested and tuned reputable library routine for matrix
inversion instead of something picked up from a random source that
appears to have invested more time into experimenting with language
features than into careful design, or...
better still, I'll let others explain why inverting a matrix is often a
poor way to solve most problems (not always, but often).
I also noticed the matlab-like [1:n] notation used in place of the a
more verbose implied do to initialize ipvt. That is not very portable
at all; few compilers accept it. It is shorthand for something like [(i,
i=1,n)], or to stick with f90/f95, (/(i,i=1,n)/). The shorthand notation
is nice, but no, it isn't at all portable.
(Dave, in his usual way, obfuscates things by carefully avoiding saying
what standard he is talking about this w .)
|
|
|
|
|