Você está na página 1de 3

FUNCTION Cramer, A, B, Double = Double, Zero = Zero

ON_ERROR, 2 ;Return to caller if error occurs.

TypeA = SIZE(A)
TypeB = SIZE(B)

if TypeA[1] ne TypeA[2] then $


MESSAGE, "Input array must be square."

if TypeA[3] ne 4 and TypeA[3] ne 5 then $


MESSAGE, "Input array must be float or double."

;If the DOUBLE keyword is not set then the internal precision and
;result are identical to the type of input.
if N_ELEMENTS(Double) eq 0 then $
Double = (TypeA[TypeA[0]+1] eq 5 or TypeB[TypeB[0]+1] eq 5)

if N_ELEMENTS(Zero) eq 0 and Double eq 0 then $


Zero = 1.0e-6 ;Single-precision zero.
if N_ELEMENTS(Zero) eq 0 and Double ne 0 then $
Zero = 1.0d-12 ;Double-precision zero.

DetermA = DETERM(A, Double = Double, Zero = Zero, /Check)


if DetermA eq 0 then MESSAGE, "Input array is singular."

if Double eq 0 then xOut = FLTARR(TypeA[1]) $


else xOut = DBLARR(TypeA[1])

for k = 0, TypeA[1]-1 do begin


ColumnK = A[k,*] ;Save the Kth column of a.
a[k,*] = B ;Permute the Kth column of A with B.
;Solve for the Kth component of the solution xOut
xOut[k] = DETERM(A, Double = Double, Zero = Zero) / DetermA
a[k,*] = ColumnK ;Restore A to its original state.
endfor

RETURN, xOut

END

IDL> P= [[1.0,1.0,2.0],[-1.0,2.0,3.0],[1.0,1.0,-1.0]]
IDL> N=[2.0,4.0,1.0]
IDL> result=cramer(P,N)
% Compiled module: DETERM.
% Compiled module: COND.
% Compiled module: NORM.
IDL> print, result
-0.111111 1.44444 0.333333
IDL> A=[4,3,6]
IDL> B=[2,-1,-4]
IDL> A[0,*]*B[0,*]+A[1,*]*B[1,*]+A[2,*]*B[2,*]
-19

IDL> A=[1,-2,0]
IDL> B=[2,1,0]
IDL> C=[1,-2,2]

IDL> AXB=[(B(2,*)*A(1,*)-B(1,*)*A(2,*)),(B(0,*)*A(2,*)-
B(2,*)*A(0,*)),(B(1,*)*A(0,*)-B(0,*)*A(1,*))]

IDL> PRINT, AXB


0 0 5
IDL> AXB[0,*]*C[0,*]+AXB[1,*]*C[1,*]+AXB[2,*]*C[2,*]
10

IDL> P= [[1.0,1.0,2.0],[-1.0,2.0,3.0],[1.0,1.0,-1.0]]
IDL> N= [[2.0,3.0,2.0],[-2.0,2.0,1.0],[3.0,1.0,-2.0]]
IDL> print, transpose((P*N)

print, transpose((P*N)
^
% Syntax error.
IDL> print, transpose(P*N)
2.00000 2.00000 3.00000
3.00000 4.00000 1.00000
4.00000 3.00000 2.00000
IDL> print, transpose(P)*transpose(N)
2.00000 2.00000 3.00000
3.00000 4.00000 1.00000
4.00000 3.00000 2.00000

pro PREGUNTA_7
file='D:\trabajos\Curso de Radar\Copia de TAREA\DATA\datos.dat';
ruteamos la data
data_struct = READ_ASCII(file, DATA_START=3); es una estructura
data=data_struct.field1 ; extraemos los datos
LATITUD=data(0,*); primera columna
LONGITUD=data(1,*); segunda columna
TEMPERATURA=data(2,*); tercera columna
MEDIA=MEAN(TEMPERATURA)
MINIMO=MIN(TEMPERATURA)
MAXIMO=MAX(TEMPERATURA)
print, MEDIA
print, MINIMO
print, MAXIMO
print, '#############FIN DEL PROCESAMIETO################'
end

Você também pode gostar