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

Home » Public Forums » archive » Re: basic soubt with fltarr
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: basic soubt with fltarr [message #30181] Thu, 11 April 2002 07:21 Go to next message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
trouble wrote:

> James,
>
> One of us has got columns and rows mixed up... are we victims of the
> column/row major format ? I think so ;)

Sorry, I do most of my work in C, so I sometimes get the terminology
reversed. Oddly enough, I almost never get mixed up about the ordering
in memory, but only about the words used to describe that ordering.

Unfortunately, it's easier to do these tricks along the last dimension
than along the first; that's intrinsic to the nature of the problem, and
not a defect of IDL itself. There are ways to do it without creating an
explicitly named temporary, but they make heavy use of transpose() to
turn the problem into a problem of concatenating along the last
dimension. That makes them significantly less efficient than the
following re-write of my original answer:
> Muks Raju wrote:
>
> Hello all...i have a basic doubt with fltarr. I have this fltarr
> Actuator = fltarr(100,4)
>
> now i need to remove the first 3 columns. How do i do this. Also i may

Actuator(3:*,*)

> need to add 3 columns at the beginning and at the end ...

newAct = fltarr(106, 4);
newAct(3:102,*) = Actuator

> ...or maybe a column
> of data in the middle.

newAct = fltarr(101,4)
newAct(0:49,*) = Actuator(0:49,*)
newAct(51:*,*) = Actuator(50:*,*)
Re: basic soubt with fltarr [message #30188 is a reply to message #30181] Thu, 11 April 2002 03:43 Go to previous messageGo to next message
the_cacc is currently offline  the_cacc
Messages: 104
Registered: October 2001
Senior Member
James,

One of us has got columns and rows mixed up... are we victims of the
column/row major format ? I think so ;)

Ciao.
Re: basic soubt with fltarr [message #30210 is a reply to message #30188] Wed, 10 April 2002 08:43 Go to previous messageGo to next message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Muks Raju wrote:

> Hello all...i have a basic doubt with fltarr. I have this fltarr
> Actuator = fltarr(100,4)
>
> now i need to remove the first 3 columns. How do i do this. Also i may

Actuator = Actuator(*,3)

Unfortunately, this result in a 2-D array with a trailing dimension of
1, which gets automatically converted by IDL into a 1-D array. I don't
know of any way around that.

> need to add 3 columns at the beginning and at the end ...

Actuator = [ [fltarr(100,3)], [Actuator], [floatarr(100,3)] ]

> ...or maybe a column
> of data in the middle.

Actuator = [ [Actuator(*,0:1)], [fltarr(100,1)], [Actuator(*,2:3)] ]
Re: basic soubt with fltarr [message #30212 is a reply to message #30210] Wed, 10 April 2002 06:01 Go to previous messageGo to next message
the_cacc is currently offline  the_cacc
Messages: 104
Registered: October 2001
Senior Member
Muks Raju <mpraju@umich.edu> wrote in message news:<3CB3F827.312818F9@umich.edu>...
> Hello all...i have a basic doubt with fltarr. I have this fltarr
> Actuator = fltarr(100,4)
>
> now i need to remove the first 3 columns. How do i do this. Also i may
> need to add 3 columns at the beginning and at the end or maybe a column
> of data in the middle. Ive seen about a million websites and help pages.
> None of them seem to be of any help. Could somebody please help me.
>
>
> Thanks in advance.
>
> Mux


You're bound to get some very clever responses to this one. Here's
possibly the least clever way:

Start with A = FLTARR(100,4).


* To remove the first three columns:

new = FLTARR(97,4)
new[*,*] = A[3:*,*]
A = new


* To add 3 more columns at the beginning:

new = FLTARR(103,4)
new[3:*,*] = A
A = new


* To add a column in the middle (at position p):

new = FLTARR(101,4)
new[0:p-1,*] = A[0:p-1,*]
new[p+1:*,*] = A[p:*,*]
A = new


It is possible to avoid using 'new' in most cases but you may prefer
doing it like this until you are comfortable with incomprehensible
array concatenation shennanigans.

Ciao.
Re: basic soubt with fltarr [message #30248 is a reply to message #30181] Fri, 12 April 2002 17:43 Go to previous message
Muks Raju is currently offline  Muks Raju
Messages: 6
Registered: April 2002
Junior Member
Hello
Thanks a lot for your help. My prog was running fine under most
conditions. But then i realised that it was converting the 2D array to a 1 D
array. Again..thanks a lot..

Mux


James Kuyper wrote:

> trouble wrote:
>
>> James,
>>
>> One of us has got columns and rows mixed up... are we victims of the
>> column/row major format ? I think so ;)
>
> Sorry, I do most of my work in C, so I sometimes get the terminology
> reversed. Oddly enough, I almost never get mixed up about the ordering
> in memory, but only about the words used to describe that ordering.
>
> Unfortunately, it's easier to do these tricks along the last dimension
> than along the first; that's intrinsic to the nature of the problem, and
> not a defect of IDL itself. There are ways to do it without creating an
> explicitly named temporary, but they make heavy use of transpose() to
> turn the problem into a problem of concatenating along the last
> dimension. That makes them significantly less efficient than the
> following re-write of my original answer:
>> Muks Raju wrote:
>>
>> Hello all...i have a basic doubt with fltarr. I have this fltarr
>> Actuator = fltarr(100,4)
>>
>> now i need to remove the first 3 columns. How do i do this. Also i may
>
> Actuator(3:*,*)
>
>> need to add 3 columns at the beginning and at the end ...
>
> newAct = fltarr(106, 4);
> newAct(3:102,*) = Actuator
>
>> ...or maybe a column
>> of data in the middle.
>
> newAct = fltarr(101,4)
> newAct(0:49,*) = Actuator(0:49,*)
> newAct(51:*,*) = Actuator(50:*,*)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL5.5 XROI problem...
Next Topic: Re: In Praise of HISTOGRAM

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

Current Time: Wed Oct 08 19:35:11 PDT 2025

Total time taken to generate the page: 0.00668 seconds