comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: REPLICATE question

Re: REPLICATE question
type: item
description: In article <32636705.41C6@jmc-luni.u-bordeaux2.fr> Mario Noyon <mnoyon@jmc-luni.u-bordeaux2.fr> writes: I would like to divide an arr1(n,n,m) by an arr2(n,n) and be able to obtain an array(n,n,m). I suppose there is a way to avoid the for statements. I had the idea to transform my arr2(n,n) in an arr2(n,n,m) where the m-elements are all the same but REPLICATE does not work with the arrays. Does some-one have an idea that could help me? how about, array=aar1 ; define "array" as an (n,n,m) array ii=lindgen(n*n*m) ; define "ii" as a one dimension index array array=arr1(ii)/aar2(ii/m) ; "ii/m" is the correct index array for "aar2" ; there is a one-to-one correspondence of ; "vector" elements on the RHS with "array" : elements on the LHS. Because "array" had ; already been defined as an (n,n,m) array, ; this equation does not alter the variable ; type. -- ____________________________________________________________ _______________ Paul Ricchiazzi Institute for Computational Earth System Science (ICESS) University of California, Santa Barbara email: paul@icess.ucsb.edu ____________________________________________________________ _______________
creator: paul
date: 1996-10-15T07:00:00-00:00

Re: REPLICATE question
type: item
description: In article <32636705.41C6@jmc-luni.u-bordeaux2.fr>, Mario Noyon <mnoyon@jmc-luni.u-bordeaux2.fr> writes: |> I would like to divide an arr1(n,n,m) by an arr2(n,n) and be able to |> obtain an array(n,n,m). I suppose there is a way to avoid the for |> statements. |> I had the idea to transform my arr2(n,n) in an arr2(n,n,m) where the |> m-elements are all the same but REPLICATE does not work with the arrays. |> |> Does some-one have an idea that could help me? |> |> Thanks. |> |> -- |> NOYON Mario |> Computer Science in Medical imaging |> University of Bordeaux 2 |> mnoyon@jmc-luni.u-bordeaux2.fr I would try two ways and see which is faster for i=0,m-1 do array(*,*,i) = arr1(*,*,i) / arr2(*,*) array = arr1 / rebin(reform(arr2,n,n,1),n,n,m) -- ************************************************************ *** ** Dan Bergmann dbergmann@llnl.gov ** ** Atmospheric Science Division fax (510) 422-5844 ** ** Lawrence Livermore National Lab human (510) 423-6765 **
creator: dan
date: 1996-10-15T07:00:00-00:00

Re: REPLICATE question
type: item
description: In article <PAUL.96Oct15094317@skua.s2k.ucsb.edu>, paul@skua.s2k.ucsb.edu (Paul Ricchiazzi) writes: |> |> In article <32636705.41C6@jmc-luni.u-bordeaux2.fr> Mario Noyon <mnoyon@jmc-luni.u-bordeaux2.fr> writes: |> |> I would like to divide an arr1(n,n,m) by an arr2(n,n) and be able to |> obtain an array(n,n,m). I suppose there is a way to avoid the for |> statements. |> I had the idea to transform my arr2(n,n) in an arr2(n,n,m) where the |> m-elements are all the same but REPLICATE does not work with the arrays. |> |> Does some-one have an idea that could help me? |> |> |> |> how about, |> |> array=aar1 ; define "array" as an (n,n,m) array |> ii=lindgen(n*n*m) ; define "ii" as a one dimension index array |> array=arr1(ii)/aar2(ii/m) ; "ii/m" is the correct index array for "aar2" I don't think that will actually work, but something similar might ii = lindgen(n*n*m) array = arr1(ii) / arr2(ii mod (n*n)) -- ************************************************************ *** ** Dan Bergmann dbergmann@llnl.gov ** ** Atmospheric Science Division fax (510) 422-5844 ** ** Lawrence Livermore National Lab human (510) 423-6765 **
creator: dan
date: 1996-10-16T07:00:00-00:00

Re: REPLICATE question
type: item
description: In article <540h21$eu5@danberg.llnl.gov>, dan@danberg.llnl.gov (Dan Bergmann) writes: |> |> In article <32636705.41C6@jmc-luni.u-bordeaux2.fr>, Mario Noyon <mnoyon@jmc-luni.u-bordeaux2.fr> writes: |> |> I would like to divide an arr1(n,n,m) by an arr2(n,n) and be able to |> |> obtain an array(n,n,m). I suppose there is a way to avoid the for |> |> statements. |> |> I had the idea to transform my arr2(n,n) in an arr2(n,n,m) where the |> |> m-elements are all the same but REPLICATE does not work with the arrays. |> |> |> |> Does some-one have an idea that could help me? |> |> |> |> Thanks. |> |> I would try two ways and see which is faster |> |> for i=0,m-1 do array(*,*,i) = arr1(*,*,i) / arr2(*,*) |> |> array = arr1 / rebin(reform(arr2,n,n,1),n,n,m) Well, several methods were suggested, and if I got them all right, here are some timing results for you (if anybody finds errors or have complaints about the implementations, please say so, and I'll rerun the tests...on the alphaserver at least). Timing programs are included at the end of this message. Method 0 is based on the first one of the above, just adding a MAKE_ARRAY call to get the original ARRAY. Method 1 is the second one of the above, adding a few /OVERWRITE and /SAMPLE keywords (see method 5 for results without these). Method 2 is the one using a one-dimensional index array as suggested by Paul Ricchiazzi, with some alterations to make it work. Method 3 is the same as #2, except with a MAKE_ARRAY call instead of copying. Method 4 is the "trick of the trailing zero subscript", suggested by James Tappin. I wouldn't have guessed right away that this produced the right result!! Method 5 (See method 1) The timing results for IDL v 4.0 and 3.6.1c are presented below for an AlphaServer (4CPUs, large cache, one other process competing for the cache space) and an AlphaStation. Lo and behold, version 3.6.1c is (as I've pointed out in earlier tests) *faster* than version 4.0, by about 10% in most cases (though exception…
creator: steinhh
date: 1996-10-17T07:00:00-00:00

Re: REPLICATE question
type: item
description: : |> In article <32636705.41C6@jmc-luni.u-bordeaux2.fr> Mario Noyon <mnoyon@jmc-luni.u-bordeaux2.fr> writes: : |> : |> I would like to divide an arr1(n,n,m) by an arr2(n,n) and be able to : |> obtain an array(n,n,m). I suppose there is a way to avoid the for : |> statements. : |> I had the idea to transform my arr2(n,n) in an arr2(n,n,m) where the : |> m-elements are all the same but REPLICATE does not work with the arrays. : |> : |> Does some-one have an idea that could help me? Various complicated methods have been suggested! All of which ignore the fact that IDL allows the addition of trailing zero subscripts. try: sa1 = size(arr1) ; Don't even need this if you've got the size of arr2 somewhere array = arr1/arr2(*,*,intarr(sa1(3)) and you're home free. +------------------------+---------------------------------- --+---------+ | James Tappin, | School of Physics & Space Research | O__ | | sjt@star.sr.bham.ac.uk | University of Birmingham | -- \/` | | Ph: 0121-414-6462. Fax: 0121-414-3722 | | +----------------------------------------------------------- --+---------+
creator: sjt
date: 1996-10-17T07:00:00-00:00