Public 型 | Public メソッド
クラス テンプレート mist::tensor< M, V, A >

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_typeoperator[] (const size_type &i)
 return the i-th element of the tensor without depending on the number of modes
const value_typeoperator[] (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_typeoperator() (const size_type &i1, const size_type &i2)
 return a element of the 2nd order tensor for each pair of indices
const value_typeoperator() (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_typeoperator() (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_typeoperator() (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_typeoperator() (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_typeoperator() (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

説明

template<int M, typename V, typename A = ::std::allocator< V >>
class mist::tensor< M, V, A >

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}.

引数
Minteger parameter to assign tensor's order (number of modes)
Vdata type parameter used as tensor's element type
Aallocator type paramerter used by mist containers

コンストラクタとデストラクタ

template<int M, typename V, typename A = ::std::allocator< V >>
template<typename AV , typename AA >
mist::tensor< M, V, A >::tensor ( const size_type rank1,
const size_type rank2,
const array< AV, AA > &  data 
)
inline

construct a 2nd order tensor

引数
[in]rank11st mode rank
[in]rank22nd mode rank
[in]datadata to assign initial values to elements of the tensor
template<int M, typename V, typename A = ::std::allocator< V >>
template<typename AV , typename AA >
mist::tensor< M, V, A >::tensor ( const array2< AV, AA > &  img)
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]imgimage to assign initial values to elements of the tensor
template<int M, typename V, typename A = ::std::allocator< V >>
template<typename MV , typename MA >
mist::tensor< M, V, A >::tensor ( const matrix< MV, MA > &  mat)
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]matmatrix to assign initial values to elements of the tensor
template<int M, typename V, typename A = ::std::allocator< V >>
mist::tensor< M, V, A >::tensor ( const size_type rank1,
const size_type rank2 
)
inline

construct a 2nd order tensor

引数
[in]rank11st mode rank
[in]rank22nd mode rank
template<int M, typename V, typename A = ::std::allocator< V >>
template<typename AV , typename AA >
mist::tensor< M, V, A >::tensor ( const size_type rank1,
const size_type rank2,
const size_type rank3,
const array< AV, AA > &  data 
)
inline

construct a 3rd order tensor

引数
[in]rank11st mode rank
[in]rank22nd mode rank
[in]rank33rd mode rank
[in]datadata to assign initial values to elements of the tensor
template<int M, typename V, typename A = ::std::allocator< V >>
mist::tensor< M, V, A >::tensor ( const size_type rank1,
const size_type rank2,
const size_type rank3 
)
inline

construct a 3rd order tensor

引数
[in]rank11st mode rank
[in]rank22nd mode rank
[in]rank33rd mode rank
template<int M, typename V, typename A = ::std::allocator< V >>
template<typename TV , typename TA , typename AA >
mist::tensor< M, V, A >::tensor ( const array< tensor< 2, TV, TA >, AA > &  ts)
inline

construct a 3rd order tensor from an array of 2nd order tensors

引数
[in]tsarray of 2nd order tensors
template<int M, typename V, typename A = ::std::allocator< V >>
template<typename AV , typename AA >
mist::tensor< M, V, A >::tensor ( const size_type rank1,
const size_type rank2,
const size_type rank3,
const size_type rank4,
const array< AV, AA > &  data 
)
inline

construct a 4th order tensor

引数
[in]rank11st mode rank
[in]rank22nd mode rank
[in]rank33rd mode rank
[in]rank44th mode rank
[in]datadata to assign initial values to elements of the tensor
template<int M, typename V, typename A = ::std::allocator< V >>
mist::tensor< M, V, A >::tensor ( const size_type rank1,
const size_type rank2,
const size_type rank3,
const size_type rank4 
)
inline

construct a 4th order tensor

引数
[in]rank11st mode rank
[in]rank22nd mode rank
[in]rank33rd mode rank
[in]rank44th mode rank
template<int M, typename V, typename A = ::std::allocator< V >>
template<typename TV , typename TA , typename AA >
mist::tensor< M, V, A >::tensor ( const array< tensor< 3, TV, TA >, AA > &  ts)
inline

construct a 4th order tensor from an array of 3rd order tensors

引数
[in]tsarray of 3rd order tensors
template<int M, typename V, typename A = ::std::allocator< V >>
template<typename AV , typename AA >
mist::tensor< M, V, A >::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 
)
inline

construct a 5th order tensor

引数
[in]rank11st mode rank
[in]rank22nd mode rank
[in]rank33rd mode rank
[in]rank44th mode rank
[in]rank55th mode rank
[in]datadata to assign initial values to elements of the tensor
template<int M, typename V, typename A = ::std::allocator< V >>
mist::tensor< M, V, A >::tensor ( const size_type rank1,
const size_type rank2,
const size_type rank3,
const size_type rank4,
const size_type rank5 
)
inline

construct a 5th order tensor

引数
[in]rank11st mode rank
[in]rank22nd mode rank
[in]rank33rd mode rank
[in]rank44th mode rank
[in]rank55th mode rank
template<int M, typename V, typename A = ::std::allocator< V >>
template<typename TV , typename TA , typename AA >
mist::tensor< M, V, A >::tensor ( const array< tensor< 4, TV, TA >, AA > &  ts)
inline

construct a 5th order tensor from an array of 4th order tensors

引数
[in]tsarray of 4th order tensors

関数

template<int M, typename V, typename A = ::std::allocator< V >>
template<typename MV , typename MA >
void mist::tensor< M, V, A >::hosvd ( tensor< M, V, A > &  z,
matrix< MV, MA > &  u1,
matrix< MV, MA > &  u2 
) const
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]zcore tensor of the tensor
[in,out]u1unitary matrix corresponding to the 1st mode
[in,out]u2unitary matrix corresponding to the 2nd mode

参照先 mist::matrix< T, Allocator >::dagger(), と mist::svd().

参照元 mist::hosvd().

template<int M, typename V, typename A = ::std::allocator< V >>
template<typename MV , typename MA >
void mist::tensor< M, V, A >::hosvd ( tensor< M, V, A > &  z,
matrix< MV, MA > &  u1,
matrix< MV, MA > &  u2,
matrix< MV, MA > &  u3 
) const
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]zcore tensor of the tensor
[in,out]u1unitary matrix corresponding to the 1st mode
[in,out]u2unitary matrix corresponding to the 2nd mode
[in,out]u3unitary matrix corresponding to the 3rd mode

