MeatAxe: Matrix Representations

MeatAxe 2.4

- Main Page
- Related Pages
- Modules
- Data Structures

Data Structures | Functions
Matrix Representations

## Data Structures
class | MatRep_t
| A matrix representation. More...
## Functions
int | MrAddGenerator (MatRep_t *rep, Matrix_t *gen, int flags)
| Add a Matrix to a Representation.
int | MrIsValid (const MatRep_t *rep)
| Check a Matrix Representation.
MatRep_t * | MrAlloc (int ngen, Matrix_t **gen, int flags)
| Create a Matrix Representation.
int | MrFree (MatRep_t *rep)
| Delete a Matrix Representation.
MatRep_t * | MrLoad (const char *basename, int ngen)
| Load a Matrix Representation.
MatRep_t * | MrTransposed (const MatRep_t *rep)
| Transpose a Representation.
int | MrSave (const MatRep_t *rep, const char *basename)
| Save a Matrix Representation.

## Function Documentation

int MrAddGenerator | ( | MatRep_t * | rep,
|  | Matrix_t * | gen,
|  | int | flags
| ) |  |

Add a Matrix to a Representation.

This function adds a generator, i.e., a matrix, to a matrix representation. The matrix must be square. If there are already generators in the represenatation, the new matrix must be over the same field and have the same number of rows. flags may be zero or the special value MR_COPY_GENERATORS. In the latter case, a local copy of the generator is made, and gen can be safely destroyed. Otherwise, only a reference to the matrix is stored in the MatRep_t structure. Consequently, the application must not modify or destroy the matrix after calling MrAddGenerator(). It will be destroyed by MrFree() together with the representation.

Parameters:

  rep | Matrix representation.
  gen | Matrix to add.
  flags | Optional flags (see below).

Returns:
  0 on success, -1 on error.

MatRep_t* MrAlloc | ( | int | ngen,
|  | Matrix_t ** | gen,
|  | int | flags
| ) |  |

Create a Matrix Representation.

This function creates a new matrix representation. Matrices representing the generators must be passed in gen. The matrices in gen must all be square, over the same field, and with the same dimensions. flags may be zero or the special value MR_COPY_GENERATORS. In the latter case, a local copy of the generators is made, and the matrices in |gen| can be safely destroyed. If flags is 0, only references to the matrices are stored in the MatRep_t structure. Consequently, the application must not modify or destroy the matrices after calling MrAlloc(). They will be destroyed automatically when MrFree() is called to destroy the representation.

Parameters:

  ngen | Number of generators in gen.
  gen | List of generators.
  flags | Optional flags (see below).

Returns:
  Pointer to the new matrix representation or 0 on error.

int MrFree | ( | MatRep_t * | rep | ) |

Delete a Matrix Representation.

This function frees a matrix representation which has beed created by MrAlloc(). This implies freeing the internal data buffers as well as the MatRep_t structure itself. Note: Even if the representation was created without MR_COPY_GENERATORS, the matrices that were passed to MrAlloc() are now destroyed. The same applies to matrices added to the representation with MrAddGenerator().

Parameters:

  rep | Pointer to the matrix representation.

Returns:
  0 on success, -1 on error.

int MrIsValid | ( | const MatRep_t * | rep | ) |

Check a Matrix Representation.

This function checks if the argument is a pointer to a valid matrix representation. If the representation is o.k., the function returns 1. Otherwise, an error is signaled and, if the error handler does not terminate the program, the function returns 0.

Parameters:

  rep | Pointer to the matrix representation.

Returns:
  1 if rep points to a valid matrix representation, 0 otherwise.

MatRep_t* MrLoad | ( | const char * | basename,
|  | int | ngen
| ) |  |

Load a Matrix Representation.

This function creates a new matrix representation and reads the generators from files. Each generator ist expected in a different file. The file name is constructed by appending ".1", ".2" etc. to basename or, if basename contains a "%d" placeholder, by replacing the "%d" with "1", "2", etc. For example, the following lines

     m11 = MrLoad("m11",2);
     m11 = MrLoad("m11.%d",2);

are equivalent. In both cases, two matrices are read from "m11.2" and "m11.2", repectively.

Parameters:

  basename | Base file name for generators.
  ngen | Number of generators.

Returns:
  Pointer to the representation, or 0 on error.

int MrSave | ( | const MatRep_t * | rep,
|  | const char * | basename
| ) |  |

Save a Matrix Representation.

This function saves all generators of a matrix representation. Each generator ist written to different file. The file name is constructed by appending ".1", ".2" etc. to basename or, if basename contains a "%d" placeholder, by replacing the "%d" with "1", "2", etc.

Parameters:

  rep | Pointer to the matrix representation.
  basename | Base file name for generators.

Returns:
  0 on success, -1 on error.

MatRep_t* MrTransposed | ( | const MatRep_t * | rep | ) |

Transpose a Representation.

This function transposes a matrix representation. A new representation is created, and the original representation is not changed.

Parameters:

  rep | Matrix representation.

Returns:
  Pointer to the transposed representation, or 0 on error.