Phase 1: /lib/complex + wire %cplx into Lagoon#46
Open
sigilante wants to merge 1 commit into
Open
Conversation
Implements the %cplx design (CPLX-DESIGN.md): complex-number arrays with a SoftBLAS-interleaved atom layout, element-wise ops, and complex linear algebra. /lib/complex (pure Hoon): cs (@cs, two @rs) and cd (@cd, two @rd) doors keyed on rounding mode. Packed atom = real low / imag high, matching SoftBLAS complexN_t. add/sub/mul, div (Smith's algorithm), neg, conj, abs (hypot, real-valued complex), equ/neq (bit equality). No total order (no gth/lth). Lagoon (sur + lib): %cplx in the kind union; bloq 6=cs 7=cd, prec needs no meta.tail. fun-scalar add/sub/mul/div + equ/neq (-> complex one/zero); gth/gte/lth/lte crash (complex unordered). New %conj op (identity on real kinds, so dotc reduces to dot there). trans-scalar %abs/%conj. New ray arms +conj and +dotc (Hermitian inner product, sum conj(a)*b). Bilinear dot, mmul, and cumsum use the generic round-each-step path (no exact complex accumulator). get-term -> @c aura terms; eye/ones constant 1+0i; scale raw-pack; change out of complex refuses (lossy). Tests (all green on ~hex): /tests/lib/complex (4: cs/cd arith, unary, compare), /tests/lib/lagoon-cplx (7: arith, unary, compare, ones, cumsum, dot vs dotc, mmul); %unum (14) and %int2 (5) regressions still pass. Oracle: tools/complex_check.py (NumPy complex64/128). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements Phase 1 of the
%cplxdesign (lagoon/CPLX-DESIGN.md, PR #45):complex-number arrays with a SoftBLAS-interleaved atom layout, element-wise
ops, and complex linear algebra. Unblocks Saloon eigenvalues/eigenvectors.
/lib/complex(pure Hoon)cs(@cs= two@rs) andcd(@cd= two@rd) doors keyed on roundingmode. Packed atom = real low / imag high, matching SoftBLAS
complexN_t(validated on ~hex:
(1+2i)·(3+4i) = -5+10i). Arms:add/sub/mul,div(Smith's algorithm),neg,conj,abs(hypot, returns real-valuedcomplex),
equ/neq(bit equality). No total order — nogth/lth.Lagoon (
sur+lib)%cplxin thekindunion;bloq6=cs7=cd(meta.tailunused).fun-scalar:add/sub/mul/div,equ/neq→ complexone/zero;gth/gte/lth/ltecrash (complex is unordered).%conjop (identity on real kinds, sodotc≡dotthere);trans-scalar%abs/%conj.conjanddotc(Hermitian inner productΣ conj(aᵢ)·bᵢ). Bilineardot,mmul,cumsumuse the genericround-each-step path (no exact complex accumulator).
get-term→@caura terms (%cs/%cd);eye/onesconstant1+0i;scaleraw-pack;changeout of complex refuses (lossy).Tests — all green on ~hex
/tests/lib/complex(4):cs/cdarith, unary, compare./tests/lib/lagoon-cplx(7): arith, unary (abs/conj), compare, ones,cumsum, dot (-18+68i) vs dotc (70-8i), complex mmul.
%unum(14) and%int2(5) still pass.tools/complex_check.py(NumPycomplex64/complex128).Not in scope (per design)
Jets (Phase 2: add
*dotu/cgemm/zgemmto our SoftBLAS); Salooneig(Phase 3);
@ch/@cqwidths;changeinto-complex.🤖 Generated with Claude Code