Re: how can i get an [n,1] array without reform? [message #63823] |
Thu, 20 November 2008 20:58  |
Vince Hradil
Messages: 574 Registered: December 1999
|
Senior Member |
|
|
On Nov 20, 3:54 pm, James McCreight <mccre...@gmail.com> wrote:
> I now understand that this is an age-old debate in the IDL community,
> which really stirs emotions!
>
> I'll just accept that IDL truncates trailing dimensions by default and
> make the call to reform to get it back.
>
Whew! I didn't want to go down that road again 8^)
|
|
|
Re: how can i get an [n,1] array without reform? [message #63826 is a reply to message #63823] |
Thu, 20 November 2008 15:25   |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
James McCreight schrieb:
> I now understand that this is an age-old debate in the IDL community,
> which really stirs emotions!
>
> I'll just accept that IDL truncates trailing dimensions by default and
> make the call to reform to get it back.
>
>
Hi
that can be also solved by
if size(a, /n_dim) eq 1 and size(b, /n_dim) eq 1 then $
c = [[a],[b]] $
else ....
cheers
Reimar
>
>
> On Nov 20, 11:20 am, James McCreight <mccre...@gmail.com> wrote:
>> for clarity, i should have used in the first example:
>>
>> IDL> a=transpose([0,1])
>> IDL> b=transpose([2,3])
>> IDL> c=[a,b]
>> IDL> print,c
>> 0 2
>> 1 3
>
|
|
|
Re: how can i get an [n,1] array without reform? [message #63830 is a reply to message #63826] |
Thu, 20 November 2008 13:54   |
mccreigh
Messages: 13 Registered: January 2008
|
Junior Member |
|
|
I now understand that this is an age-old debate in the IDL community,
which really stirs emotions!
I'll just accept that IDL truncates trailing dimensions by default and
make the call to reform to get it back.
On Nov 20, 11:20 am, James McCreight <mccre...@gmail.com> wrote:
> for clarity, i should have used in the first example:
>
> IDL> a=transpose([0,1])
> IDL> b=transpose([2,3])
> IDL> c=[a,b]
> IDL> print,c
> 0 2
> 1 3
|
|
|
|
Re: how can i get an [n,1] array without reform? [message #63898 is a reply to message #63826] |
Fri, 21 November 2008 07:28  |
mccreigh
Messages: 13 Registered: January 2008
|
Junior Member |
|
|
> Hi
>
> that can be also solved by
>
> if size(a, /n_dim) eq 1 and size(b, /n_dim) eq 1 then $
> c = [[a],[b]] $
> else ....
>
> cheers
> Reimar
In my version of IDL (6.4.1), that gives a column vector of dimension
[1,2]. Which is not a solution, no free beer for you. Try again! :)
But that's OK, i will accept that it cant be done without reform.
Fortunately, in my code i already have a surrogate variable which
implies the dimension of a and b. But I still have to test (n eq
max-1) unnecessarily in all but one case, seems like a waste.
Should we all avoid using and concatenating column vectors then and
just use row vectors? I guess I could just put these in an array right
off the bat and avoid concatenation all together. That seems like it
would be faster anyway, if i'm really concerned with speed.
|
|
|