[25] | 1 | ;+ |
---|
| 2 | ; |
---|
[142] | 3 | ; file_comments |
---|
| 4 | ; computes the determinant of n 2 by 2 arrays |
---|
| 5 | ; Z2DS is an 2*2*n array |
---|
[25] | 6 | ; |
---|
[142] | 7 | ; @categories |
---|
| 8 | ; Without loop |
---|
| 9 | ; |
---|
| 10 | ; @param A {in}{required} |
---|
| 11 | ; n element array |
---|
| 12 | ; Defined as z2ds[0, 0, *] = z1d00 |
---|
[25] | 13 | ; |
---|
[142] | 14 | ; @param B {in}{required} |
---|
| 15 | ; n element array |
---|
| 16 | ; Defined as z2ds[0, 1, *] = z1d01 |
---|
[25] | 17 | ; |
---|
[142] | 18 | ; @param C {in}{required} |
---|
| 19 | ; n element array |
---|
| 20 | ; Defined as z2ds[1, 0, *] = z1d10 |
---|
[25] | 21 | ; |
---|
[142] | 22 | ; @param D {in}{required} |
---|
| 23 | ; n element array |
---|
| 24 | ; Defined as z2ds[1, 1, *] = z1d11 |
---|
[25] | 25 | ; |
---|
[142] | 26 | ; @returns |
---|
| 27 | ; n elements array, the determinent of each 2*2 arrrays |
---|
[25] | 28 | ; |
---|
[142] | 29 | ; @examples |
---|
[25] | 30 | ; a=findgen(2,2,5) |
---|
| 31 | ; print, determ2(a) |
---|
| 32 | ; FOR i=0,4 DO print, determ(a[*,*,i]) ; IDL solution |
---|
| 33 | ; |
---|
[142] | 34 | ; @history |
---|
[157] | 35 | ; S. Masson (smasson\@lodyc.jussieu.fr) |
---|
[25] | 36 | ; July 11th, 2002 |
---|
[142] | 37 | ; |
---|
| 38 | ; @version |
---|
| 39 | ; $Id$ |
---|
| 40 | ; |
---|
[25] | 41 | ;- |
---|
| 42 | FUNCTION determ2, a, b, c, d |
---|
[114] | 43 | ; |
---|
| 44 | compile_opt idl2, strictarrsubs |
---|
| 45 | ; |
---|
[25] | 46 | CASE n_params() OF |
---|
| 47 | 1:res = a[0, 0, *]*a[1, 1, *]-a[0, 1, *]*a[1, 0, *] |
---|
| 48 | 4:res = a[*]*d[*]-c[*]*b[*] |
---|
| 49 | ELSE:stop |
---|
| 50 | ENDCASE |
---|
| 51 | |
---|
| 52 | RETURN, res |
---|
| 53 | END |
---|