1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; computes the determinant of n 3 by 3 arrays. |
---|
5 | ; Z2DS is an 3*3*n array |
---|
6 | ; |
---|
7 | ; @categories |
---|
8 | ; Without loop |
---|
9 | ; |
---|
10 | ; @param IN00 {in}{required} |
---|
11 | ; It is an n element array |
---|
12 | ; defined by in00 = z2ds[0, 0, *] |
---|
13 | ; |
---|
14 | ; @param IN01 {in}{required} |
---|
15 | ; It is an n element array |
---|
16 | ; defined by in01 = z2ds[0, 1, *] |
---|
17 | ; |
---|
18 | ; @param IN02 {in}{required} |
---|
19 | ; It is an n element array |
---|
20 | ; defined by in02 = z2ds[0, 2, *] |
---|
21 | ; |
---|
22 | ; @param IN10 {in}{required} |
---|
23 | ; It is an n element array |
---|
24 | ; defined by in10 = z2ds[1, 0, *] |
---|
25 | ; |
---|
26 | ; @param IN11 {in}{required} |
---|
27 | ; It is an n element array |
---|
28 | ; defined by in11 = z2ds[1, 1, *] |
---|
29 | ; |
---|
30 | ; @param IN12 {in}{required} |
---|
31 | ; It is an n element array |
---|
32 | ; defined by in12 = z2ds[1, 2, *] |
---|
33 | ; |
---|
34 | ; @param IN20 {in}{required} |
---|
35 | ; It is an n element array |
---|
36 | ; defined by in20 = z2ds[2, 0, *] |
---|
37 | ; |
---|
38 | ; @param IN21 {in}{required} |
---|
39 | ; It is an n element array |
---|
40 | ; defined by in21 = z2ds[2, 1, *] |
---|
41 | ; |
---|
42 | ; @param IN22 {in}{required} |
---|
43 | ; It is an n element array |
---|
44 | ; defined by in22 = z2ds[2, 2, *] |
---|
45 | ; |
---|
46 | ; @returns |
---|
47 | ; n elements array, the determinant of each 3*3 arrays |
---|
48 | ; |
---|
49 | ; @examples |
---|
50 | ; a=findgen(3,3,5) |
---|
51 | ; print, determ3(a^2) |
---|
52 | ; FOR i=0,4 DO print, determ((a[*,*,i])^2) ; IDL solution |
---|
53 | ; |
---|
54 | ; @history |
---|
55 | ; S. Masson (smasson\@lodyc.jussieu.fr) |
---|
56 | ; July 11th, 2002 |
---|
57 | ; |
---|
58 | ; @version |
---|
59 | ; $Id$ |
---|
60 | ; |
---|
61 | ;- |
---|
62 | FUNCTION determ3, in00, in01, in02, in10, in11, in12, in20, in21, in22 |
---|
63 | ; |
---|
64 | compile_opt idl2, strictarrsubs |
---|
65 | ; |
---|
66 | IF n_params() EQ 1 THEN BEGIN |
---|
67 | in00save = temporary(in00) |
---|
68 | in00 = in00save[0, 0, *] |
---|
69 | in01 = in00save[0, 1, *] |
---|
70 | in02 = in00save[0, 2, *] |
---|
71 | in10 = in00save[1, 0, *] |
---|
72 | in11 = in00save[1, 1, *] |
---|
73 | in12 = in00save[1, 2, *] |
---|
74 | in20 = in00save[2, 0, *] |
---|
75 | in21 = in00save[2, 1, *] |
---|
76 | in22 = in00save[2, 2, *] |
---|
77 | ENDIF |
---|
78 | |
---|
79 | a01 = -determ2(in10[*], in20[*] $ |
---|
80 | , in12[*], in22[*]) |
---|
81 | |
---|
82 | a11 = determ2(in00[*], in20[*] $ |
---|
83 | , in02[*], in22[*]) |
---|
84 | |
---|
85 | a21 = -determ2(in00[*], in10[*] $ |
---|
86 | , in02[*], in12[*]) |
---|
87 | |
---|
88 | res = in01[*]*a01+in11[*]*a11+in21[*]*a21 |
---|
89 | |
---|
90 | IF n_params() EQ 1 THEN in00 = temporary(in00save) |
---|
91 | |
---|
92 | RETURN, res |
---|
93 | END |
---|