Skip to content

Instantly share code, notes, and snippets.

@luksamuk
Created August 23, 2019 00:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save luksamuk/8ae9f5afcbfa1af16ce2b3099e1f90ef to your computer and use it in GitHub Desktop.
Save luksamuk/8ae9f5afcbfa1af16ce2b3099e1f90ef to your computer and use it in GitHub Desktop.
Escalonando Matrizes em APL: Código
RIDENTITY N
R(N N)(1,N0)
REXTENDBOTTOM MAT
R(((MAT)1),0)\[1]MAT
REXTENDRIGHT MAT
R(((2MAT)1),0)\MAT
RN PIVOT MAT;LST;IDX
LSTN[1]MAT
IDX(0LST)1
(IDX>LST)/0
RIDXLST
RA GCD B
(B=0)/END
(A B)(B (|B | A))
1
END: RA
RSIMPVEC VEC;SIMPL
SIMPLVEC÷GCD/|VEC[|VEC]
(×+/0<SIMPL-SIMPL)/DONTSIMPL
RSIMPL
0
DONTSIMPL:RVEC
RL GAUSSELIM A;ZEROLNS
(0=+/|A[L;])/END
A[L;](×L PIVOT A)×SIMPVEC A[L;]
ZEROLNS(~L=ZEROLNS)/ZEROLNSA
R{A[;]((L PIVOT A)×A[;])-(A[;L]×A[L;])}¨ZEROLNS
END:RA
RGAUSSJORDAN MAT
R{MAT GAUSSELIM MAT}¨MAT
R{MAT[;]SIMPVEC MAT[;]}¨MAT
RMAT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment