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

Home » Public Forums » archive » Re: analogue vector type in C++ for IDL ?
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: analogue vector type in C++ for IDL ? [message #68966] Sat, 05 December 2009 17:33
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Dec 5, 9:53 pm, "skymaxw...@gmail.com" <skymaxw...@gmail.com>
wrote:
> Good day !
>
> Does IDL have some instrument like vector type in C++ ?
> I have array MxN, but it's fixed. I want insert some rows there. How ?

Not like C++, which in this case is a big advantage of IDL, as it has
much nicer semantics. I find the C++ STL too awkward for more than 1D,
which is why I tend to make my own templates to use C++ vectors in a
similar way to IDL's arrays.

Note that in IDL arrays are column-major (the fastest varying
dimension is the leftmost), the opposite of C++.

A few examples to give you just a taste of the semantics:

a=[1,2,3,4]
print,a
; 1 2 3 4
a=[a,5,6,7]
print,a
; 1 2 3 4 5 6 7
a=[a[0:3],-1,-2,a[4:6]]
print,a
; 1 2 3 4 -1 -2 5
6 7
a=bindgen(2,3)
print,a
; 0 1
; 2 3
; 4 5
a=[a,transpose([-1,-2,-3])]
print,a
; 0 1 -1
; 2 3 -2
; 4 5 -3
a=[a,[[-4,-5],[-6,-7],[-8,-9]]]
print,a
; 0 1 -1 -4 -5
; 2 3 -2 -6 -7
; 4 5 -3 -8 -9
a=bindgen(2,3)
print,a
; 0 1
; 2 3
; 4 5
a=[[a],[-1,-2]]
print,a
; 0 1
; 2 3
; 4 5
; -1 -2
a=[[a],[[-3,-4],[-5,-6]]]
print,a
; 0 1
; 2 3
; 4 5
; -1 -2
; -3 -4
; -5 -6
a=[1,2,3]
print,a
; 1 2 3
a=reform(a,1,3)
print,a
; 1
; 2
; 3
a=rebin(a,2,3)
print,a
; 1 1
; 2 2
; 3 3

Also very useful are the ability to index multidimensional arrays by
single indices, use vector indices, treat contiguous slices as if the
remaining dimensions (to the right) did not exist, routines that work
with any number of dimensions, and some very powerful functions to use
and manipulate arrays, like where, value_locate, array_indices, rebin,
reform, and histogram.

A few good references are

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

And others in David's site.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: analogue vector type in C++ for IDL ?
Next Topic: remote applications kills X upon IDL exit

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

Current Time: Sun Oct 12 12:58:47 PDT 2025

Total time taken to generate the page: 0.71982 seconds