@@ -28,13 +28,13 @@ Stdev ← √Var
2828# ? SwappedRows Pivot
2929GaussEliminate‼ ↚ ∧(
3030 ⊢⍖⊸⌵⍜⊙↙×0⟜⊡⤚⊸⊙⍉
31- ⍜⊏⇌ ⊃⊙⊙∘^0 ⊟⤙⊙⊙∘ ⊙(⊃⋅⊙∘^1 ⍤. ≥ε⊸⌵) ⟜⊡
32- ⊸⍜⊡(÷⊸⊡:)⊸:
33- ⍜(°⊂↻|𝄐⌞ -˜⊸⊞×⊙(⊡⤚˜⊙⍉))⊸:
31+ ⍜⊏⇌ ⊃⊙⊙∘^0 ⊟⤙⊙⊙∘ ⊙(⊃⋅⊙∘^1 ˙⍤ ≥ε⊸⌵) ⟜⊡
32+ ⊸⍜⊡(÷˜⊸⊡)⊸˜∘
33+ ⍜(°⊂↻|˜⊙ -˜⊸⊞×⊙(⊡⤚˜⊙⍉))⊸˜∘
3434)°⊏
3535
3636# Matrix Determinant
37- MDet ← ◌⍣GaussEliminate‼(⍥¯𝄐𝄐 /≠)𝄐𝄐 × ⊙0⊙1
37+ MDet ← ◌⍣GaussEliminate‼(⍥¯˜⌞⋅˜⋅ /≠)˜⌞⋅˜⋅ × ⊙0⊙1
3838
3939# Perform Gauss-Jordan elimination
4040Mgje ← ⊏⍏˜⨂1>1e-12⊸⌵ ⍥(
@@ -72,14 +72,14 @@ MInv ← |1 ⌅(⍜⍉(↘÷2⊸⧻) ⍣Mgje(⍤"Matrix has no inverse"0) ˜≡
7272 # 0_0_0_0_1]
7373└─╴
7474
75- MSquarify ↚ ⍜△[. √⊢]
75+ MSquarify ↚ ⍜△[⟜∘ √⊢]
7676# Matrix Cofactors
77- MCof ← ⍥¯⊞≠. ◿2°⊏MSquarify≡(MDet MSquarify≡⊡⊙¤⊚¬⊞↥°⊟)⊙¤⬚0≡₀°⊚⊚⊸=.
77+ MCof ← ⍥¯˙⊞≠ ◿2°⊏MSquarify≡(MDet MSquarify≡⊡⊙¤⊚¬⊞↥°⊟)⊙¤⬚0≡₀°⊚⊚⊸⊸=
7878
7979# Dot product
8080Dot ← /+×
8181# Cross product
82- Cross ← ↻2-∩(×↻2)◡:
82+ Cross ← ↻2-∩(×↻2)◡˜∘
8383# Matrix product
8484#
8585# Computes AB
@@ -92,13 +92,13 @@ Mmp ← |2 ⌅(⊞Dot⊙⍉|◌⍜≡⊂Mgje)
9292Mvp ← |2 ⌅(Dot⍉|♭◌⍜≡⊂Mgje)
9393# Matrix power
9494# ? P M
95- Mpow ← ◌⍥⟜Mmp⊙(: ˙⊞=°⊏)
95+ Mpow ← ◌⍥⟜Mmp⊙(˜∘ ˙⊞=°⊏)
9696# TODO: Change to this if it comes to work with negative powers
9797# Mpow ← ⍥⟜Mmp⊙(˙⊞=°⊏)
9898
9999┌─╴test
100100 ⍤⤙≍ [3_7 ¯6_2] ⌝Mmp [1_0 0_1] [3_7 ¯6_2]
101- ⍤⤙≍ [1_0 0_1] ⁅ ⌝Mmp . [1_2 3_4]
101+ ⍤⤙≍ [1_0 0_1] ⁅ ˙ ⌝Mmp [1_2 3_4]
102102 ⍤⤙≍ 3 ⁅ MDet [5_6 2_3]
103103
104104 ⍤⤙≍ [¯8 5 ¯3 2 ¯1 1 0 1 1 2 3 5 8] ≡(⊢♭Mpow) ⍜-⇡¯7 6 ¤ [1_1 1_0]
@@ -141,9 +141,9 @@ Qqp ← ⍉⊕/+-1⌵⊙×⟜±QqpMask⊞×∩°⍉
141141# To use rotation quaternions created by `RQuat` to rotate 3D
142142# vectors, see `QRot`.
143143# ? θ U
144- RQuat ← ⍜⊙°⍉⊂𝄐⌞ ×°∠÷2
144+ RQuat ← ⍜⊙°⍉⊂˜⊙ ×°∠÷2
145145# Quaternion rotation implementation
146- QRotImpl ↚ ⍜⊙°⍉↘1 Qqp Qqp ⟜⍜∩°⍉(⬚0↙¯4: ⍜↘¯ 1)
146+ QRotImpl ↚ ⍜⊙°⍉↘1 Qqp Qqp ⟜⍜∩°⍉(˜ ⬚0↙₋₄ ⍜↘¯ 1)
147147# Rotate a 3D vector array using a quaternion array.
148148#
149149# To create rotation quaternions to use with `QRot`, see `RQuat`.
@@ -164,7 +164,7 @@ QRot ← ⌅(QRotImpl|QRotImpl⍜(↘1°⍉)¯)
164164
165165┌─╴test
166166 ⍤⤙≍ [¯48_6_6_12 ¯120_24_60_48] Qqp [1_2_3_4 2_4_6_8] [1_3_5_7 5_6_7_8]
167- ⍤⤙≍ [¯2_3_0 ¯3_1_2] ⁅ QRot ¤: [3_2_0 1_3_2] RQuat η 0_0_1
167+ ⍤⤙≍ [¯2_3_0 ¯3_1_2] ⁅ QRot ¤ ⊙ [3_2_0 1_3_2] RQuat η 0_0_1
168168└─╴
169169
170170# -- Number theory --
@@ -196,15 +196,15 @@ Gamma ← (
196196 ¯2.7405717035683877e-8
197197 4.048694881756761e-9
198198 ]
199- /+÷⍜⊢⋅1≡+⊙¤⊙:
199+ /+÷⍜⊢⋅1≡+⊙˜¤
200200 )
201201 ××× √τ ₑ¯ ⤙ⁿ ⤙+ 8 # g
202202)
203203
204204┌─╴test
205205 ⍤⤙(<1e¯10 ⌵-) √π Gamma 1/2
206206 ⍤⤙(<1e¯10 ⌵-) 24 Gamma 5
207- ⍤⤙(<1e¯10 ⌵-) ℂ¯0.09161772311294437 0.024480267015440246 Gamma ℂ. ¯√2
207+ ⍤⤙(<1e¯10 ⌵-) ℂ¯0.09161772311294437 0.024480267015440246 Gamma ˙ℂ ¯√2
208208└─╴
209209
210210# Greatest common divisor
@@ -300,10 +300,10 @@ Divisors ← ◌°▽⊂⊃÷⇌ ▽=0⊸⊃◿÷ +1⇡⌊⊸√
300300
301301# Error function
302302Erf ← (
303- ˜÷1+1×0.3275911 ⟜(˜ⁿe¯×. ) ⌵⟜±
304- : [1.061405429 ¯1.453152027 1.421413741
303+ ˜÷1+1×0.3275911 ⟜(˜ⁿe¯˙× ) ⌵⟜±
304+ ⊙ [1.061405429 ¯1.453152027 1.421413741
305305 ¯0.284496736 0.254829592
306- ]: 0
306+ ]⊙ 0
307307 ׬×∧(×⊙+)¤
308308)
309309
@@ -343,17 +343,17 @@ DistRand ← ˜⍜♭≡(⊢⊚>)⊓¤gen⍜♭\+÷/+⊸♭
343343#
344344# Converts uniformly distributed pairs of input values to
345345# standard normally distributed pairs of output values
346- BoxMuller ← ∩×⤙⊓°∠∘×τ: √ׯ2°ₑ¬
346+ BoxMuller ← ∩×⤙⊓°∠∘×τ˜∘ √ׯ2°ₑ¬
347347
348348# Generate a 2 dimensional square Gaussian kernel
349349# ? Size StandardDeviation
350- Gaussian ← ÷/+⊸♭ₑ¯÷2˙ט÷⌵⊞ℂ. -÷2-1⟜⇡
350+ Gaussian ← ÷/+⊸♭ₑ¯÷2˙ט÷⌵˙⊞ℂ -÷2-1⟜⇡
351351
352352# Binomial distribution
353353#
354354# Probability that n Bernoulli trials each with success probability p will amount to X successes
355355# ? p n X
356- BinomPmf ← ××⊃(≡₀⧅>|𝄐 ⁿ|ⁿ⊓-¬) ⤚⋅:
356+ BinomPmf ← ××⊃(≡₀⧅>|˜⋅ ⁿ|ⁿ⊓-¬) ⤚⋅˜∘
357357# Cumulative binomial distribution
358358#
359359# Probability that n Bernoulli trials each with success probability p will amount to X or fewer successes
@@ -366,7 +366,7 @@ BinomCmf ← /+BinomPmf⊓∩¤(⇡+1)
366366#
367367# Probability of X failures before the first success of repeated trials with success probability p
368368# ? p X
369- GeomPmf ← טⁿ¬⟜:
369+ GeomPmf ← ×⟜( ˜ⁿ¬)
370370# Cumulative geometric distribution
371371#
372372# Probability of X or fewer failures before the first success of repeated trials with success probability p
@@ -403,7 +403,7 @@ NormalCdf ← ÷2+1Erf÷×√2⊙-
403403#
404404# Outputs complex-typed numbers only if the roots are complex
405405# ? A B C
406- Quad ← ⍥R⌵↥₀: ⊟⊃-+⊙: √⟜±˜-˙×⟜: ℂ₀¯÷₂∩⌞÷
406+ Quad ← ⍥R⌵˜↥₀ ⊟⊃-+⊙˜∘ √⟜±˜-˙×⟜˜∘ ℂ₀¯÷₂∩⌞÷
407407
408408┌─╴test
409409 ⍤⤙≍ [1 2] Quad 1 ¯3 2
@@ -416,7 +416,7 @@ PSet ← ⍚▽⋯⇡˜ⁿ2⧻⟜¤
416416
417417# Rank-polymorphic fast fourier transform
418418# Deprecated! `fft` has been updated to be rank-polymorphic by default. Use that instead.
419- RPFFT ← ⌅(⍥(⍉fft)⧻△. |⍥°(⍉fft)⧻△. )
419+ RPFFT ← ⌅(⍥(⍉fft)⧻⊸△ |⍥°(⍉fft)⧻⊸△ )
420420
421421# Rank-polymorphic convolution using fast fourier transform
422422┌─╴FFTConvolve
0 commit comments