# CartesianTensor(minix, dim, R)ΒΆ

CartesianTensor(minix, dim, `R`) provides Cartesian tensors with components belonging to a commutative ring `R`. These tensors can have any number of indices. Each index takes values from `minix` to `minix + dim - 1`.

0: %
1: %

*: (%, %) -> %

`s*t` is the inner product of the tensors `s` and `t` which contracts the last index of `s` with the first index of `t`, i.e. `t*s = contract(t, rank t, s, 1)` `t*s = sum(k=1..N, t[i1, .., iN, k]*s[k, j1, .., jM])` This is compatible with the use of `M*v` to denote the matrix-vector inner product.

*: (%, Integer) -> %
*: (%, R) -> %

*: (Integer, %) -> %
*: (R, %) -> %

+: (%, %) -> %
-: % -> %
-: (%, %) -> %
=: (%, %) -> Boolean

from BasicType

~=: (%, %) -> Boolean

from BasicType

coerce: % -> OutputForm
coerce: DirectProduct(dim, R) -> %

`coerce(v)` views a vector as a rank 1 tensor.

coerce: List % -> %

`coerce([t_1, ..., t_dim])` allows tensors to be constructed using lists.

coerce: List R -> %

`coerce([r_1, ..., r_dim])` allows tensors to be constructed using lists.

coerce: R -> %

from CoercibleFrom R

coerce: SquareMatrix(dim, R) -> %

`coerce(m)` views a matrix as a rank 2 tensor.

contract: (%, Integer, %, Integer) -> %

`contract(t, i, s, j)` is the inner product of tenors `s` and `t` which sums along the `k1``-`th index of `t` and the `k2``-`th index of `s`. For example, if `r = contract(s, 2, t, 1)` for rank 3 tensors rank 3 tensors `s` and `t`, then `r` is the rank 4 `(= 3 + 3 - 2)` tensor given by `r(i, j, k, l) = sum(h=1..dim, s(i, h, j)*t(h, k, l))`.

contract: (%, Integer, Integer) -> %

`contract(t, i, j)` is the contraction of tensor `t` which sums along the `i``-`th and `j``-`th indices. For example, if `r = contract(t, 1, 3)` for a rank 4 tensor `t`, then `r` is the rank 2 `(= 4 - 2)` tensor given by `r(i, j) = sum(h=1..dim, t(h, i, h, j))`.

degree: % -> NonNegativeInteger
elt: % -> R

`elt(t)` gives the component of a rank 0 tensor.

elt: (%, Integer) -> R

`elt(t, i)` gives a component of a rank 1 tensor.

elt: (%, Integer, Integer) -> R

`elt(t, i, j)` gives a component of a rank 2 tensor.

elt: (%, Integer, Integer, Integer) -> R

`elt(t, i, j, k)` gives a component of a rank 3 tensor.

elt: (%, Integer, Integer, Integer, Integer) -> R

`elt(t, i, j, k, l)` gives a component of a rank 4 tensor.

elt: (%, List Integer) -> R

`elt(t, [i1, ..., iN])` gives a component of a rank `N` tensor.

kroneckerDelta: () -> %

`kroneckerDelta()` is the rank 2 tensor defined by `kroneckerDelta()(i, j)` `= 1 if i = j` `= 0 if i \~= j`

latex: % -> String

from SetCategory

leviCivitaSymbol: () -> %

`leviCivitaSymbol()` is the rank `dim` tensor defined by `leviCivitaSymbol()(i1, ...idim) = +1/0/-1` if `i1, ..., idim` is an even/is nota /is an odd permutation of `minix, ..., minix+dim-1`.

product: (%, %) -> %

`product(s, t)` is the outer product of the tensors `s` and `t`. For example, if `r = product(s, t)` for rank 2 tensors `s` and `t`, then `r` is a rank 4 tensor given by `r(i, j, k, l) = s(i, j)*t(k, l)`.

rank: % -> NonNegativeInteger

`rank(t)` returns the tensorial rank of `t` (that is, the number of indices). This is the same as the graded module degree.

ravel: % -> List R

`ravel(t)` produces a list of components from a tensor such that `unravel(ravel(t)) = t`.

reindex: (%, List Integer) -> %

`reindex(t, [i1, ..., idim])` permutes the indices of `t`. For example, if `r = reindex(t, [4, 1, 2, 3])` for a rank 4 tensor `t`, then `r` is the rank for tensor given by `r(i, j, k, l) = t(l, i, j, k)`.

retract: % -> R

from RetractableTo R

retractIfCan: % -> Union(R, failed)

from RetractableTo R

sample: () -> %

`sample()` returns an object of type %.

transpose: % -> %

`transpose(t)` exchanges the first and last indices of `t`. For example, if `r = transpose(t)` for a rank 4 tensor `t`, then `r` is the rank 4 tensor given by `r(i, j, k, l) = t(l, j, k, i)`.

transpose: (%, Integer, Integer) -> %

`transpose(t, i, j)` exchanges the `i``-`th and `j``-`th indices of `t`. For example, if `r = transpose(t, 2, 3)` for a rank 4 tensor `t`, then `r` is the rank 4 tensor given by `r(i, j, k, l) = t(i, k, j, l)`.

unravel: List R -> %

`unravel(t)` produces a tensor from a list of components such that `unravel(ravel(t)) = t`.

BasicType

SetCategory