Re: IDL Way to have a single row/collum act on all rows/collums in an array [message #89541 is a reply to message #89540] |
Fri, 24 October 2014 07:49   |
rryan%stsci.edu
Messages: 16 Registered: October 2014
|
Junior Member |
|
|
Unfortunately, I am unaware of a better way of doing arithmetic of the form
Matrix _DO_SOMETHING_HERE_ vector
where the vector is applied to all the rows/columns of the matrix without looping or beefing up the vector to match the matrix.
Two more things. First a question. How huge is HUGE? What are the real dimensions of the 2 matrices and vectors. Also, do you really need them both in memory? Like, do you need all the past time values in memory at this time?
Second a statement. If the answer is Yes, i need everything at all times. Then doing
a= x# make_array()
is going to be slow. Because the # operator is doing arthimeic. You'll likely be better off using rebin and reform to achieve the same goal.
-Russell
On Friday, October 24, 2014 10:32:43 AM UTC-4, JTMHD wrote:
> Hi Guys,
>
>
> What I am trying to do is analogous to the following
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> timedistancearray =FINDGEN(3,3)
>
> timezero = timedistancearray(*,0)
>
> timedistance_minustimezero = FLTARR(3,3)
>
> FOR t=0,2 DO timedistance_minustimezero(*,t)=timedistancearray(*,t)-timez ero
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
> The thing is in this case the array is HUGE so I don't think the FOR loop would be optimum.
>
> The other thing I thought about was taking the timezero array and changing it into a 2D array of the correct dimensions, e.g.
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;
>
> timedistancearray =FINDGEN(3,3)
>
> timezero = timedistancearray(*,0)#MAKE_ARRAY(1, 3, /DOUBLE, VALUE = 1D0)
>
> timedistance_minustimezero = timedistancearray-timezero
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;
>
> But again, this perhaps isn't ideal as it will involve creating an equally huge array to do the operation which will have add to the memory overhead.
>
> I keep hearing that if you want to get good at IDL you have to exploit the array operations properly - what other options do I have here?
>
> Thanks in advance
>
> Jonathan
|
|
|