Skip to content

Commit 8a3c216

Browse files
committed
Working version of Mgje
1 parent 5740258 commit 8a3c216

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib.ua

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,30 @@ GaussEliminate‼ ↚ ∧(
3737
MDet ← ◌⍣GaussEliminate‼(⍥¯𝄐𝄐/≠)𝄐𝄐× ⊙0⊙1
3838

3939
# Perform Gauss-Jordan elimination
40-
Mgje ← ⍣GaussEliminate‼(|)(⍤"Elimination cannot be completed"0)
40+
Mgje ← +0⍥(
41+
↻₁⍣(⍜⊙⊢÷⟜(-⊞×⊙⊸⊢⊂0÷)°⊂⊸≡⊏⊢)◌⊚≠0⊸⊢
42+
)⊸⧻ ⊏⍏⊸=0
43+
# Mgje ← ⍣GaussEliminate‼(|)(⍤"Elimination cannot be completed"0)
44+
4145
# Matrix Inverse
4246
MInv ← |1 ⌅(⍜⍉(↘÷2⊸⧻) ⍣Mgje(⍤"Matrix has no inverse"0) ˜≡⊂˙⊞=°⊏|MInv)
4347

4448
┌─╴test
4549
⍤⤙≍ 5 ⁅₃ MDet [1_¯3_¯1 1_¯1_¯2 1_0_0]
4650
⍤⤙≍ [0_0_1 ¯0.4_0.2_0.2 0.2_¯0.6_0.4] ⁅₃ MInv [1_¯3_¯1 1_¯1_¯2 1_0_0]
4751
⍤⤙≍ ˙⊞=⇡3 ⁅₃ Mgje [1_¯3_¯1 1_¯1_¯2 1_0_0]
52+
53+
Mgje [1_5_5
54+
4_5_¯10]
55+
⍤⤙≍ [1_0_¯5
56+
0_1_2]
57+
58+
⁅₉ Mgje [0_0_2_¯4_¯5
59+
0_1_¯1_1_3
60+
0_6_0_¯6_5]
61+
⍤⤙≍ [0_1_0_¯1_0
62+
0_0_1_¯2_0
63+
0_0_0_0_1]
4864
└─╴
4965

5066
MSquarify ↚ ⍜△[.√⊢]

0 commit comments

Comments
 (0)