comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Applying scalar functions to arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Applying scalar functions to arrays [message #10431] Fri, 05 December 1997 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Niels V�ver Petersen (vaever@mi.aau.dk) writes:

> How can you apply an IDL scalar function to each element in an
> array, without using for loops?
>
> Suppose we have the following array:
>
> IDL> a=[0.05,0.01,0.001]
>
> Calculating cosine is easy!
> IDL> print,cos(a)
> 0.998750 0.999950 1.00000
>
> But how about chi-square quantiles...?
> IDL> print,chisqr_cvf(a,17)
> % Compiled module: CHISQR_CVF.
> % Expression must be a scalar in this context: <BYTE Array[3]>.

In this particular case, it is a matter of the author of
CHISQR_CVF not realizing that people might want to obtain
a vector of values. So the code wasn't written to support
it. You could add that modification yourself, if you like,
by modifying the CHISQR_CVF source code in your lib directory.

Without modifying the code yourself, I am afraid you are
stuck with a loop. I speak with some experience when I say
that it is not always easy to anticipate what users are going
to try to do with your code. :-)

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: RANDOMU (version 5) is not always uniform
Next Topic: Re: axis and the like

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 07:08:15 PDT 2025

Total time taken to generate the page: 0.80137 seconds