MeatAxe: Tensor Products

MeatAxe 2.4

- Main Page
- Related Pages
- Modules
- Data Structures

Data Structures | Functions
Tensor Products

## Detailed Description

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.
Matrix_t * | MatTensor (const Matrix_t *m1, const Matrix_t *m2)
| Tensor Product.
Matrix_t * | TensorMap (Matrix_t *vec, const Matrix_t *a, const Matrix_t *b)
| Map Under Tensor Product.
int | TK_ReadInfo (TkData_t *tki, const char *name)
| Read a .tki file.
int | TK_WriteInfo (TkData_t *tki, const char *name)
| Write a .tki file.
Matrix_t * | VectorToMatrix (Matrix_t *vecs, int n, int noc)
| Convert vector to matrix.

## Function Documentation

int MatrixToVector | ( | const Matrix_t * | mat,
|  | Matrix_t * | vecs,
|  | int | n
| ) |  |

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.

See also:
  VectorToMatrix

Parameters:

  mat | Matrix to convert.
  vecs | Destination of the vector.
  n | Row number where the vector is stored.

Returns:
  0 on success, -1 on error.

Matrix_t* MatTensor | ( | const Matrix_t * | m1,
|  | const Matrix_t * | m2
| ) |  |

Tensor Product.

This function calculates the (Kronecker) tensor product m1⊗m2. Both matrices must be over the same field.

Parameters:

  m1 | Pointer to the first matrix.
  m2 | Pointer to the second matrix.

Returns:
  The tensor product of m1 and m2, or 0 on error.

Matrix_t* TensorMap | ( | Matrix_t * | vec,
|  | const Matrix_t * | a,
|  | const Matrix_t * | b
| ) |  |

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.

See also:
  VectorToMatrix() MatrixToVector()

Parameters:

  vec | Vectors to map.
  a | Left matrix.
  b | Right matrix.

Returns:
  Image of vec under a⊗b, or 0 on error.

int TK_ReadInfo | ( | TkData_t * | tki,
|  | const char * | name
| ) |  |

Read a .tki file.

This function reads the contents of a .tki file and puts the data into a TkData_t structure.

Parameters:

  tki | Pointer to a TkData_t structure where the data is stored.
  name | File name without ".tki" extension (which is appended automatically).

Returns:
  0 on success, -1 on error.

int TK_WriteInfo | ( | TkData_t * | tki,
|  | const char * | name
| ) |  |

Write a .tki file.

This function writes the contents of a TkData_t structure into a file.

Parameters:

  tki | Pointer to a TkData_t structure.
  name | File name without ".tki" extension (which is appended automatically).

Returns:
  0 o success, -1 on error.

Matrix_t* VectorToMatrix | ( | Matrix_t * | vecs,
|  | int | n,
|  | int | noc
| ) |  |

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.

See also:
  MatrixToVector

Parameters:

  vecs | List of vectors.
  n | Number of the vector to convert.
  noc | Desired number of columns.

Returns:
  0 on success, -1 on error.