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

Home » Public Forums » archive » Re: Help me aviod a FOR loop!?!?
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: Help me aviod a FOR loop!?!? [message #30411] Thu, 25 April 2002 07:47
James Tappin is currently offline  James Tappin
Messages: 54
Registered: December 1995
Member
Sean Davis wrote:

> I don't know if this is possible. I have 4 coeffecients,
> a,c,d,cd, that are each 3191-long arrays, and I would like to construct
> 3191, waveforms (of length 128) from these coefeccients.
>
> Here's what I'm trying to do:
>
> x = FINDGEN(128)
> yfit = FLTARR(128,3191)
>
> yfit = (a/cd)*( exp(-1.*c*x)-exp(-1.*d*x) )
>
> In the end, I would like yfit to be an array of (128,3191) or (3191,128).
>
> I can't figure out how to do this without using a FOR loop. Is there any
> hope for doing this without a FOR loop?
>

Try this:
x=findgen(1,128)
d1=intarr[128]
d2=intarr[3191]
yfit= (a/c*d)[*,d1]*(exp(-c[*,d1]*x[d2,*])-exp(-d[*,d1]*x[d2,*])

You could use explicit intarr calls for the dummy indices, but it take more
space.

James

--
+------------------------+-------------------------------+-- -------+
| James Tappin | School of Physics & Astronomy | O__ |
| sjt@star.sr.bham.ac.uk | University of Birmingham | -- \/` |
| Ph: 0121-414-6462. Fax: 0121-414-3722 | |
+--------------------------------------------------------+-- -------+
Re: Help me aviod a FOR loop!?!? [message #30436 is a reply to message #30411] Wed, 24 April 2002 02:01 Go to previous message
Malcolm Walters is currently offline  Malcolm Walters
Messages: 8
Registered: October 2001
Junior Member
"Sean Davis" <sdavis@nis.lanl.gov> wrote in message
news:Pine.LNX.4.33.0204231006000.1744-100000@vglass.lanl.gov ...
> I don't know if this is possible. I have 4 coeffecients,
> a,c,d,cd, that are each 3191-long arrays, and I would like to construct
> 3191, waveforms (of length 128) from these coefeccients.
>
> Here's what I'm trying to do:
>
> x = FINDGEN(128)
> yfit = FLTARR(128,3191)
>
> yfit = (a/cd)*( exp(-1.*c*x)-exp(-1.*d*x) )
>
> In the end, I would like yfit to be an array of (128,3191) or (3191,128).
>
> I can't figure out how to do this without using a FOR loop. Is there any
> hope for doing this without a FOR loop?

I think this calls for use of rebin and matrix multiplication.
The rebin is required to turn 'a' and 'cd' into arrays the same shape as the
result of the matrix multiplications.

so...
a=randomn(systime(/seconds),3191)
c=randomu(systime(/seconds),3191)
d=randomu(systime(/seconds),3191)
cd=randomn(systime(/seconds),3191)
x=findgen(128)
yfit = (rebin(a,3191,128,/sample)/rebin(cd,3191,128,/sample))*(
exp(-c#x)-exp(-d#x) )

Malcolm
>
> THANKS!!!!!!
>
> Sean
>
>
>
Re: Help me aviod a FOR loop!?!? [message #30438 is a reply to message #30436] Tue, 23 April 2002 20:23 Go to previous message
gutmann is currently offline  gutmann
Messages: 11
Registered: December 2001
Junior Member
something like

tmp=intarr(1,128)
tmp(*,*)=1

yfit = (tmp##(a/cd))*( exp(-1.*c##x)-exp(-1.*d##x) )


Now I'll step aside and let one of the gurus here tell it right
Re: Help me aviod a FOR loop!?!? [message #30451 is a reply to message #30438] Tue, 23 April 2002 10:06 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Sean Davis wrote:
>
> I don't know if this is possible. I have 4 coeffecients,
> a,c,d,cd, that are each 3191-long arrays, and I would like to construct
> 3191, waveforms (of length 128) from these coefeccients.
>
> Here's what I'm trying to do:
>
> x = FINDGEN(128)
> yfit = FLTARR(128,3191)
>
> yfit = (a/cd)*( exp(-1.*c*x)-exp(-1.*d*x) )
>
> In the end, I would like yfit to be an array of (128,3191) or (3191,128).
>
> I can't figure out how to do this without using a FOR loop. Is there any
> hope for doing this without a FOR loop?

Using matrix multiplication maybe?

paulv

--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: signed character
Next Topic: Re: How to make a ribbon plot

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

Current Time: Wed Oct 08 13:46:00 PDT 2025

Total time taken to generate the page: 0.00677 seconds