Current Status
-
/lib/mathis distributed via the%yarddesk. -
We are preparing a release of Lagoon
%realwith SoftBLAS-powered jets for release with Urbit 410K. -
We are preparing a release of Saloon
%realwithout jets for release with Urbit 409K. -
We are working on an implementation of tinygrad for Maroon.
-
some notion of cursor in an array would be really helpful
We envision four libraries and associated jet code living in this repository:
/lib/mathoffers basic special function support for floating-point atoms.- Lagoon (Linear AlGebra in hOON) offers BLAS-like operations (like NumPy's pure matrix operations).
- Saloon (Scientific ALgorithms in hOON) offers transcendental functions (like NumPy's transcendental functions, optimizers, etc.).
- Maroon (MAchine LeaRning in hOON) offers machine learning algorithms, starting with tinygrad.
%realIEEE 754 float (currently supported)%cplxIEEE 754 float/BLAS packed complex (planned)%uintunsigned integers (currently supported)%int2signed twos-complement integers (planned)%sintsigned ZigZag integers (planned)%unum→ subdivide into one of:%postposits (32-bit or 16-bit) (planned)%valdvalids (32-bit or 16-bit) (planned)
%fixpfixed-precision (planned)
> `@ub`(add:fixed 0b100.0001.0000 [8 8] 0b101.0001.0000 [8 8])
0b1001.0010.0000
> `@ub`(sub:fixed 0b100.0001.0000 [8 8] 0b101.0001.0000 [8 8])
0b1.1111.1111.0000.0000
> `[@ub ^]`(mul:fixed 0b100.0001.0000 [8 8] 0b101.0001.0000 [8 8])
[0b1.0100.1001.0001.0000.0000 17 16]
> `[@ub ^]`(div:fixed 0b100.0001.0000 [8 8] 0b101.0001.0000 [8 8])
[0b0 17 16]
> `[@ub ^]`(div:fixed 0b1.0100.0001.0000 [8 8] 0b101.0001.0000 [8 8])
[0b11 17 16]
The 410 K release candidate for Lagoon provides %real-valued array operations equivalent to @rh, @rs, @rd, and @rq operations in vanilla Hoon. (Other types have been removed for this release but will be re/introduced in a subsequent release.) The following arms are provided:
++print++slog++to-tank++get-term++squeeze++submatrix++product++gather++get-item++set-item++get-row++set-row++get-col++set-col++get-bloq-offset++get-item-number++strides++get-dim++get-item-index++ravel++en-ray++de-ray++get-item-baum++fill++spac(helper function)++unspac(helper function)++scalar-to-ray++eye++zeros++ones++iota++magic++range++linspace++urge++scale++max++argmax++min++argmin++cumsum++prod++reshape++stack++hstack++vstack++transpose++diag++trace++dot++mmul++abs++add-scalar++sub-scalar++mul-scalar++div-scalar++mod-scalar++add++sub++mul++div++mod++pow-n++gth(note boolean)++gte(note boolean)++lth(note boolean)++lte(note boolean)++mpow-n++is-close++any(note boolean)++all(note boolean)++fun-scalar(helper function)++trans-scalar(helper function)++el-wise-op(helper function)++bin-op(helper function)
The Hoon release is available in urbit/numerics, branch sigilante/reals-only. The Hoon release consists of the following files:
/sur/lagoonfor data types necessary to use Lagoon./lib/lagoonfor operations./tests/lib/lagoonfor various array operation behavior tests.
A PR is at #6971.
The Vere release is available in urbit/vere, branch sigilante/lagoon-jets. The Vere release contains jets for 28 arms. These have been tested for correctness against the reference Hoon results.
A PR is at #638.
Points for discussion:
- Currently we ship Lagoon as
/lib/lagoonand jet into thef/hexcore intree.c. Since that generally deals with Zuse-level arms, is it advisable to introduce another levelg/hepfor/libjets? /sur/lagoonstill lists other types in+$kind, but these are commented out for the time being.
Nonobvious points to note:
- The comparison gates for Lagoon flip back to boolean rather than loobean results. Furthermore, they result in numerical ones (e.g.
0x3f80.0000for@rs) rather than simple0x1s. This is because we want sparse matrices to remain sparse when we eventually support them, and because we want multiplication times the result of a logical operation to set or clear fields appropriately without needing to change thekind. (No solution appears to be completely satisfactory.) ++submatrixand++stackare not jetted yet. These are both dicey jets to get right due to multiple offsets. Fortunately, once we have them correct they should work for allkinds since they only depend onbloqsize notkind.- The rounding mode for
%realmay be set for the core using the++lakegate. This returns a copy of the Lagoon++lacore with rounding mode changed to one of?(%n %u %d %z).
> (cumsum:(lake:la %u) (en-ray:(lake:la %u) [~[7 1] 5 %real ~] ~[.1 .5 .-5 .2 .3 .-20 .-1]))
[meta=[shape=~[1 1] bloq=5 kind=%real fxp=~] data=0x1.c170.0000]to make:
- logspace
- tensordot
- bitwise ops
- eq, ne
- isnan, isinf (±)
- pad
- pow, exp, log, whatever not in Saloon
THREE POSSIBILITIES:
-
Logical loobean (0 true, terrible for sparse matrices)
-
Logical boolean (1 true, normal but out of step w/ Hoon)
-
Numeric boolean (0x3f80.0000 for 1, etc.)
Here we follow the third option in u3qf_la_gth_real() etc.