;+ ; NAME:determ2 ; ; PURPOSE: computes the determinant of n 2 by 2 arrays ; ; CATEGORY: no DO loops and better accuracy ; ; CALLING SEQUENCE: 2 cases: ; res = determ2(z2ds) ; res = determ2(z1d00,z1d01,z1d10,z1d11) ; ; INPUTS: ; z2ds: an 2*2*n array ; or ; z1d00,z1d01,z1d10,z1d11: the four n elements arrays ; defined as: ; z2ds[0, 0, *] = z1d00 ; z2ds[0, 1, *] = z1d01 ; z2ds[1, 0, *] = z1d10 ; z2ds[1, 1, *] = z1d11 ; ; OUTPUTS: n elements array, the determinent of each 2*2 arrrays ; ; EXAMPLE: ; ; a=findgen(2,2,5) ; print, determ2(a) ; FOR i=0,4 DO print, determ(a[*,*,i]) ; IDL solution ; ; MODIFICATION HISTORY: ; S. Masson (smasson@lodyc.jussieu.fr) ; July 11th, 2002 ;- FUNCTION determ2, a, b, c, d ; compile_opt idl2, strictarrsubs ; CASE n_params() OF 1:res = a[0, 0, *]*a[1, 1, *]-a[0, 1, *]*a[1, 0, *] 4:res = a[*]*d[*]-c[*]*b[*] ELSE:stop ENDCASE RETURN, res END