Liking cljdoc? Tell your friends :D

sicmutils.structure


*allow-incompatible-multiplication*clj/s

source

basis-unitclj/s

(basis-unit i)
(basis-unit n i)

Returns a basis sequence of n 0s, with 1 in the ith position.

If n is not supplied returns an infinite sequence.

Returns a basis sequence of `n` 0s, with `1` in the `i`th position.

If `n` is not supplied returns an infinite sequence.
sourceraw docstring

compatible-shapeclj/s

(compatible-shape s)

Returns a structure compatible for multiplication with s down to a scalar, with the slots filled with gensyms.

Returns a structure compatible for multiplication with `s` down to a scalar,
with the slots filled with gensyms.
sourceraw docstring

compatible-zeroclj/s

(compatible-zero s)

Returns a structure compatible for multiplication with s down to 0.

Returns a structure compatible for multiplication with `s` down to 0.
sourceraw docstring

componentclj/s

(component & indices)

Given an access chain (a sequence of indices), return a function that accepts a structure and returns the element at the specified access chain.

Given an access chain (a sequence of indices), return a function that accepts a
structure and returns the element at the specified access chain.
sourceraw docstring

dimensionclj/s

(dimension s)

If s is sequential, returns its dimension, ie, the total number of non-sequential entries in the structure. Else, returns 1.

If `s` is sequential, returns its dimension, ie, the total number of
non-sequential entries in the structure. Else, returns 1.
sourceraw docstring

downclj/s

(down & xs)

Construct a down (covariant) tuple from the arguments. Variadic version of down*.

Construct a down (covariant) tuple from the arguments. Variadic version
of [[down*]].
sourceraw docstring

down*clj/s

(down* xs)

Construct a down (covariant) tuple from the supplied sequence. For a variadic version, see down.

Construct a down (covariant) tuple from the supplied sequence. For a
variadic version, see [[down]].
sourceraw docstring

down?clj/s

(down? s)

Returns true if s is a down structure, false otherwise.

Returns `true` if `s` is a down structure, false otherwise.
sourceraw docstring

generateclj/s

(generate dimension orientation f)

Generate a structure with the given orientation whose elements are

(f i)

where i ranges from [0..dimension).

Generate a structure with the given `orientation` whose elements are

(f i)

where i ranges from [0..`dimension`).
sourceraw docstring

kroneckerclj/s

(kronecker i j)

Returns 1 if i== j, 0 otherwise.

Returns `1` if `i`== `j`, `0` otherwise.
sourceraw docstring

literalclj/s

(literal sym size orientation)

Generates a structure of the specified orientation and dimension size populated by symbolic entries, each prefixed by the supplied symbol sym.

For example:

(= (literal 'x 3 ::s/up) (up 'x↑0 'x↑1 'x↑2))

See literal-up and literal-down for constructors with baked in orientations.

Generates a structure of the specified `orientation` and dimension `size`
populated by symbolic entries, each prefixed by the supplied symbol `sym`.

For example:

