Convenience functions

+lake

Accepts

Rounding mode, one of ?(%n %u %d %z).

Produces

Specialized version of ++la core.

Source

++  lake
  |=  [inrnd=rounding-mode]
  %*(. la rnd inrnd)
::

Discussion

Lagoon operators are accessed through the ++la container core. This is a door which supplies necessary mathematical details for the implementation (which may be ignored for certain types).

For instance, by default ++la implements round-to-zero IEEE 754 behavior, much as the ++rs etc. doors in vanilla Hoon. This may be overridden using the ++lake gate:

(lake %u)       :: resolve to round-upwards behavior

+print

Pretty-print an array.

Accepts

A $ray.

Produces

A $tank %slog (as side effect) and ~.

Source


+slog

Utility function to print an array.

Accepts

A $ray.

Produces

A $tank %slog (as side effect) and ~.

Source


+to-tank

Convert a $ray to a $tank.

Accepts

A list of data, a shape as a list of dimensions, and the scalar type as a $kind.

Produces

A tank.

Source


+get-term

Utility function to get the term tag associated with a $ray's metadata type.

Accepts

A $meta of the target shape and parameters.

Produces

A %slog-compatible tag as a term.

Source


+squeeze

Convert a noun into a typed list.

Accepts

See source for parameter details.

Produces

See source for return type details.

Source


+submatrix

Produce a submatrix from a $ray using slice notation.

Accepts

A $slice and a $ray.

Produces

A $ray.

Source


+product

Produce the cartesian product of two lists.

Accepts

A pair of lists.

Produces

The cartesian product as a list of pairs.

Source


+gather

Utility function to gather indices for submatrix extraction.

Accepts

A (list (list (list @))).

Produces

A (list (list @))

Source


+get-item

Get item at index from a $ray.

Accepts

A $ray and target index as a list of multi-dimensional indices. Crashes if index is out of bounds.

Produces

A @ux.

Source


+set-item

Set item at index in a $ray.

Accepts

A $ray, target index as a list of multi-dimensional indices, and the value to set.

Produces

A $ray.

Source


+get-row

Get row at index from a $ray.

Accepts

A $ray and target index as a single-entry list of multi-dimensional indices.

Produces

A $ray of dimension n−1n-1.

Source


+set-row

Set row at index in a $ray.

Accepts

A $ray, target index as a list of multi-dimensional indices, and the row to set.

Produces

A $ray.

Source


+get-col

Get column at index from a $ray.

Accepts

A $ray and target index as a single-entry list of multi-dimensional indices.

Produces

A $ray of dimension n−1n-1.

Source


+set-col

Set column at index in a $ray.

Accepts

A $ray, target index as a list of multi-dimensional indices, and the column to set.

Produces

A $ray.

Source


+get-bloq-offset

Utility function to get the bloq offset of an n-dimensional index.

Accepts

A $ray and target index as a list of multi-dimensional indices.

Produces

A $bloq offset @.

Source


+get-item-number

Utility function to convert an n-dimensional index to a scalar index.

Accepts

A shape as a list of dimensions and a scalar index as a list of multi-dimensional indices.

Produces

A scalar index @.

Source


+strides

Return the stride in each dimension: row, col, layer, etc.

Accepts

A $meta of the target shape and parameters.

Produces

A (list @).

Source

Discussion

The stride is reported in units of bits.


+get-dim

Utility function to convert a scalar index to an n-dimensional index.

Accepts

A shape as a list of dimensions and a scalar index.

Produces

The nn-dimensional index as a (list @).

Source


+get-item-index

Utility function to get the item index from a multi-dimensional index.

Accepts

A shape as a list of dimensions and a scalar index.

Produces

An index @.

Source


+ravel

Utility function to flatten a $ray into a list of atoms.

Accepts

A $ray.

Produces

A (list @).

Source


+en-ray

Convert a $baum to a $ray.

Accepts

A $baum (or unwrapped $ray).

Produces

A $ray.

Source


+de-ray

Utility function to convert a $ray to a $baum.

Accepts

A $ray.

Produces

A $baum (or unwrapped $ray).

Source


+rip

Utility function to recursively rip a bite into a list of atoms.

Accepts

A target $bite and an atom to rip .b.

Produces

A (list @).

Source


+check

Check if a $ray is valid according to its metadata.

Accepts

A $ray.

Produces

A $flag.

Source


+get-item-baum

Utility function to get an item from a $baum at a multi-dimensional index.

Accepts

Parameters as specified in source.

Produces

An item as raw @.

Source


+fill

Fill a $ray with a scalar value.

Accepts

A target $meta and a value to fill the array with.

Produces

A $ray.

Source


+spac

Utility function to add a pinned 0x1 MSB to an in-flight $ray's data to preserve leading zeros. For internal library use only.

Accepts

A $ray.

Produces

A $ray.

Source


+unspac

Utility function to remove the pinned 0x1 MSB from an in-flight $ray's data. For internal library use only.

Accepts

A $ray.

Produces

An in-flight $ray.

Source


+scalar-to-ray

Convert a scalar value to an $n$-dimensional $ray.

Accepts

A $meta of the target shape and parameters, and the single value as an atom .data.

Produces

A $ray.

Source


+change

Utility function to change the type of a $ray's metadata.

Accepts

Parameters as specified in source

Produces

A $ray.

Source

Last updated