参照先 mist::matrix< T, Allocator >::dagger(), と mist::svd().

template<int M, typename V, typename A = ::std::allocator< V >>
template<typename MV , typename MA >
void mist::tensor< M, V, A >::hosvd ( tensor< M, V, A > &  z,
matrix< MV, MA > &  u1,
matrix< MV, MA > &  u2,
matrix< MV, MA > &  u3,
matrix< MV, MA > &  u4 
) const
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]zcore tensor of the tensor
[in,out]u1unitary matrix corresponding to the 1st mode
[in,out]u2unitary matrix corresponding to the 2nd mode
[in,out]u3unitary matrix corresponding to the 3rd mode
[in,out]u4unitary matrix corresponding to the 4th mode

参照先 mist::matrix< T, Allocator >::dagger(), と mist::svd().

template<int M, typename V, typename A = ::std::allocator< V >>
template<typename MV , typename MA >
void mist::tensor< M, V, A >::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
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]zcore tensor of the tensor
[in,out]u1unitary matrix corresponding to the 1st mode
[in,out]u2unitary matrix corresponding to the 2nd mode
[in,out]u3unitary matrix corresponding to the 3rd mode
[in,out]u4unitary matrix corresponding to the 4th mode
[in,out]u5unitary matrix corresponding to the 5th mode

参照先 mist::matrix< T, Allocator >::dagger(), と mist::svd().

template<int M, typename V, typename A = ::std::allocator< V >>
value_type& mist::tensor< M, V, A >::operator() ( const size_type i1,
const size_type i2 
)
inline

return a element of the 2nd order tensor for each pair of indices

引数
[in]i1index for the 1st mode
[in]i2index for the 2nd mode
戻り値
the element corresponding to the indices
template<int M, typename V, typename A = ::std::allocator< V >>
const value_type& mist::tensor< M, V, A >::operator() ( const size_type i1,
const size_type i2 
) const
inline

return a element of the 2nd order tensor for each pair of indices

引数
[in]i1index for the 1st mode
[in]i2index for the 2nd mode
戻り値
the element corresponding to the indices
template<int M, typename V, typename A = ::std::allocator< V >>
value_type& mist::tensor< M, V, A >::operator() ( const size_type i1,
const size_type i2,
const size_type i3 
)
inline

return a element of the 3rd order tensor for each set of indices

引数
[in]i1index of the 1st mode
[in]i2index of the 2nd mode
[in]i3index of the 3rd mode
戻り値
the element corresponding to the indices
template<int M, typename V, typename A = ::std::allocator< V >>
const value_type& mist::tensor< M, V, A >::operator() ( const size_type i1,
const size_type i2,
const size_type i3 
) const
inline

return a element of the 3rd order tensor for each set of indices

引数
[in]i1index of the 1st mode
[in]i2index of the 2nd mode
[in]i3index of the 3rd mode
戻り値
the element corresponding to the indices
template<int M, typename V, typename A = ::std::allocator< V >>
value_type& mist::tensor< M, V, A >::operator() ( const size_type i1,
const size_type i2,
const size_type i3,
const size_type i4 
)
inline

