SharedMeatAxe
1.0
|
These function are used for calculations with tensor products.
Data Structures | |
struct | TkData_t |
Tensor condensation state. More... | |
Functions | |
int | MatrixToVector (const Matrix_t *mat, Matrix_t *vecs, int n) |
Convert matrix to vector. More... | |
Matrix_t * | MatTensor (const Matrix_t *m1, const Matrix_t *m2) |
Tensor Product. More... | |
Matrix_t * | TensorMap (Matrix_t *vec, const Matrix_t *a, const Matrix_t *b) |
Map Under Tensor Product. More... | |
int | TK_ReadInfo (TkData_t *tki, const char *name) |
Read a .tki file. More... | |
int | TK_WriteInfo (TkData_t *tki, const char *name) |
Write a .tki file. More... | |
Matrix_t * | VectorToMatrix (Matrix_t *vecs, int n, int noc) |
Convert vector to matrix. More... | |
Convert matrix to vector.
This function converts a matrix into a row vector by concatenating the rows of the matrix. If mat is a r by c matrix, the resulting vector has rc entries. Instead of allocating a new buffer for the result, MatToVec() expects a pointer to a matrix, vecs, and puts the vector into the n-th row of this matrix. Of course, vecs must be over the smae field as mat, have rc columns and at least n+1 rows.
mat | Matrix to convert. |
vecs | Destination of the vector. |
n | Row number where the vector is stored. |
Tensor Product.
This function calculates the (Kronecker) tensor product m1⊗m2. Both matrices must be over the same field.
m1 | Pointer to the first matrix. |
m2 | Pointer to the second matrix. |
Map Under Tensor Product.
This function applies the tensor product of two matrices to one or more vectors. The same calculation could be done with MatMul() and MatTensor(), but this function is usually faster and uses less memory, because it does not calculate the full tensor product of a⊗b.
vec | Vectors to map. |
a | Left matrix. |
b | Right matrix. |
int TK_ReadInfo | ( | TkData_t * | tki, |
const char * | name | ||
) |
int TK_WriteInfo | ( | TkData_t * | tki, |
const char * | name | ||
) |
Convert vector to matrix.
This function converts a vector with m=rc entries into a r by c matrix by filling the matrix from top to bottom and left to right with the entries of the vector. The vector is taken as the n-th row of vecs. A new matrix is allocated and returned. noc is the number of columns of the result, which must be a divisor of the number of columns of vecs.
vecs | List of vectors. |
n | Number of the vector to convert. |
noc | Desired number of columns. |