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

Home » Public Forums » archive » Re: Matrix expansion performance
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: Matrix expansion performance [message #43248] Wed, 30 March 2005 00:22 Go to next message
Timm Weitkamp is currently offline  Timm Weitkamp
Messages: 66
Registered: August 2002
Member
On 29.03.05 at 10:55 +0100, Ricardo Bugalho wrote:

> I think I didn't make clear the ranges of m,n and p.
> In the problem I have at hand, m is always 8, n is usually 5 (min 1, max 16)
> and p is in the range of 10,000 to 100,000.
> Looping over p is a BadThing(tm) due to IDL's high interpretation overhead.

The method that Chris Lee suggested does not use loops. But I think there
is no need for any call to REFORM. And the dimension arguments to REBIN
must be scalars in IDL 5.4. A simple

b = rebin(a, m, n, p, /sample)

should therefore work (and, hopefully, be fast enough for your purposes).

Timm

--
Timm Weitkamp <http://people.web.psi.ch/weitkamp>
Re: Matrix expansion performance [message #43263 is a reply to message #43248] Tue, 29 March 2005 01:55 Go to previous messageGo to next message
Ricardo Bugalho is currently offline  Ricardo Bugalho
Messages: 22
Registered: March 2005
Junior Member
"Kenneth P. Bowman" <kpb@null.com> wrote in message
news:kpb-E62DD6.07500028032005@news.tamu.edu...
> In article <d28tre$j32$1@pegasus.fccn.pt>,
> "Ricardo Bugalho" <rbugalho@ibili.uc.pt> wrote:
>
>> I have a matrix A (m,n) is and I want to create a matrix B(m,n,p) such
>> that
>> each B(*,*,i) slice equals A. p is very large and n is usually smaller
>> than
>> m so I have:

>
> This should be quite fast, if I understand your problem correctly:

I think I didn't make clear the ranges of m,n and p.
In the problem I have at hand, m is always 8, n is usually 5 (min 1, max 16)
and p is in the range of 10,000 to 100,000.
Looping over p is a BadThing(tm) due to IDL's high interpretation overhead.

>
> B = BYTARR(m,n,p)
> FOR k = 0, p-1 DO B[0,0,k] = A
>
> This will avoid subscript arrays and should access memory efficiently on
> most machines.
Re: Matrix expansion performance [message #43272 is a reply to message #43263] Mon, 28 March 2005 05:50 Go to previous messageGo to next message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <d28tre$j32$1@pegasus.fccn.pt>,
"Ricardo Bugalho" <rbugalho@ibili.uc.pt> wrote:

> Hi,
> I have a matrix A (m,n) is and I want to create a matrix B(m,n,p) such that
> each B(*,*,i) slice equals A. p is very large and n is usually smaller than
> m so I have:
>
> B=bytArr(m,n,p)
> C=byteArr(p) + 1
> FOR i = 0, n-1 DO B[*,i,*] = REFORM(A[*,i]) # p

This should be quite fast, if I understand your problem correctly:

B = BYTARR(m,n,p)
FOR k = 0, p-1 DO B[0,0,k] = A

This will avoid subscript arrays and should access memory efficiently on
most machines.

Ken Bowman
Re: Matrix expansion performance [message #43273 is a reply to message #43272] Mon, 28 March 2005 05:43 Go to previous messageGo to next message
Chris Lee is currently offline  Chris Lee
Messages: 101
Registered: August 2003
Senior Member
In article <d28tre$j32$1@pegasus.fccn.pt>, "Ricardo Bugalho"
<rbugalho@ibili.uc.pt> wrote:


> Hi,
> I have a matrix A (m,n) is and I want to create a matrix B(m,n,p) such
> that each B(*,*,i) slice equals A. p is very large and n is usually
> smaller than m so I have:
> B=bytArr(m,n,p)
> C=byteArr(p) + 1
> FOR i = 0, n-1 DO B[*,i,*] = REFORM(A[*,i]) # p Quite fast, but not
> enough for my needs. Any one has better sugestions? Still stuck in IDL
> 5.4, by the way.
> Thanks,
> Ricardo
>

Assuming your code was wrong, and that #p should be #C. A bit of reform
magic will do what you want.

http://www.dfanning.com/tips/rebin_magic.html

e.g.

b=rebin(reform(a, [m, n,1]), [m,n,p])

Chris.
Re: Matrix expansion performance [message #43343 is a reply to message #43248] Wed, 30 March 2005 07:21 Go to previous message
Chris Lee is currently offline  Chris Lee
Messages: 101
Registered: August 2003
Senior Member
In article
<Pine.LNX.4.44.0503301010060.7505-100000@localhost.localdomain>, "Timm
Weitkamp" <dont.try@this.address> wrote:


> On 29.03.05 at 10:55 +0100, Ricardo Bugalho wrote:
>> I think I didn't make clear the ranges of m,n and p. In the problem I
>> have at hand, m is always 8, n is usually 5 (min 1, max 16) and p is in
>> the range of 10,000 to 100,000. Looping over p is a BadThing(tm) due to
>> IDL's high interpretation overhead.
> The method that Chris Lee suggested does not use loops. But I think
> there is no need for any call to REFORM. And the dimension arguments to
> REBIN must be scalars in IDL 5.4. A simple
>
> b = rebin(a, m, n, p, /sample)
> should therefore work (and, hopefully, be fast enough for your
> purposes). Timm
>

My first reaction was "when did that happen?", I tried it without the
reform, and it works...except

IDL> help, rebin(fltarr(4,5),[7,4,5,6])
% REBIN: Result dimensions must be integer factor of original dimensions

doesn't work (6.1.1 Linux), but the reform version does

IDL> help, rebin(reform(fltarr(4,5),[1,4,5,1]),[7,4,5,6])
<Expression> FLOAT = Array[7, 4, 5, 6]

So my world-view isn't completely shattered :)

Chris.
Re: Matrix expansion performance [message #43346 is a reply to message #43248] Wed, 30 March 2005 04:18 Go to previous message
Ricardo Bugalho is currently offline  Ricardo Bugalho
Messages: 22
Registered: March 2005
Junior Member
I used Chris' method.
However, I've been having some problems posting and my thanks to him got
lost.

"Timm Weitkamp" <dont.try@this.address> wrote in message
news:Pine.LNX.4.44.0503301010060.7505-100000@localhost.local domain...
>
> The method that Chris Lee suggested does not use loops. But I think there
> is no need for any call to REFORM. And the dimension arguments to REBIN
> must be scalars in IDL 5.4. A simple
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Line-Mouse widget tool
Next Topic: IDLWAVE Manuals: Your Support Needed

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

Current Time: Wed Oct 08 15:32:47 PDT 2025

Total time taken to generate the page: 0.00666 seconds