|
Prev: Call Array valued Fortran function from C
Next: Advice on how to keep track of allocated memory
From: Luka Djigas on 20 Apr 2008 19:12 On Sun, 20 Apr 2008 11:05:57 -0400, "David Frank" <dave_frank(a)hotmail.com> wrote: > >"Luka Djigas" <ldigas@@gmail.com> wrote in message >news:pu4l04dnt3apg1hf1a1jvesp0gf3jttiol(a)4ax.com... >> What would be the shortest way to sum some elements of an array? For >> example from 5 to 50. >> > >Gee whiz, all these replies and no-one shows him what he asked for. > > asum = SUM(a(5:50)) > Yes ! That's what I've been looking for :-) I couldn't figure out (nor find an example) how to write the mask part. So I tried SUM(x,1,1:3) ... SUM(x,1,(1:3) ... and such ... Thanks David ... uhmm ... or Frank (?) regards dig
From: Luka Djigas on 20 Apr 2008 19:35 On Sun, 20 Apr 2008 10:21:27 -0500, dpb <none(a)non.net> wrote: > >I saw a response that used 5,50 in a loop but didn't realize it was the >actual question. Sorry about that :-) Response ? The 5,50 loop was in the original post ... I saw the first responses that came after that, but I didn't quite understand what they were trying to say in those (except that dimension can't be written as dim, and something about summing the i-elements which they converted to real) > >The reply to look at array sections was spot on, though, wasn't it?? :) Yes. Gave me a few other interesting points to read, and to think of. Also found a nice example that does simplify some things I've been doing the other way. Uhmm, how to say this ... it's a strange situation, this ... I sometimes know, or at least am pretty sure that there is a better way of doing something, but don't know where to even begin searching in help. Anyway, thank you, and all the others, for your help. regards dig
From: dpb on 20 Apr 2008 19:59 Luka Djigas wrote: .... > Uhmm, how to say this ... it's a strange situation, this ... I > sometimes know, or at least am pretty sure that there is a better way > of doing something, but don't know where to even begin searching in > help. When learning a new language, one thing to do is to gradually simply read the entire LRF from cover to cover so you at least see all the features. You obviously won't learn them all from that single perusal, but you will have the experience of having seen it so there's a least a reasonable chance of recalling of "I remember something about...". Also, as Richard Maine noted in an response in the last day or so, to learn really requires more than simply a language reference manual. There are regular threads here about recommendations for books for various purposes. ---
From: glen herrmannsfeldt on 20 Apr 2008 20:21 dpb wrote: (snip) > Also, as Richard Maine noted in an response in the last day or so, to > learn really requires more than simply a language reference manual. > There are regular threads here about recommendations for books for > various purposes. You should be able to learn a language from a good language reference manual and a system to try out programs on. Not all LRM's are good, though. -- glen
From: Luka Djigas on 20 Apr 2008 22:03
On Sun, 20 Apr 2008 16:21:20 -0800, glen herrmannsfeldt <gah(a)ugcs.caltech.edu> wrote: > >You should be able to learn a language from a good language >reference manual and a system to try out programs on. >Not all LRM's are good, though. > >-- glen I might add, somebody who you can bother with questions, comes very handy too in the process of learning :-) regards Luka |