(= (literal 'x 3 ::s/up)
   (up 'x↑0 'x↑1 'x↑2))

See [[literal-up]] and [[literal-down]] for constructors with baked in
orientations.
sourceraw docstring

literal-downclj/s

(literal-down sym size)

Generates a down structure of dimension size populated by symbolic entries, each prefixed by the supplied symbol sym.

For example:

(= (literal-down 'x 3) (down 'x_0 'x_1 'x_2))

Generates a `down` structure of dimension `size` populated by symbolic entries,
each prefixed by the supplied symbol `sym`.

For example:

(= (literal-down 'x 3)
   (down 'x_0 'x_1 'x_2))
sourceraw docstring

literal-upclj/s

(literal-up sym size)

Generates an up structure of dimension size populated by symbolic entries, each prefixed by the supplied symbol sym.

For example:

(= (literal-up 'x 3) (up 'x↑0 'x↑1 'x↑2))

Generates an `up` structure of dimension `size` populated by symbolic entries,
each prefixed by the supplied symbol `sym`.

For example:

(= (literal-up 'x 3)
   (up 'x↑0 'x↑1 'x↑2))
sourceraw docstring

makeclj/s

(make orientation xs)

Generate a structure with the supplied orientation, given some sequence xs

Generate a structure with the supplied orientation, given some sequence `xs`
sourceraw docstring

map-chainclj/s

(map-chain f s)

Returns a new structure of equivalent shape to s, generated by applying f to three arguments:

  • the entry in the structure
  • a vector of its 'access chain', ie, the path you'd pass to [[clojure.core/get-in]] to access the entry
  • a vector of orientations associated with each index in the access chain

For example:

(doall (map-chain print (s/down (s/up 1 2) (s/up 3 4))))

1 [0 0] [:s/down :s/up] 2 [0 1] [:s/down :s/up] 3 [1 0] [:s/down :s/up] 4 [1 1] [:s/down :s/up]

Returns a new structure of equivalent shape to `s`, generated by applying `f`
to three arguments:

- the entry in the structure
- a vector of its 'access chain', ie, the path you'd pass
  to [[clojure.core/get-in]] to access the entry
- a vector of orientations associated with each index in the access chain

For example:

(doall (map-chain print (s/down (s/up 1 2) (s/up 3 4))))

1 [0 0] [:s/down :s/up]
2 [0 1] [:s/down :s/up]
3 [1 0] [:s/down :s/up]
4 [1 1] [:s/down :s/up]
sourceraw docstring

maprclj/s

(mapr f & structures)

Return a structure with the same shape as s but with f applied to each primitive (that is, not structural) component.

Return a structure with the same shape as s but with f applied to each
primitive (that is, not structural) component.
sourceraw docstring

oppositeclj/s

(opposite s xs)

Returns a structure containing xs with the orientation opposite to s.

Returns a structure containing `xs` with the orientation opposite to `s`.
sourceraw docstring

opposite-orientationclj/s

source

orientationclj/s

(orientation s)

Returns the orientation of s, either ::up or ::down. Defaults to ::up, even for non-structures.

Returns the orientation of s, either `::up` or `::down`. Defaults to `::up`,
even for non-structures.
sourceraw docstring

sameclj/s

(same s xs)

Returns a structure containing xs with the same orientation as s.

Returns a structure containing `xs` with the same orientation as `s`.
sourceraw docstring

same-orientation?clj/s

(same-orientation? s t)

Returns true if the supplied structures have the same orientation, false otherwise.

Returns true if the supplied structures have the same orientation, false
otherwise.
sourceraw docstring

Structurecljs

source

structure->access-chainsclj/s

(structure->access-chains s)

Return a structure of the same shape as s whose elements are access chains corresponding to position of each element (i.e., the sequence of indices needed to address that element via [[get-in]]).

Each access chain has the sequence of orientations (::s/up, ::s/down) associated with each step attached to it as metadata, under an :orientations key. Use this if the orientation of the indices matters.

Return a structure of the same shape as `s` whose elements are access chains
corresponding to position of each element (i.e., the sequence of indices
needed to address that element via [[get-in]]).

Each access chain has the sequence of orientations (`::s/up`, `::s/down`)
associated with each step attached to it as metadata, under an `:orientations`
key. Use this if the orientation of the indices matters.
sourceraw docstring

structure->prototypeclj/s

(structure->prototype name s)

Accepts

  • some symbolic (or string) name
  • a structure s

and returns a new structure of identical shape, with symbolic entries like 'x↑0_1 that show their access chain with proper orientations for each step.

Accepts

- some symbolic (or string) `name`
- a structure `s`

and returns a new structure of identical shape, with symbolic entries like
`'x↑0_1` that show their access chain with proper orientations for each step.
sourceraw docstring

structure->vectorclj/s

(structure->vector s)

Return the structure in unoriented vector form.

Return the structure in unoriented vector form.
sourceraw docstring

structure?clj/s

(structure? s)

Returns true if s is a structure, false otherwise. (Vectors are treated as up structures.)

Returns `true` if `s` is a structure, false otherwise. (Vectors are treated as
up structures.)
sourceraw docstring

transposeclj/s

(transpose s)

Returns a structure with the same shape as s, with all orientations inverted.

Returns a structure with the same shape as `s`, with all orientations
inverted.
sourceraw docstring

transpose-outerclj/s

(transpose-outer s)

Returns a new structure with the same orientation as the first element of s, filled with elements of the same orientation as s.

Each element is generating by taking the first element of each entry in s, the the second, etc... In that sense this is similar to a traditional matrix transpose.

A comment from scmutils states:

'used only in symmetrize-Christoffel in src/calculus/covariant-derivative.scm.'

Returns a new structure with the same orientation as the first element of `s`,
filled with elements of the same orientation as `s`.

Each element is generating by taking the first element of each entry in `s`,
the the second, etc... In that sense this is similar to a traditional matrix
transpose.

A comment from `scmutils` states:

'used only in symmetrize-Christoffel in
src/calculus/covariant-derivative.scm.'
sourceraw docstring

typical-objectclj/s

(typical-object s)

Returns a structure of the same shape and orientation as s, generated by substituting gensymmed symbols in for each entry.

Returns a structure of the same shape and orientation as `s`, generated by
substituting gensymmed symbols in for each entry.
sourceraw docstring

unflattenclj/s

(unflatten values struct)
(unflatten constructor values struct)

Given:

  • a sequence of values
  • a model struct

Returns a new structure generated by unpacking values into a structure with the same shape as struct.

Given:

- a sequence of `values`
- a model `struct`

Returns a new structure generated by unpacking `values` into a structure with
the same shape as `struct`.
sourceraw docstring

upclj/s

(up & xs)

Construct an up (contravariant) tuple from the arguments.

Variadic version of up*.

Construct an up (contravariant) tuple from the arguments.

Variadic version of [[up*]].
sourceraw docstring

up*clj/s

(up* xs)

Construct an up (contravariant) tuple from the supplied sequence. For a variadic version, see up.

Construct an up (contravariant) tuple from the supplied sequence. For a
variadic version, see [[up]].
sourceraw docstring

up?clj/s

(up? s)

Returns true if s is an up structure, false otherwise.

Returns `true` if `s` is an up structure, false otherwise.
sourceraw docstring

valid-orientation?clj/s

(valid-orientation? o)

Returns true if the supplied orientation lives in the set of allowed orientations, false otherwise.

Returns true if the supplied orientation lives in the set of allowed
orientations, false otherwise.
sourceraw docstring

vector->downclj/s

(vector->down v)

Form a down-tuple from a vector.

NOTE that this is an alias of down* that is more restrictive, in that it only accepts a vector. Use down* if you'd like to pass an arbitrary sequence. (If you pass a vector to down*) it will be just as efficient.

Form a down-tuple from a vector.

NOTE that this is an alias of [[down*]] that is more restrictive, in that it
only accepts a vector. Use [[down*]] if you'd like to pass an arbitrary
sequence. (If you pass a vector to [[down*]]) it will be just as efficient.
sourceraw docstring

vector->upclj/s

(vector->up v)

Form an up-tuple from a vector.

NOTE that this is an alias of up* that is more restrictive, in that it only accepts a vector. Use up* if you'd like to pass an arbitrary sequence. (If you pass a vector to up*) it will be just as efficient.

Form an up-tuple from a vector.

NOTE that this is an alias of [[up*]] that is more restrictive, in that it
only accepts a vector. Use [[up*]] if you'd like to pass an arbitrary
sequence. (If you pass a vector to [[up*]]) it will be just as efficient.
sourceraw docstring

vector-dot-productclj/s

(vector-dot-product v1 v2)

Returns the (vector) dot product of v1 and v2; this is equivalent to the sum of the pairwise product of each entry.

The arguments must have identical length, and all pairwise entries must be compatible via [[g/*]].

Returns the (vector) dot product of `v1` and `v2`; this is equivalent to the sum
of the pairwise product of each entry.

The arguments must have identical length, and all pairwise entries must be
compatible via [[g/*]].
sourceraw docstring

vector-inner-productclj/s

(vector-inner-product v1 v2)

Returns the (vector) inner product of v1 and v2; this is equivalent to the sum of the pairwise product of each entry.

This is equivalent to vector-dot-product with every element of v1 transformed into its complex conjugate.

The arguments must have identical length, and all pairwise entries must be compatible via [[g/*]].

Returns the (vector) inner product of `v1` and `v2`; this is equivalent to the
sum of the pairwise product of each entry.

  This is equivalent to [[vector-dot-product]] with every element of `v1`
transformed into its complex conjugate.

The arguments must have identical length, and all pairwise entries must be
compatible via [[g/*]].
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close