(basis-unit i)
(basis-unit n i)
Returns a basis sequence of n
0s, with 1
in the i
th 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.
(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.
(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.
(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.
(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.
(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*]].
(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]].
(down-of-ups? s)
Returns true if s
is a down
structure containing all up
structures of the same size, false otherwise.
Returns true if `s` is a `down` structure containing all `up` structures of the same size, false otherwise.
(down? s)
Returns true
if s
is a down
structure, false otherwise.
Returns `true` if `s` is a `down` structure, false otherwise.
(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)`.
(kronecker i j)
Returns 1
if i
== j
, 0
otherwise.
Returns `1` if `i`== `j`, `0` otherwise.
(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.
(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: ```clojure (= (literal-down 'x 3) (down 'x_0 'x_1 'x_2)) ```
(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: ```clojure (= (literal-up 'x 3) (up 'x↑0 'x↑1 'x↑2)) ```
(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`
(map-chain f s)
Returns a new structure of equivalent shape to s
, generated by applying f
to three arguments:
For example:
(dorun (map-chain println (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: ```clojure (dorun (map-chain println (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] ```
(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.
(opposite s)
(opposite s xs)
For a non-Structure
s
, the single-arity case acts as [[identity]]. For
a Structure
, returns an identical structure with its orientation
reversed (up becomes down, down becomes up).
NOTE that a vector is interpreted as an up
structure, so:
(opposite [1 2 3]) ;;=> (down 1 2 3)
The two-arity case returns a new Structure
of opposite orientation to s
with the contents of the sequence xs
.
For a non-[[Structure]] `s`, the single-arity case acts as [[identity]]. For a [[Structure]], returns an identical structure with its orientation reversed (up becomes down, down becomes up). NOTE that a vector is interpreted as an `up` structure, so: (opposite [1 2 3]) ;;=> (down 1 2 3) The two-arity case returns a new [[Structure]] of opposite orientation to `s` with the contents of the sequence `xs`.
(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.
(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`.
(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.
(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.
(structure->prototype name s)
Accepts
name
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.
(structure->vector s)
Return the structure s
in unoriented vector form.
Return the structure `s` in unoriented vector form.
(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.)
(sumr f & structures)
Given some function f
and any number of isomorphic structures
,
returns the sum of the results of applying f
to each associated set of
entries in each structure
.
Given some function `f` and any number of isomorphic `structures`, returns the sum of the results of applying `f` to each associated set of entries in each `structure`.
(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.
(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.'
(two-down? s)
Returns true if s
is a down
structure containing all down
structures of the same size, false otherwise.
Returns true if `s` is a `down` structure containing all `down` structures of the same size, false otherwise.
(two-tensor-info s)
Given an up
or down
structure containing structures of the same
orientation and size (a 2 tensor), returns a dictionary with keys:
{:outer-orientation <::up or ::down>
:inner-orientation <::up or ::down>
:outer-size <int>
:inner-size <int>}
If `s` is /not/ a valid tensor, returns nil.
Given an `up` or `down` structure containing structures of the same orientation and size (a 2 tensor), returns a dictionary with keys: ```clj {:outer-orientation <::up or ::down> :inner-orientation <::up or ::down> :outer-size <int> :inner-size <int>} If `s` is /not/ a valid tensor, returns nil. ```
(two-tensor? s)
Returns true if s
is an up
or down
structure containing all up
or
down
structures of internally-matching orientation and size, false
otherwise.
Returns true if `s` is an `up` or `down` structure containing all `up` or `down` structures of internally-matching orientation and size, false otherwise.
(two-up? s)
Returns true if s
is an up
structure containing all up
structures of the same size, false otherwise.
Returns true if `s` is an `up` structure containing all `up` structures of the same size, false otherwise.
(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.
(unflatten values struct)
(unflatten constructor values struct)
Given:
values
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`.
(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*]].
(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]].
(up-of-downs? s)
Returns true if s
is an up
structure containing all down
structures of the same size, false otherwise.
Returns true if `s` is an `up` structure containing all `down` structures of the same size, false otherwise.
(up? s)
Returns true
if s
is an up
structure, false otherwise.
Returns `true` if `s` is an `up` structure, false otherwise.
(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.
(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.
(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.
(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/*]].
(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/*]].
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close