source: trunk/SRC/ToBeReviewed/MATRICE/colle.pro @ 325

Last change on this file since 325 was 325, checked in by pinsard, 17 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.8 KB
Line 
1;+
2; @file_comments
3; This concatenation function exist in IDL so long
4; as we do not try to stick with a dimension superior or equal at 4.
5;
6; @categories
7; Utilities
8;
9; @param a0 {in}{required}
10;
11; @param a1 {in}{required}
12;
13; @param a2 {in}{required}
14;
15; @param a3 {in}{required}
16;
17; @param a4 {in}{required}
18;
19; @param a5 {in}{required}
20;
21; @param a6 {in}{required}
22;
23; @param a7 {in}{required}
24;
25; @param a8 {in}{required}
26;
27; @param a9 {in}{required}
28;
29; @param a10 {in}{required}
30;
31; @param a11 {in}{required}
32;
33; @param a12 {in}{required}
34;
35; @param a13 {in}{required}
36;
37; @param a14 {in}{required}
38;
39; @param a15 {in}{required}
40;
41; @param a16 {in}{required}
42;
43; @param a17 {in}{required}
44;
45; @param a18 {in}{required}
46;
47; @param a19 {in}{required}
48;
49; @param a20 {in}{required}
50;
51; @keyword SAUVE
52; force to save the pointer array and arrays to be stuck
53;
54; @returns
55; matrice resultat
56;
57; @examples
58; IDL> print, colle(replicate(1,2,2,2),indgen(2,2,2),2)
59;                1       1
60;                1       1
61;                0       1
62;                2       3
63;
64;                1       1
65;                1       1
66;                4       5
67;                6       7
68;
69; @history
70; Sebastien Masson (smasson\@lodyc.jussieu.fr)
71;                       13/1/98
72;
73; @version
74; $Id$
75;
76;-
77FUNCTION colle, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, SAUVE = sauve
78;
79  compile_opt idl2, strictarrsubs
80;
81   res = -1
82;------------------------------------------------------------
83; We put in place ptrtab and direc in function of input arguments
84;------------------------------------------------------------
85   case 1 of
86      n_params() EQ 2:BEGIN     ; case where we directly give the pointer array
87         ptrtab = a0
88         direc = a1
89         if NOT keyword_set(sauve) then undefine, a0
90; on recuperate the number of array to be pasted.
91         nbretab = (size(ptrtab))[1]
92      end
93      n_params() GT 2:BEGIN
94; on recuperate the number of array to be pasted.
95         nbretab = n_params()-1
96         bidon = execute('direc = a'+strtrim(n_params()-1, 2))
97; We write the pointer array whose each element point on an array.
98         ptrtab=ptrarr(nbretab,/allocate_heap)
99         for n = 0,nbretab-1 do begin
100            bidon = execute('*ptrtab[n]=a'+strtrim(n, 2))
101            if NOT keyword_set(sauve) then bidon = execute('undefine, a'+strtrim(n, 2))
102         endfor
103         sauve = 0
104      end
105      ELSE:
106   endcase
107;------------------------------------------------------------
108; case on the direct's value.
109;------------------------------------------------------------
110   case direc of
111      1:BEGIN                   ; we paste following the dimension 1
112         res = *ptrtab[0]
113         if NOT keyword_set(sauve) then ptr_free, ptrtab[0]
114         FOR n = 1,nbretab-1 DO BEGIN
115            res = [temporary(res), *ptrtab[n]]
116            if NOT keyword_set(sauve) then ptr_free, ptrtab[n]
117         ENDFOR
118      END
119      2:BEGIN                   ; we paste following the dimension 2
120         res = *ptrtab[0]
121         if NOT keyword_set(sauve) then ptr_free, ptrtab[0]
122         FOR n = 1,nbretab-1 DO BEGIN
123            res = [[temporary(res)], [*ptrtab[n]]]
124            if NOT keyword_set(sauve) then ptr_free, ptrtab[n]
125         ENDFOR
126      END
127      3:BEGIN                   ; we paste following the dimension 3
128         res = *ptrtab[0]
129         if NOT keyword_set(sauve) then ptr_free, ptrtab[0]
130         FOR n = 1,nbretab-1 DO BEGIN
131            res = [[[temporary(res)]], [[*ptrtab[n]]]]
132            if NOT keyword_set(sauve) then ptr_free, ptrtab[n]
133         ENDFOR
134      END
135      ELSE:BEGIN
136; We transpose res in order to put the dimension to be pasted number 1
137; To this, we contain the permuter vector which give the place that dimension
138; in the transposed matrix must take.
139        siz = (size(*ptrtab[0]))[0]
140         if siz LT direc then $
141          *ptrtab[0] = reform(*ptrtab[0], [(size(*ptrtab[0]))[1:siz], replicate(1, direc-siz)], /over)
142         permute = indgen((size(*ptrtab[0]))[0])
143         permute[0] = direc-1
144         permute[direc-1] = 0
145         res = transpose(*ptrtab[0], permute)
146         if NOT keyword_set(sauve) then ptr_free, ptrtab[0]
147         FOR n = 1,nbretab-1 DO BEGIN ; we paste following the dimension 1on colle suivant la dimension 1
148            if (size(*ptrtab[n]))[0] LT direc then $
149             *ptrtab[n] = reform(*ptrtab[n], [(size(*ptrtab[n]))[1:siz], replicate(1, direc-siz)])
150            res = [temporary(res), transpose(*ptrtab[n], permute)]
151            if NOT keyword_set(sauve) then ptr_free, ptrtab[n]
152         ENDFOR
153         res = transpose(temporary(res), permute)
154      END
155   ENDCASE
156;------------------------------------------------------------
157   if NOT keyword_set(sauve) then undefine, ptrtab
158sortie:
159   return,  res
160END
Note: See TracBrowser for help on using the repository browser.