Last change
on this file since 114 was
114,
checked in by smasson, 18 years ago
|
new compilation options (compile_opt idl2, strictarrsubs) in each routine
|
-
Property svn:executable set to
*
|
File size:
995 bytes
|
Rev | Line | |
---|
[25] | 1 | ;+ |
---|
| 2 | ; NAME:determ2 |
---|
| 3 | ; |
---|
| 4 | ; PURPOSE: computes the determinant of n 2 by 2 arrays |
---|
| 5 | ; |
---|
| 6 | ; CATEGORY: no DO loops and better accuracy |
---|
| 7 | ; |
---|
| 8 | ; CALLING SEQUENCE: 2 cases: |
---|
| 9 | ; res = determ2(z2ds) |
---|
| 10 | ; res = determ2(z1d00,z1d01,z1d10,z1d11) |
---|
| 11 | ; |
---|
| 12 | ; INPUTS: |
---|
| 13 | ; z2ds: an 2*2*n array |
---|
| 14 | ; or |
---|
| 15 | ; z1d00,z1d01,z1d10,z1d11: the four n elements arrays |
---|
| 16 | ; defined as: |
---|
| 17 | ; z2ds[0, 0, *] = z1d00 |
---|
| 18 | ; z2ds[0, 1, *] = z1d01 |
---|
| 19 | ; z2ds[1, 0, *] = z1d10 |
---|
| 20 | ; z2ds[1, 1, *] = z1d11 |
---|
| 21 | ; |
---|
| 22 | ; OUTPUTS: n elements array, the determinent of each 2*2 arrrays |
---|
| 23 | ; |
---|
| 24 | ; EXAMPLE: |
---|
| 25 | ; |
---|
| 26 | ; a=findgen(2,2,5) |
---|
| 27 | ; print, determ2(a) |
---|
| 28 | ; FOR i=0,4 DO print, determ(a[*,*,i]) ; IDL solution |
---|
| 29 | ; |
---|
| 30 | ; MODIFICATION HISTORY: |
---|
| 31 | ; S. Masson (smasson@lodyc.jussieu.fr) |
---|
| 32 | ; July 11th, 2002 |
---|
| 33 | ;- |
---|
| 34 | FUNCTION determ2, a, b, c, d |
---|
[114] | 35 | ; |
---|
| 36 | compile_opt idl2, strictarrsubs |
---|
| 37 | ; |
---|
[25] | 38 | CASE n_params() OF |
---|
| 39 | 1:res = a[0, 0, *]*a[1, 1, *]-a[0, 1, *]*a[1, 0, *] |
---|
| 40 | 4:res = a[*]*d[*]-c[*]*b[*] |
---|
| 41 | ELSE:stop |
---|
| 42 | ENDCASE |
---|
| 43 | |
---|
| 44 | RETURN, res |
---|
| 45 | END |
---|
Note: See
TracBrowser
for help on using the repository browser.