Tensor class. [詳細]
#include <tensor.h>
Public 型 | |
typedef V | value_type |
data type of tensor's elements | |
typedef A | allocator |
allocator type of mist containers | |
typedef data_type::size_type | size_type |
unsigned integer type used for contener size or data index (same as size_t) |
Public メソッド | |
const size_type | mode () const |
return the number of tensor's modes | |
const size_type | rank (const size_type &mode) const |
return a mode rank of the tensor for each mode | |
const size_type | size () const |
return the number of tensor's elements | |
value_type & | operator[] (const size_type &i) |
return the i-th element of the tensor without depending on the number of modes | |
const value_type & | operator[] (const size_type &i) const |
return the i-th element of the tensor without depending on the number of modes | |
matrix_type | unfold (const size_type &mode) const |
return a matrix form of the tensor obtained by unfolding it for each mode | |
template<typename MV , typename MA > | |
tensor< M, V, A > | x (const size_type &mode, const matrix< MV, MA > &mat) const |
return a mode-product between the tensor and a matrix | |
template<typename TV , typename TA > | |
bool | operator== (const tensor< M, TV, TA > &t) const |
equivalence operator | |
template<typename TV , typename TA > | |
bool | operator!= (const tensor< M, TV, TA > &t) const |
non-equivalence operator | |
template<typename TV , typename TA > | |
const tensor< M, V, A > & | operator+= (const tensor< M, TV, TA > &t) |
addision assignment operator to add a tensor to the tensor | |
template<typename TV , typename TA > | |
const tensor< M, V, A > & | operator-= (const tensor< M, TV, TA > &t) |
subtraction assignment operator to subtract a tensor from the tensor | |
template<typename VV > | |
const tensor< M, V, A > & | operator*= (const VV &v) |
multiplication assignment operator to multiply the tensor by a value | |
template<typename VV > | |
const tensor< M, V, A > & | operator/= (const VV &v) |
division assignment operator to divide the tensor by a value | |
tensor () | |
construct a tensor (default constructer) | |
void | resize (const size_type &rank1, const size_type &rank2) |
resize the 2nd order tensor | |
value_type & | operator() (const size_type &i1, const size_type &i2) |
return a element of the 2nd order tensor for each pair of indices | |
const value_type & | operator() (const size_type &i1, const size_type &i2) const |
return a element of the 2nd order tensor for each pair of indices | |
template<typename MV , typename MA > | |
void | hosvd (tensor< M, V, A > &z, matrix< MV, MA > &u1, matrix< MV, MA > &u2) const |
apply higher order singular value decomposition (HOSVD) to the 2nd order tensor | |
template<typename AV , typename AA > | |
tensor (const size_type &rank1, const size_type &rank2, const array< AV, AA > &data) | |
construct a 2nd order tensor | |
template<typename AV , typename AA > | |
tensor (const array2< AV, AA > &img) | |
construct a 2nd order tensor from an image | |
template<typename MV , typename MA > | |
tensor (const matrix< MV, MA > &mat) | |
construct a 2nd order tensor from a matrix | |
tensor (const size_type &rank1, const size_type &rank2) | |
construct a 2nd order tensor | |
void | resize (const size_type &rank1, const size_type &rank2, const size_type &rank3) |
resize the 3rd order tensor | |
value_type & | operator() (const size_type &i1, const size_type &i2, const size_type &i3) |
return a element of the 3rd order tensor for each set of indices | |
const value_type & | operator() (const size_type &i1, const size_type &i2, const size_type &i3) const |
return a element of the 3rd order tensor for each set of indices | |
template<typename MV , typename MA > | |
void | hosvd (tensor< M, V, A > &z, matrix< MV, MA > &u1, matrix< MV, MA > &u2, matrix< MV, MA > &u3) const |
apply higher order singular value decomposition (HOSVD) to the 3rd order tensor | |
template<typename AV , typename AA > | |
tensor (const size_type &rank1, const size_type &rank2, const size_type &rank3, const array< AV, AA > &data) | |
construct a 3rd order tensor | |
tensor (const size_type &rank1, const size_type &rank2, const size_type &rank3) | |
construct a 3rd order tensor | |
template<typename TV , typename TA , typename AA > | |
tensor (const array< tensor< 2, TV, TA >, AA > &ts) | |
construct a 3rd order tensor from an array of 2nd order tensors | |
void | resize (const size_type &rank1, const size_type &rank2, const size_type &rank3, const size_type &rank4) |
resize the 4th order tensor | |
value_type & | operator() (const size_type &i1, const size_type &i2, const size_type &i3, const size_type &i4) |
return a element of the 4th order tensor for each set of indices | |
const value_type & | operator() (const size_type &i1, const size_type &i2, const size_type &i3, const size_type &i4) const |
return a element of the 4th order tensor for each set of indices | |
template<typename MV , typename MA > | |
void | hosvd (tensor< M, V, A > &z, matrix< MV, MA > &u1, matrix< MV, MA > &u2, matrix< MV, MA > &u3, matrix< MV, MA > &u4) const |
apply higher order singular value decomposition (HOSVD) to the 4th order tensor | |
template<typename AV , typename AA > | |
tensor (const size_type &rank1, const size_type &rank2, const size_type &rank3, const size_type &rank4, const array< AV, AA > &data) | |
construct a 4th order tensor | |
tensor (const size_type &rank1, const size_type &rank2, const size_type &rank3, const size_type &rank4) | |
construct a 4th order tensor | |
template<typename TV , typename TA , typename AA > | |
tensor (const array< tensor< 3, TV, TA >, AA > &ts) | |
construct a 4th order tensor from an array of 3rd order tensors | |
void | resize (const size_type &rank1, const size_type &rank2, const size_type &rank3, const size_type &rank4, const size_type &rank5) |
resize the 5th order tensor | |
tensor< M, V, A > & | operator() (const size_type &i1, const size_type &i2, const size_type &i3, const size_type &i4, const size_type &i5) |
return a element of the 5th order tensor for each set of indices | |
const tensor< M, V, A > & | operator() (const size_type &i1, const size_type &i2, const size_type &i3, const size_type &i4, const size_type &i5) const |
return a element of the 5th order tensor for each set of indices | |
template<typename MV , typename MA > | |
void | hosvd (tensor< M, V, A > &z, matrix< MV, MA > &u1, matrix< MV, MA > &u2, matrix< MV, MA > &u3, matrix< MV, MA > &u4, matrix< MV, MA > &u5) const |
apply higher order singular value decomposition (HOSVD) to the 5th order tensor | |
template<typename AV , typename AA > | |
tensor (const size_type &rank1, const size_type &rank2, const size_type &rank3, const size_type &rank4, const size_type &rank5, const array< AV, AA > &data) | |
construct a 5th order tensor | |
tensor (const size_type &rank1, const size_type &rank2, const size_type &rank3, const size_type &rank4, const size_type &rank5) | |
construct a 5th order tensor | |
template<typename TV , typename TA , typename AA > | |
tensor (const array< tensor< 4, TV, TA >, AA > &ts) | |
construct a 5th order tensor from an array of 4th order tensors |
Tensor class.
An N-th order tensor T has mode-ranks I_1, I_2, ..., I_N and belongs to the product space R^{I_1 I_2 ... I_N}.
M | integer parameter to assign tensor's order (number of modes) |
V | data type parameter used as tensor's element type |
A | allocator type paramerter used by mist containers |
|
inline |
construct a 2nd order tensor
[in] | rank1 | 1st mode rank |
[in] | rank2 | 2nd mode rank |
[in] | data | data to assign initial values to elements of the tensor |
|
inline |
construct a 2nd order tensor from an image
Width and height of the image are assigned to the 1st and 2nd mode ranks respectively.
[in] | img | image to assign initial values to elements of the tensor |
|
inline |
construct a 2nd order tensor from a matrix
Numbers of rows and cols of the matrix are assigned to the 1st and 2nd mode ranks respectively.
[in] | mat | matrix to assign initial values to elements of the tensor |
|
inline |
construct a 2nd order tensor
[in] | rank1 | 1st mode rank |
[in] | rank2 | 2nd mode rank |
|
inline |
construct a 3rd order tensor
[in] | rank1 | 1st mode rank |
[in] | rank2 | 2nd mode rank |
[in] | rank3 | 3rd mode rank |
[in] | data | data to assign initial values to elements of the tensor |
|
inline |
construct a 3rd order tensor
[in] | rank1 | 1st mode rank |
[in] | rank2 | 2nd mode rank |
[in] | rank3 | 3rd mode rank |
|
inline |
construct a 3rd order tensor from an array of 2nd order tensors
[in] | ts | array of 2nd order tensors |
|
inline |
construct a 4th order tensor
[in] | rank1 | 1st mode rank |
[in] | rank2 | 2nd mode rank |
[in] | rank3 | 3rd mode rank |
[in] | rank4 | 4th mode rank |
[in] | data | data to assign initial values to elements of the tensor |
|
inline |
construct a 4th order tensor
[in] | rank1 | 1st mode rank |
[in] | rank2 | 2nd mode rank |
[in] | rank3 | 3rd mode rank |
[in] | rank4 | 4th mode rank |
|
inline |
construct a 4th order tensor from an array of 3rd order tensors
[in] | ts | array of 3rd order tensors |
|
inline |
construct a 5th order tensor
[in] | rank1 | 1st mode rank |
[in] | rank2 | 2nd mode rank |
[in] | rank3 | 3rd mode rank |
[in] | rank4 | 4th mode rank |
[in] | rank5 | 5th mode rank |
[in] | data | data to assign initial values to elements of the tensor |
|
inline |
construct a 5th order tensor
[in] | rank1 | 1st mode rank |
[in] | rank2 | 2nd mode rank |
[in] | rank3 | 3rd mode rank |
[in] | rank4 | 4th mode rank |
[in] | rank5 | 5th mode rank |
|
inline |
construct a 5th order tensor from an array of 4th order tensors
[in] | ts | array of 4th order tensors |
|
inline |
apply higher order singular value decomposition (HOSVD) to the 2nd order tensor
HOSVD decomposes a 2nd order tensor T as T = Z U_1 U_2. Here U_1 and U_2 are unitary matrices and a 2nd order tensor Z is called as a core tensor. Using 1-mode-unfolding matrix of T, this is described like SVD of a matrix as T_1 = U1 S U2^t Here S is a singular value matrix.
[in,out] | z | core tensor of the tensor |
[in,out] | u1 | unitary matrix corresponding to the 1st mode |
[in,out] | u2 | unitary matrix corresponding to the 2nd mode |
参照先 mist::matrix< T, Allocator >::dagger(), と mist::svd().
参照元 mist::hosvd().
|
inline |
apply higher order singular value decomposition (HOSVD) to the 3rd order tensor
HOSVD decomposes a 3rd order tensor T as T = Z U_1 U_2 U_3. Here U_1, U_2, and U_3 are unitary matrices and a 3rd order tensor Z is called as a core tensor.
[in,out] | z | core tensor of the tensor |
[in,out] | u1 | unitary matrix corresponding to the 1st mode |
[in,out] | u2 | unitary matrix corresponding to the 2nd mode |
[in,out] | u3 | unitary matrix corresponding to the 3rd mode |
|
inline |
apply higher order singular value decomposition (HOSVD) to the 4th order tensor
HOSVD decomposes a 4th order tensor T as T = Z U_1 U_2 U_3 U_4. Here U_1, U_2, U_3, and U_4 are unitary matrices and a 4th order tensor Z is called as a core tensor.
[in,out] | z | core tensor of the tensor |
[in,out] | u1 | unitary matrix corresponding to the 1st mode |
[in,out] | u2 | unitary matrix corresponding to the 2nd mode |
[in,out] | u3 | unitary matrix corresponding to the 3rd mode |
[in,out] | u4 | unitary matrix corresponding to the 4th mode |
|
inline |
apply higher order singular value decomposition (HOSVD) to the 5th order tensor
HOSVD decomposes a 5th order tensor T as T = Z U_1 U_2 U_3 U_4 U_5. Here U_1, U_2, U_3, U_4, and U_5 are unitary matrices and a 5th order tensor Z is called as a core tensor.
[in,out] | z | core tensor of the tensor |
[in,out] | u1 | unitary matrix corresponding to the 1st mode |
[in,out] | u2 | unitary matrix corresponding to the 2nd mode |
[in,out] | u3 | unitary matrix corresponding to the 3rd mode |
[in,out] | u4 | unitary matrix corresponding to the 4th mode |
[in,out] | u5 | unitary matrix corresponding to the 5th mode |
|
inline |
return a element of the 2nd order tensor for each pair of indices
[in] | i1 | index for the 1st mode |
[in] | i2 | index for the 2nd mode |
|
inline |
return a element of the 2nd order tensor for each pair of indices
[in] | i1 | index for the 1st mode |
[in] | i2 | index for the 2nd mode |
|
inline |
return a element of the 3rd order tensor for each set of indices
[in] | i1 | index of the 1st mode |
[in] | i2 | index of the 2nd mode |
[in] | i3 | index of the 3rd mode |
|
inline |
return a element of the 3rd order tensor for each set of indices
[in] | i1 | index of the 1st mode |
[in] | i2 | index of the 2nd mode |
[in] | i3 | index of the 3rd mode |
|
inline |
return a element of the 4th order tensor for each set of indices
[in] | i1 | index of the 1st mode |
[in] | i2 | index of the 2nd mode |
[in] | i3 | index of the 3rd mode |
[in] | i4 | index of the 4th mode |
|
inline |
return a element of the 4th order tensor for each set of indices
[in] | i1 | index of the 1st mode |
[in] | i2 | index of the 2nd mode |
[in] | i3 | index of the 3rd mode |
[in] | i4 | index of the 4th mode |
|
inline |
return a element of the 5th order tensor for each set of indices
[in] | i1 | index of the 1st mode |
[in] | i2 | index of the 2nd mode |
[in] | i3 | index of the 3rd mode |
[in] | i4 | index of the 4th mode |
[in] | i5 | index of the 5th mode |
|
inline |
return a element of the 5th order tensor for each set of indices
[in] | i1 | index of the 1st mode |
[in] | i2 | index of the 2nd mode |
[in] | i3 | index of the 3rd mode |
[in] | i4 | index of the 4th mode |
[in] | i5 | index of the 5th mode |
|
inline |
return the i-th element of the tensor without depending on the number of modes
[in] | i | index to specify tensor's element |
|
inline |
return the i-th element of the tensor without depending on the number of modes
[in] | i | index to specify tensor's element |
|
inline |
return a mode rank of the tensor for each mode
[in] | mode | mode value to obtain the corresponding tensor's rank |
|
inline |
resize the 2nd order tensor
[in] | rank1 | 1st mode rank after this operation |
[in] | rank2 | 2nd mode rank after this operation |
|
inline |
resize the 3rd order tensor
[in] | rank1 | 1st mode rank after this operation |
[in] | rank2 | 2nd mode rank after this operation |
[in] | rank3 | 3rd mode rank after this operation |
|
inline |
resize the 4th order tensor
[in] | rank1 | 1st mode rank after this operation |
[in] | rank2 | 2nd mode rank after this operation |
[in] | rank3 | 3rd mode rank after this operation |
[in] | rank4 | 4th mode rank after this operation |
|
inline |
resize the 5th order tensor
[in] | rank1 | 1st mode rank after this operation |
[in] | rank2 | 2nd mode rank after this operation |
[in] | rank3 | 3rd mode rank after this operation |
[in] | rank4 | 4th mode rank after this operation |
[in] | rank5 | 5th mode rank after this operation |
|
inline |
return a matrix form of the tensor obtained by unfolding it for each mode
For a tensor T in R^{I_1 I_2 ... I_N}, n-mode-unfolding means constructing a matrix T_n from T so that T_n consits of I_n dimensional column vectors and the number of vectors is I_1 I_2 ... I_{n-1} I_{n+1} ... I_N.
[in] | mode | mode value to unfold the tensor |
|
inline |
return a mode-product between the tensor and a matrix
An n-mode-product between a tensor T and a matrix M is denoted as T M. Using n-mode-unfolding matrix T_n, elements of the mode-product are calculated by M T_n.
[in] | mode | mode value to determine the direction of multiplication |