return a element of the 4th order tensor for each set of indices

引数
[in]i1index of the 1st mode
[in]i2index of the 2nd mode
[in]i3index of the 3rd mode
[in]i4index of the 4th mode
戻り値
the element corresponding to the indices
template<int M, typename V, typename A = ::std::allocator< V >>
const value_type& mist::tensor< M, V, A >::operator() ( const size_type i1,
const size_type i2,
const size_type i3,
const size_type i4 
) const
inline

return a element of the 4th order tensor for each set of indices

引数
[in]i1index of the 1st mode
[in]i2index of the 2nd mode
[in]i3index of the 3rd mode
[in]i4index of the 4th mode
戻り値
the element corresponding to the indices
template<int M, typename V, typename A = ::std::allocator< V >>
tensor< M, V, A >& mist::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 
)
inline

return a element of the 5th order tensor for each set of indices

引数
[in]i1index of the 1st mode
[in]i2index of the 2nd mode
[in]i3index of the 3rd mode
[in]i4index of the 4th mode
[in]i5index of the 5th mode
戻り値
the element corresponding to the indices
template<int M, typename V, typename A = ::std::allocator< V >>
const tensor< M, V, A >& mist::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
inline

return a element of the 5th order tensor for each set of indices

引数
[in]i1index of the 1st mode
[in]i2index of the 2nd mode
[in]i3index of the 3rd mode
[in]i4index of the 4th mode
[in]i5index of the 5th mode
戻り値
the element corresponding to the indices
template<int M, typename V, typename A = ::std::allocator< V >>
value_type& mist::tensor< M, V, A >::operator[] ( const size_type i)
inline

return the i-th element of the tensor without depending on the number of modes

引数
[in]iindex to specify tensor's element
戻り値
the i-th element of the tensor
template<int M, typename V, typename A = ::std::allocator< V >>
const value_type& mist::tensor< M, V, A >::operator[] ( const size_type i) const
inline

return the i-th element of the tensor without depending on the number of modes

引数
[in]iindex to specify tensor's element
戻り値
the i-th element of the tensor
template<int M, typename V, typename A = ::std::allocator< V >>
const size_type mist::tensor< M, V, A >::rank ( const size_type mode) const
inline

return a mode rank of the tensor for each mode

引数
[in]modemode value to obtain the corresponding tensor's rank
戻り値
the tensor's rank corresponding to the mode
template<int M, typename V, typename A = ::std::allocator< V >>
void mist::tensor< M, V, A >::resize ( const size_type rank1,
const size_type rank2 
)
inline

resize the 2nd order tensor

引数
[in]rank11st mode rank after this operation
[in]rank22nd mode rank after this operation
template<int M, typename V, typename A = ::std::allocator< V >>
void mist::tensor< M, V, A >::resize ( const size_type rank1,
const size_type rank2,
const size_type rank3 
)
inline

resize the 3rd order tensor

引数
[in]rank11st mode rank after this operation
[in]rank22nd mode rank after this operation
[in]rank33rd mode rank after this operation
template<int M, typename V, typename A = ::std::allocator< V >>
void mist::tensor< M, V, A >::resize ( const size_type rank1,
const size_type rank2,
const size_type rank3,
const size_type rank4 
)
inline

resize the 4th order tensor

引数
[in]rank11st mode rank after this operation
[in]rank22nd mode rank after this operation
[in]rank33rd mode rank after this operation
[in]rank44th mode rank after this operation
template<int M, typename V, typename A = ::std::allocator< V >>
void mist::tensor< M, V, A >::resize ( const size_type rank1,
const size_type rank2,
const size_type rank3,
const size_type rank4,
const size_type rank5 
)
inline

resize the 5th order tensor

引数
[in]rank11st mode rank after this operation
[in]rank22nd mode rank after this operation
[in]rank33rd mode rank after this operation
[in]rank44th mode rank after this operation
[in]rank55th mode rank after this operation
template<int M, typename V, typename A = ::std::allocator< V >>
matrix_type mist::tensor< M, V, A >::unfold ( const size_type mode) const
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]modemode value to unfold the tensor
戻り値
the the matrix obtained by unfolding the tensor
template<int M, typename V, typename A = ::std::allocator< V >>
template<typename MV , typename MA >
tensor< M, V, A > mist::tensor< M, V, A >::x ( const size_type mode,
const matrix< MV, MA > &  mat 
) const
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]modemode value to determine the direction of multiplication
戻り値
the mode-product

このクラスの説明は次のファイルから生成されました:

Generated on Wed Nov 12 2014 19:44:29 for MIST by doxygen 1.8.1.2