Re: Help me aviod a FOR loop!?!? [message #30411] |
Thu, 25 April 2002 07:47 |
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  |
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 #30451 is a reply to message #30438] |
Tue, 23 April 2002 10:06  |
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
|
|
|