CMR  1.3.0
Classes | Functions
matrix.h File Reference

Functionality for sparse matrices. More...

#include <cmr/env.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  CMR_SUBMAT
 Row and column indices for a submatrix. More...
 
struct  CMR_DBLMAT
 Row-wise representation of sparse double matrix. More...
 
struct  CMR_INTMAT
 Row-wise representation of sparse int matrix. More...
 
struct  CMR_CHRMAT
 Row-wise representation of sparse char matrix. More...
 

Functions

CMR_EXPORT CMR_ERROR CMRsubmatCreate (CMR *cmr, size_t numRows, size_t numColumns, CMR_SUBMAT **psubmatrix)
 Creates a submatrix of given size. More...
 
CMR_EXPORT CMR_ERROR CMRsubmatCreate1x1 (CMR *cmr, size_t row, size_t column, CMR_SUBMAT **psubmatrix)
 Creates a 1-by-1 submatrix. More...
 
CMR_EXPORT CMR_ERROR CMRsubmatFree (CMR *cmr, CMR_SUBMAT **psubmatrix)
 Frees a submatrix. More...
 
CMR_EXPORT CMR_ERROR CMRsubmatTranspose (CMR_SUBMAT *submatrix)
 Transposes a submatrix. More...
 
CMR_EXPORT CMR_ERROR CMRsubmatSlice (CMR *cmr, CMR_SUBMAT *base, CMR_SUBMAT *input, CMR_SUBMAT **poutput)
 Returns the submatrix input as a submatrix of the base submatrix. More...
 
CMR_EXPORT CMR_ERROR CMRsubmatUnslice (CMR *cmr, CMR_SUBMAT *base, CMR_SUBMAT *input, CMR_SUBMAT **poutput)
 Returns the sub-submatrix input of base as a submatrix of its parent. More...
 
CMR_EXPORT CMR_ERROR CMRsubmatPrint (CMR *cmr, CMR_SUBMAT *submatrix, size_t numRows, size_t numColumns, FILE *stream)
 Writes the submatrix submatrix to the file stream by means of lists of row and column indices. More...
 
CMR_EXPORT CMR_ERROR CMRsubmatWriteToFile (CMR *cmr, CMR_SUBMAT *submatrix, size_t numRows, size_t numColumns, const char *fileName)
 Writes the submatrix submatrix to the file fileName by means of lists of row and column indices. More...
 
CMR_EXPORT CMR_ERROR CMRsubmatReadFromStream (CMR *cmr, CMR_SUBMAT **psubmatrix, size_t *pnumMatrixRows, size_t *pnumMatrixColumns, FILE *stream)
 Reads the submatrix *psubmatrix from the file stream. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatCreate (CMR *cmr, CMR_DBLMAT **presult, int numRows, int numColumns, int numNonzeros)
 Creates a double matrix of with numRows rows, numColumns columns and numNonzeros nonzeros. The actual arrays are allocated but not initialized. More...
 
CMR_EXPORT CMR_ERROR CMRintmatCreate (CMR *cmr, CMR_INTMAT **presult, int numRows, int numColumns, int numNonzeros)
 Creates an int matrix of with numRows rows, numColumns columns and numNonzeros nonzeros. The actual arrays are allocated but not initialized. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatCreate (CMR *cmr, CMR_CHRMAT **presult, int numRows, int numColumns, int numNonzeros)
 Creates a char matrix of with numRows rows, numColumns columns and numNonzeros nonzeros. The actual arrays are allocated but not initialized. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatFree (CMR *cmr, CMR_DBLMAT **pmatrix)
 Frees the memory of a double matrix. More...
 
CMR_EXPORT CMR_ERROR CMRintmatFree (CMR *cmr, CMR_INTMAT **pmatrix)
 Frees the memory of an int matrix. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatFree (CMR *cmr, CMR_CHRMAT **pmatrix)
 Frees the memory of a char matrix. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatChangeNumNonzeros (CMR *cmr, CMR_DBLMAT *matrix, size_t newNumNonzeros)
 Changes the number of nonzeros and reallocates corresponding arrays. More...
 
CMR_EXPORT CMR_ERROR CMRintmatChangeNumNonzeros (CMR *cmr, CMR_INTMAT *matrix, size_t newNumNonzeros)
 Changes the number of nonzeros and reallocates corresponding arrays. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatChangeNumNonzeros (CMR *cmr, CMR_CHRMAT *matrix, size_t newNumNonzeros)
 Changes the number of nonzeros and reallocates corresponding arrays. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatSortNonzeros (CMR *cmr, CMR_DBLMAT *matrix)
 Sorts the nonzeros of a double matrix by column in ascending order. More...
 
CMR_EXPORT CMR_ERROR CMRintmatSortNonzeros (CMR *cmr, CMR_INTMAT *matrix)
 Sorts the nonzeros of an int matrix by column in ascending order. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatSortNonzeros (CMR *cmr, CMR_CHRMAT *matrix)
 Sorts the nonzeros of a char matrix by column in ascending order. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatCopy (CMR *cmr, CMR_DBLMAT *matrix, CMR_DBLMAT **presult)
 Copies a double matrix to a newly allocated one. More...
 
CMR_EXPORT CMR_ERROR CMRintmatCopy (CMR *cmr, CMR_INTMAT *matrix, CMR_INTMAT **presult)
 Copies an int matrix to a newly allocated one. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatCopy (CMR *cmr, CMR_CHRMAT *matrix, CMR_CHRMAT **presult)
 Copies a char matrix to a newly allocated one. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatTranspose (CMR *cmr, CMR_DBLMAT *matrix, CMR_DBLMAT **presult)
 Creates the transpose of a double matrix. More...
 
CMR_EXPORT CMR_ERROR CMRintmatTranspose (CMR *cmr, CMR_INTMAT *matrix, CMR_INTMAT **presult)
 Creates the transpose of an int matrix. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatTranspose (CMR *cmr, CMR_CHRMAT *matrix, CMR_CHRMAT **presult)
 Creates the transpose of a char matrix. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatPermute (CMR *cmr, CMR_DBLMAT *matrix, size_t *rows, size_t *columns, CMR_DBLMAT **presult)
 Creates the double matrix obtained from matrix by applying row- and column-permutations. More...
 
CMR_EXPORT CMR_ERROR CMRintmatPermute (CMR *cmr, CMR_INTMAT *matrix, size_t *rows, size_t *columns, CMR_INTMAT **presult)
 Creates the int matrix obtained from matrix by applying row- and column-permutations. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatPermute (CMR *cmr, CMR_CHRMAT *matrix, size_t *rows, size_t *columns, CMR_CHRMAT **presult)
 Creates the char matrix obtained from matrix by applying row- and column-permutations. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatPrintSparse (CMR *cmr, CMR_DBLMAT *matrix, FILE *stream)
 Prints a double matrix in sparse format. More...
 
CMR_EXPORT CMR_ERROR CMRintmatPrintSparse (CMR *cmr, CMR_INTMAT *matrix, FILE *stream)
 Prints an int matrix in sparse format. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatPrintSparse (CMR *cmr, CMR_CHRMAT *matrix, FILE *stream)
 Prints a char matrix in sparse format. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatPrintDense (CMR *cmr, CMR_DBLMAT *matrix, FILE *stream, char zeroChar, bool header)
 Prints a double matrix in dense format. More...
 
CMR_EXPORT CMR_ERROR CMRintmatPrintDense (CMR *cmr, CMR_INTMAT *matrix, FILE *stream, char zeroChar, bool header)
 Prints an int matrix in dense format. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatPrintDense (CMR *cmr, CMR_CHRMAT *matrix, FILE *stream, char zeroChar, bool header)
 Prints a char matrix in dense format. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatCreateFromSparseStream (CMR *cmr, FILE *stream, CMR_DBLMAT **presult)
 Reads a double matrix from a file stream in sparse format. More...
 
CMR_EXPORT CMR_ERROR CMRintmatCreateFromSparseStream (CMR *cmr, FILE *stream, CMR_INTMAT **presult)
 Reads an int matrix from a file stream in sparse format. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatCreateFromSparseStream (CMR *cmr, FILE *stream, CMR_CHRMAT **presult)
 Reads a char matrix from a file stream in sparse format. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatCreateFromSparseFile (CMR *cmr, const char *fileName, const char *stdinName, CMR_DBLMAT **presult)
 Reads a double matrix from a file name fileName in sparse format. More...
 
CMR_EXPORT CMR_ERROR CMRintmatCreateFromSparseFile (CMR *cmr, const char *fileName, const char *stdinName, CMR_INTMAT **presult)
 Reads an int matrix from a file name fileName in sparse format. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatCreateFromSparseFile (CMR *cmr, const char *fileName, const char *stdinName, CMR_CHRMAT **presult)
 Reads a char matrix from a file name fileName in sparse format. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatCreateFromDenseStream (CMR *cmr, FILE *stream, CMR_DBLMAT **presult)
 Reads a double matrix from a file stream in dense format. More...
 
CMR_EXPORT CMR_ERROR CMRintmatCreateFromDenseStream (CMR *cmr, FILE *stream, CMR_INTMAT **presult)
 Reads an int matrix from a file stream in dense format. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatCreateFromDenseStream (CMR *cmr, FILE *stream, CMR_CHRMAT **presult)
 Reads a char matrix from a file stream in dense format. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatCreateFromDenseFile (CMR *cmr, const char *fileName, const char *stdinName, CMR_DBLMAT **presult)
 Reads a double matrix from a file name fileName in dense format. More...
 
CMR_EXPORT CMR_ERROR CMRintmatCreateFromDenseFile (CMR *cmr, const char *fileName, const char *stdinName, CMR_INTMAT **presult)
 Reads an int matrix from a file name fileName in dense format. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatCreateFromDenseFile (CMR *cmr, const char *fileName, const char *stdinName, CMR_CHRMAT **presult)
 Reads a char matrix from a file name fileName in dense format. More...
 
CMR_EXPORT bool CMRdblmatCheckEqual (CMR_DBLMAT *matrix1, CMR_DBLMAT *matrix2)
 Checks whether two double matrices are equal. More...
 
CMR_EXPORT bool CMRintmatCheckEqual (CMR_INTMAT *matrix1, CMR_INTMAT *matrix2)
 Checks whether two int matrices are equal. More...
 
CMR_EXPORT bool CMRchrmatCheckEqual (CMR_CHRMAT *matrix1, CMR_CHRMAT *matrix2)
 Checks whether two char matrices are equal. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatCheckTranspose (CMR *cmr, CMR_DBLMAT *matrix1, CMR_DBLMAT *matrix2, bool *pareTranspose)
 Checks whether two double matrices are transposes of each other. More...
 
CMR_EXPORT CMR_ERROR CMRintmatCheckTranspose (CMR *cmr, CMR_INTMAT *matrix1, CMR_INTMAT *matrix2, bool *pareTranspose)
 Checks whether two int matrices are transposes of each other. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatCheckTranspose (CMR *cmr, CMR_CHRMAT *matrix1, CMR_CHRMAT *matrix2, bool *pareTranspose)
 Checks whether two char matrices are transposes of each other. More...
 
CMR_EXPORT char * CMRdblmatConsistency (CMR_DBLMAT *matrix)
 Checks a double matrix for consistency. More...
 
CMR_EXPORT char * CMRintmatConsistency (CMR_INTMAT *matrix)
 Checks an int matrix for consistency. More...
 
CMR_EXPORT char * CMRchrmatConsistency (CMR_CHRMAT *matrix)
 Checks a char matrix for consistency. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatSlice (CMR *cmr, CMR_DBLMAT *matrix, CMR_SUBMAT *submatrix, CMR_DBLMAT **presult)
 Slices a submatrix of a double matrix. More...
 
CMR_EXPORT CMR_ERROR CMRintmatSlice (CMR *cmr, CMR_INTMAT *matrix, CMR_SUBMAT *submatrix, CMR_INTMAT **presult)
 Slices a submatrix of an int matrix. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatSlice (CMR *cmr, CMR_CHRMAT *matrix, CMR_SUBMAT *submatrix, CMR_CHRMAT **presult)
 Slices a submatrix of a char matrix. More...
 
CMR_EXPORT bool CMRdblmatIsBinary (CMR *cmr, CMR_DBLMAT *matrix, double epsilon, CMR_SUBMAT **psubmatrix)
 Checks if a double matrix has only entries in \( \{0,1\} \) with absolute error tolerance epsilon. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatFindBinarySubmatrix (CMR *cmr, CMR_DBLMAT *matrix, double epsilon, CMR_SUBMAT **psubmatrix)
 Finds a large binary submatrix with absolute error tolerance epsilon. More...
 
CMR_EXPORT bool CMRintmatIsBinary (CMR *cmr, CMR_INTMAT *matrix, CMR_SUBMAT **psubmatrix)
 Checks if an int matrix has only entries in \( \{0,1\} \). More...
 
CMR_EXPORT bool CMRchrmatIsBinary (CMR *cmr, CMR_CHRMAT *matrix, CMR_SUBMAT **psubmatrix)
 Checks if a char matrix has only entries in \( \{0,1\} \). More...
 
CMR_EXPORT bool CMRdblmatIsTernary (CMR *cmr, CMR_DBLMAT *matrix, double epsilon, CMR_SUBMAT **psubmatrix)
 Checks if a double matrix has only entries in \( \{-1,0,+1\} \) with absolute error tolerance epsilon. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatFindTernarySubmatrix (CMR *cmr, CMR_DBLMAT *matrix, double epsilon, CMR_SUBMAT **psubmatrix)
 Finds a large ternary submatrix with absolute error tolerance epsilon. More...
 
CMR_EXPORT bool CMRintmatIsTernary (CMR *cmr, CMR_INTMAT *matrix, CMR_SUBMAT **psubmatrix)
 Checks if an int matrix has only entries in \( \{-1,0,+1\} \). More...
 
CMR_EXPORT bool CMRchrmatIsTernary (CMR *cmr, CMR_CHRMAT *matrix, CMR_SUBMAT **psubmatrix)
 Checks if a double matrix has only entries in \( \{-1,0,+1\} \). More...
 
CMR_EXPORT CMR_ERROR CMRdblmatSupport (CMR *cmr, CMR_DBLMAT *matrix, double epsilon, CMR_CHRMAT **presult)
 Creates the (binary) support matrix of a double matrix as a char matrix with absolute error tolerance epsilon. More...
 
CMR_EXPORT CMR_ERROR CMRintmatSupport (CMR *cmr, CMR_INTMAT *matrix, CMR_CHRMAT **presult)
 Creates the (binary) support matrix of an int matrix as a char matrix. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatSupport (CMR *cmr, CMR_CHRMAT *matrix, CMR_CHRMAT **presult)
 Creates the (binary) support matrix of a char matrix as a char matrix. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatSignedSupport (CMR *cmr, CMR_DBLMAT *matrix, double epsilon, CMR_CHRMAT **presult)
 Creates the (ternary) signed support matrix of a double matrix as a char matrix with absolute error tolerance epsilon. More...
 
CMR_EXPORT CMR_ERROR CMRintmatSignedSupport (CMR *cmr, CMR_INTMAT *matrix, CMR_CHRMAT **presult)
 Creates the (ternary) signed support matrix of an int matrix as a char matrix. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatSignedSupport (CMR *cmr, CMR_CHRMAT *matrix, CMR_CHRMAT **presult)
 Creates the (ternary) signed support matrix of a char matrix as a char matrix. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatToInt (CMR *cmr, CMR_CHRMAT *matrix, CMR_INTMAT **presult)
 Converts a char matrix to an int matrix. More...
 
CMR_EXPORT CMR_ERROR CMRintmatToChr (CMR *cmr, CMR_INTMAT *matrix, CMR_CHRMAT **presult)
 Converts an int matrix to a char matrix. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatToChr (CMR *cmr, CMR_DBLMAT *matrix, double epsilon, CMR_CHRMAT **presult)
 Converts a double matrix to a char matrix. More...
 
CMR_EXPORT CMR_ERROR CMRdblmatFindEntry (CMR_DBLMAT *matrix, size_t row, size_t column, size_t *pentry)
 Finds a specific entry of a double matrix. More...
 
CMR_EXPORT CMR_ERROR CMRintmatFindEntry (CMR_INTMAT *matrix, size_t row, size_t column, size_t *pentry)
 Finds a specific entry of an int matrix. More...
 
CMR_EXPORT CMR_ERROR CMRchrmatFindEntry (CMR_CHRMAT *matrix, size_t row, size_t column, size_t *pentry)
 Finds a specific entry of a char matrix. More...
 

Detailed Description

Functionality for sparse matrices.

Author
Matthias Walter

Function Documentation

◆ CMRchrmatChangeNumNonzeros()

CMR_EXPORT CMR_ERROR CMRchrmatChangeNumNonzeros ( CMR cmr,
CMR_CHRMAT matrix,
size_t  newNumNonzeros 
)

Changes the number of nonzeros and reallocates corresponding arrays.

Parameters
cmrCMR environment.
matrixA matrix.
newNumNonzerosNew number of nonzeros.

◆ CMRchrmatCheckEqual()

CMR_EXPORT bool CMRchrmatCheckEqual ( CMR_CHRMAT matrix1,
CMR_CHRMAT matrix2 
)

Checks whether two char matrices are equal.

Parameters
matrix1First matrix.
matrix2Second matrix.

◆ CMRchrmatCheckTranspose()

CMR_EXPORT CMR_ERROR CMRchrmatCheckTranspose ( CMR cmr,
CMR_CHRMAT matrix1,
CMR_CHRMAT matrix2,
bool *  pareTranspose 
)

Checks whether two char matrices are transposes of each other.

Parameters
cmrCMR environment.
matrix1First matrix
matrix2Second matrix
pareTransposePointer for storing whether matrix1 and matrix2 are tranposes of each other.

◆ CMRchrmatConsistency()

CMR_EXPORT char* CMRchrmatConsistency ( CMR_CHRMAT matrix)

Checks a char matrix for consistency.

Checks whether the entries of a row are sorted by column in ascending order. Checks for duplicate entries. Checks for zero entries.

Returns
NULL if consistent. Otherwise, an explanation string is returned, which must free'd with free().
See also
CMRdbgConsistencyAssert() for checking the returned string and aborting in case of inconsistency.
Parameters
matrixA matrix.

◆ CMRchrmatCopy()

CMR_EXPORT CMR_ERROR CMRchrmatCopy ( CMR cmr,
CMR_CHRMAT matrix,
CMR_CHRMAT **  presult 
)

Copies a char matrix to a newly allocated one.

Parameters
cmrCMR environment.
matrixA matrix.
presultPointer for storing a copy of matrix.

◆ CMRchrmatCreate()

CMR_EXPORT CMR_ERROR CMRchrmatCreate ( CMR cmr,
CMR_CHRMAT **  presult,
int  numRows,
int  numColumns,
int  numNonzeros 
)

Creates a char matrix of with numRows rows, numColumns columns and numNonzeros nonzeros. The actual arrays are allocated but not initialized.

Parameters
cmrCMR environment.
presultPointer for storing the created matrix.
numRowsNumber of rows.
numColumnsNumber of columns.
numNonzerosNumber of nonzeros.

◆ CMRchrmatCreateFromDenseFile()

CMR_EXPORT CMR_ERROR CMRchrmatCreateFromDenseFile ( CMR cmr,
const char *  fileName,
const char *  stdinName,
CMR_CHRMAT **  presult 
)

Reads a char matrix from a file name fileName in dense format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL. Expects that the file contains only the matrix and no additional data.

Parameters
cmrCMR environment.
fileNameFile stream to read from.
stdinNameIf not NULL, indicates which file name represents stdin.
presultPointer for storing the matrix.

◆ CMRchrmatCreateFromDenseStream()

CMR_EXPORT CMR_ERROR CMRchrmatCreateFromDenseStream ( CMR cmr,
FILE *  stream,
CMR_CHRMAT **  presult 
)

Reads a char matrix from a file stream in dense format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL.

Parameters
cmrCMR environment.
streamFile stream to read from.
presultPointer for storing the matrix.

◆ CMRchrmatCreateFromSparseFile()

CMR_EXPORT CMR_ERROR CMRchrmatCreateFromSparseFile ( CMR cmr,
const char *  fileName,
const char *  stdinName,
CMR_CHRMAT **  presult 
)

Reads a char matrix from a file name fileName in sparse format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL. Expects that the file contains only the matrix and no additional data.

Parameters
cmrCMR environment.
fileNameFile stream to read from.
stdinNameIf not NULL, indicates which file name represents stdin.
presultPointer for storing the matrix.

◆ CMRchrmatCreateFromSparseStream()

CMR_EXPORT CMR_ERROR CMRchrmatCreateFromSparseStream ( CMR cmr,
FILE *  stream,
CMR_CHRMAT **  presult 
)

Reads a char matrix from a file stream in sparse format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL.

Parameters
cmrCMR environment.
streamFile stream to read from.
presultPointer for storing the matrix.

◆ CMRchrmatFindEntry()

CMR_EXPORT CMR_ERROR CMRchrmatFindEntry ( CMR_CHRMAT matrix,
size_t  row,
size_t  column,
size_t *  pentry 
)

Finds a specific entry of a char matrix.

Searches for the entry at (row, column) using binary search. If an entry is zero, then *pentry is set to SIZE_MAX.

Parameters
matrixInput matrix.
rowA row.
columnA column.
pentryPointer for storing the entry at row, column, or SIZE_MAX if it is zero.

◆ CMRchrmatFree()

CMR_EXPORT CMR_ERROR CMRchrmatFree ( CMR cmr,
CMR_CHRMAT **  pmatrix 
)

Frees the memory of a char matrix.

Parameters
cmrCMR environment.
pmatrixPointer to matrix.

◆ CMRchrmatIsBinary()

CMR_EXPORT bool CMRchrmatIsBinary ( CMR cmr,
CMR_CHRMAT matrix,
CMR_SUBMAT **  psubmatrix 
)

Checks if a char matrix has only entries in \( \{0,1\} \).

Parameters
cmrCMR environment.
matrixA matrix.
psubmatrixPointer for storing a non-binary entry as a submatrix (may be NULL).

◆ CMRchrmatIsTernary()

CMR_EXPORT bool CMRchrmatIsTernary ( CMR cmr,
CMR_CHRMAT matrix,
CMR_SUBMAT **  psubmatrix 
)

Checks if a double matrix has only entries in \( \{-1,0,+1\} \).

Parameters
cmrCMR environment.
matrixA matrix.
psubmatrixPointer for storing a non-ternary entry as a submatrix (may be NULL).

◆ CMRchrmatPermute()

CMR_EXPORT CMR_ERROR CMRchrmatPermute ( CMR cmr,
CMR_CHRMAT matrix,
size_t *  rows,
size_t *  columns,
CMR_CHRMAT **  presult 
)

Creates the char matrix obtained from matrix by applying row- and column-permutations.

Parameters
cmrCMR environment.
matrixGiven matrix.
rowsMapping from new rows to rows of matrix (may be NULL for identity).
columnsMapping from new columns to columns of matrix (may be NULL for identity).
presultPointer for storing the permuted matrix.

◆ CMRchrmatPrintDense()

CMR_EXPORT CMR_ERROR CMRchrmatPrintDense ( CMR cmr,
CMR_CHRMAT matrix,
FILE *  stream,
char  zeroChar,
bool  header 
)

Prints a char matrix in dense format.

Parameters
cmrCMR environment.
matrixA matrix.
streamFile stream to print to.
zeroCharCharacter to print for a zero.
headerWhether to print row and column indices.

◆ CMRchrmatPrintSparse()

CMR_EXPORT CMR_ERROR CMRchrmatPrintSparse ( CMR cmr,
CMR_CHRMAT matrix,
FILE *  stream 
)

Prints a char matrix in sparse format.

Parameters
cmrCMR environment.
matrixA matrix.
streamFile stream to print to.

◆ CMRchrmatSignedSupport()

CMR_EXPORT CMR_ERROR CMRchrmatSignedSupport ( CMR cmr,
CMR_CHRMAT matrix,
CMR_CHRMAT **  presult 
)

Creates the (ternary) signed support matrix of a char matrix as a char matrix.

Parameters
cmrCMR environment.
matrixDouble matrix
presultPointer for storing the signed support matrix of matrix.

◆ CMRchrmatSlice()

CMR_EXPORT CMR_ERROR CMRchrmatSlice ( CMR cmr,
CMR_CHRMAT matrix,
CMR_SUBMAT submatrix,
CMR_CHRMAT **  presult 
)

Slices a submatrix of a char matrix.

Parameters
cmrCMR environment.
matrixA matrix
submatrixA submatrix of matrix.
presultPointer for storing the resulting double matrix.

◆ CMRchrmatSortNonzeros()

CMR_EXPORT CMR_ERROR CMRchrmatSortNonzeros ( CMR cmr,
CMR_CHRMAT matrix 
)

Sorts the nonzeros of a char matrix by column in ascending order.

Parameters
cmrCMR environment.
matrixA matrix.

◆ CMRchrmatSupport()

CMR_EXPORT CMR_ERROR CMRchrmatSupport ( CMR cmr,
CMR_CHRMAT matrix,
CMR_CHRMAT **  presult 
)

Creates the (binary) support matrix of a char matrix as a char matrix.

Parameters
cmrCMR environment.
matrixDouble matrix
presultPointer for storing the support matrix of matrix.

◆ CMRchrmatToInt()

CMR_EXPORT CMR_ERROR CMRchrmatToInt ( CMR cmr,
CMR_CHRMAT matrix,
CMR_INTMAT **  presult 
)

Converts a char matrix to an int matrix.

Parameters
cmrCMR environment.
matrixInput matrix.
presultPointer for storing the output matrix.

◆ CMRchrmatTranspose()

CMR_EXPORT CMR_ERROR CMRchrmatTranspose ( CMR cmr,
CMR_CHRMAT matrix,
CMR_CHRMAT **  presult 
)

Creates the transpose of a char matrix.

Parameters
cmrCMR environment.
matrixGiven matrix.
presultPointer for storing the transpose of matrix.

◆ CMRdblmatChangeNumNonzeros()

CMR_EXPORT CMR_ERROR CMRdblmatChangeNumNonzeros ( CMR cmr,
CMR_DBLMAT matrix,
size_t  newNumNonzeros 
)

Changes the number of nonzeros and reallocates corresponding arrays.

Parameters
cmrCMR environment.
matrixGiven matrix.
newNumNonzerosNew number of nonzeros.

◆ CMRdblmatCheckEqual()

CMR_EXPORT bool CMRdblmatCheckEqual ( CMR_DBLMAT matrix1,
CMR_DBLMAT matrix2 
)

Checks whether two double matrices are equal.

Parameters
matrix1First matrix.
matrix2Second matrix.

◆ CMRdblmatCheckTranspose()

CMR_EXPORT CMR_ERROR CMRdblmatCheckTranspose ( CMR cmr,
CMR_DBLMAT matrix1,
CMR_DBLMAT matrix2,
bool *  pareTranspose 
)

Checks whether two double matrices are transposes of each other.

Parameters
cmrCMR environment.
matrix1First matrix.
matrix2Second matrix.
pareTransposePointer for storing whether matrix1 and matrix2 are tranposes of each other.

◆ CMRdblmatConsistency()

CMR_EXPORT char* CMRdblmatConsistency ( CMR_DBLMAT matrix)

Checks a double matrix for consistency.

Checks whether the entries of a row are sorted by column in ascending order. Checks for duplicate entries. Checks for zero entries.

Returns
NULL if consistent. Otherwise, an explanation string is returned, which must free'd with free().
See also
CMRdbgConsistencyAssert() for checking the returned string and aborting in case of inconsistency.
Parameters
matrixA matrix.

◆ CMRdblmatCopy()

CMR_EXPORT CMR_ERROR CMRdblmatCopy ( CMR cmr,
CMR_DBLMAT matrix,
CMR_DBLMAT **  presult 
)

Copies a double matrix to a newly allocated one.

Parameters
cmrCMR environment.
matrixA matrix.
presultPointer for storing a copy of matrix.

◆ CMRdblmatCreate()

CMR_EXPORT CMR_ERROR CMRdblmatCreate ( CMR cmr,
CMR_DBLMAT **  presult,
int  numRows,
int  numColumns,
int  numNonzeros 
)

Creates a double matrix of with numRows rows, numColumns columns and numNonzeros nonzeros. The actual arrays are allocated but not initialized.

Parameters
cmrCMR environment.
presultPointer for storing the created matrix.
numRowsNumber of rows.
numColumnsNumber of columns.
numNonzerosNumber of nonzeros.

◆ CMRdblmatCreateFromDenseFile()

CMR_EXPORT CMR_ERROR CMRdblmatCreateFromDenseFile ( CMR cmr,
const char *  fileName,
const char *  stdinName,
CMR_DBLMAT **  presult 
)

Reads a double matrix from a file name fileName in dense format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL. Expects that the file contains only the matrix and no additional data.

Parameters
cmrCMR environment.
fileNameFile stream to read from.
stdinNameIf not NULL, indicates which file name represents stdin.
presultPointer for storing the matrix.

◆ CMRdblmatCreateFromDenseStream()

CMR_EXPORT CMR_ERROR CMRdblmatCreateFromDenseStream ( CMR cmr,
FILE *  stream,
CMR_DBLMAT **  presult 
)

Reads a double matrix from a file stream in dense format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL.

Parameters
cmrCMR environment.
streamFile stream to read from.
presultPointer for storing the matrix.

◆ CMRdblmatCreateFromSparseFile()

CMR_EXPORT CMR_ERROR CMRdblmatCreateFromSparseFile ( CMR cmr,
const char *  fileName,
const char *  stdinName,
CMR_DBLMAT **  presult 
)

Reads a double matrix from a file name fileName in sparse format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL. Expects that the file contains only the matrix and no additional data.

Parameters
cmrCMR environment.
fileNameFile stream to read from.
stdinNameIf not NULL, indicates which file name represents stdin.
presultPointer for storing the matrix.

◆ CMRdblmatCreateFromSparseStream()

CMR_EXPORT CMR_ERROR CMRdblmatCreateFromSparseStream ( CMR cmr,
FILE *  stream,
CMR_DBLMAT **  presult 
)

Reads a double matrix from a file stream in sparse format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL.

Parameters
cmrCMR environment.
streamFile stream to read from.
presultPointer for storing the matrix.

◆ CMRdblmatFindBinarySubmatrix()

CMR_EXPORT CMR_ERROR CMRdblmatFindBinarySubmatrix ( CMR cmr,
CMR_DBLMAT matrix,
double  epsilon,
CMR_SUBMAT **  psubmatrix 
)

Finds a large binary submatrix with absolute error tolerance epsilon.

Parameters
cmrCMR environment.
matrixA matrix.
epsilonAbsolute error tolerance.
psubmatrixPointer for storing a large binary submatrix.

◆ CMRdblmatFindEntry()

CMR_EXPORT CMR_ERROR CMRdblmatFindEntry ( CMR_DBLMAT matrix,
size_t  row,
size_t  column,
size_t *  pentry 
)

Finds a specific entry of a double matrix.

Searches for the entry at (row, column) using binary search.

Parameters
matrixInput matrix.
rowA row.
columnA column.
pentryPointer for storing the entry at row, column, or SIZE_MAX if it is zero.

◆ CMRdblmatFindTernarySubmatrix()

CMR_EXPORT CMR_ERROR CMRdblmatFindTernarySubmatrix ( CMR cmr,
CMR_DBLMAT matrix,
double  epsilon,
CMR_SUBMAT **  psubmatrix 
)

Finds a large ternary submatrix with absolute error tolerance epsilon.

Parameters
cmrCMR environment.
matrixA matrix.
epsilonAbsolute error tolerance.
psubmatrixPointer for storing a large binary submatrix.

◆ CMRdblmatFree()

CMR_EXPORT CMR_ERROR CMRdblmatFree ( CMR cmr,
CMR_DBLMAT **  pmatrix 
)

Frees the memory of a double matrix.

Parameters
cmrCMR environment.
pmatrixPointer to matrix.

◆ CMRdblmatIsBinary()

CMR_EXPORT bool CMRdblmatIsBinary ( CMR cmr,
CMR_DBLMAT matrix,
double  epsilon,
CMR_SUBMAT **  psubmatrix 
)

Checks if a double matrix has only entries in \( \{0,1\} \) with absolute error tolerance epsilon.

Parameters
cmrCMR environment.
matrixA matrix.
epsilonAbsolute error tolerance.
psubmatrixPointer for storing a non-binary entry as a submatrix (may be NULL).

◆ CMRdblmatIsTernary()

CMR_EXPORT bool CMRdblmatIsTernary ( CMR cmr,
CMR_DBLMAT matrix,
double  epsilon,
CMR_SUBMAT **  psubmatrix 
)

Checks if a double matrix has only entries in \( \{-1,0,+1\} \) with absolute error tolerance epsilon.

Parameters
cmrCMR environment.
matrixA matrix.
epsilonAbsolute error tolerance.
psubmatrixPointer for storing a non-ternary entry as a submatrix (may be NULL).

◆ CMRdblmatPermute()

CMR_EXPORT CMR_ERROR CMRdblmatPermute ( CMR cmr,
CMR_DBLMAT matrix,
size_t *  rows,
size_t *  columns,
CMR_DBLMAT **  presult 
)

Creates the double matrix obtained from matrix by applying row- and column-permutations.

Parameters
cmrCMR environment.
matrixGiven matrix.
rowsMapping from new rows to rows of matrix (may be NULL for identity).
columnsMapping from new columns to columns of matrix (may be NULL for identity).
presultPointer for storing the permuted matrix.

◆ CMRdblmatPrintDense()

CMR_EXPORT CMR_ERROR CMRdblmatPrintDense ( CMR cmr,
CMR_DBLMAT matrix,
FILE *  stream,
char  zeroChar,
bool  header 
)

Prints a double matrix in dense format.

Parameters
cmrCMR environment.
matrixA matrix.
streamFile stream to print to.
zeroCharCharacter to print for a zero.
headerWhether to print row and column indices.

◆ CMRdblmatPrintSparse()

CMR_EXPORT CMR_ERROR CMRdblmatPrintSparse ( CMR cmr,
CMR_DBLMAT matrix,
FILE *  stream 
)

Prints a double matrix in sparse format.

Parameters
cmrCMR environment.
matrixA matrix.
streamFile stream to print to.

◆ CMRdblmatSignedSupport()

CMR_EXPORT CMR_ERROR CMRdblmatSignedSupport ( CMR cmr,
CMR_DBLMAT matrix,
double  epsilon,
CMR_CHRMAT **  presult 
)

Creates the (ternary) signed support matrix of a double matrix as a char matrix with absolute error tolerance epsilon.

Parameters
cmrCMR environment.
matrixDouble matrix
epsilonAbsolute error tolerance.
presultPointer for storing the support matrix of matrix.

◆ CMRdblmatSlice()

CMR_EXPORT CMR_ERROR CMRdblmatSlice ( CMR cmr,
CMR_DBLMAT matrix,
CMR_SUBMAT submatrix,
CMR_DBLMAT **  presult 
)

Slices a submatrix of a double matrix.

Parameters
cmrCMR environment.
matrixA matrix
submatrixA submatrix of matrix.
presultPointer for storing the resulting matrix.

◆ CMRdblmatSortNonzeros()

CMR_EXPORT CMR_ERROR CMRdblmatSortNonzeros ( CMR cmr,
CMR_DBLMAT matrix 
)

Sorts the nonzeros of a double matrix by column in ascending order.

Parameters
cmrCMR environment.
matrixA matrix.

◆ CMRdblmatSupport()

CMR_EXPORT CMR_ERROR CMRdblmatSupport ( CMR cmr,
CMR_DBLMAT matrix,
double  epsilon,
CMR_CHRMAT **  presult 
)

Creates the (binary) support matrix of a double matrix as a char matrix with absolute error tolerance epsilon.

Parameters
cmrCMR environment.
matrixDouble matrix
epsilonAbsolute error tolerance.
presultPointer for storing the support matrix of matrix.

◆ CMRdblmatToChr()

CMR_EXPORT CMR_ERROR CMRdblmatToChr ( CMR cmr,
CMR_DBLMAT matrix,
double  epsilon,
CMR_CHRMAT **  presult 
)

Converts a double matrix to a char matrix.

Returns
CMR_ERROR_OVERFLOW in case of overflow.
Parameters
cmrCMR environment.
matrixInput matrix.
epsilonExpected accuracy.
presultPointer for storing the output matrix.

◆ CMRdblmatTranspose()

CMR_EXPORT CMR_ERROR CMRdblmatTranspose ( CMR cmr,
CMR_DBLMAT matrix,
CMR_DBLMAT **  presult 
)

Creates the transpose of a double matrix.

Parameters
cmrCMR environment.
matrixA matrix.
presultPointer for storing the transpose of matrix.

◆ CMRintmatChangeNumNonzeros()

CMR_EXPORT CMR_ERROR CMRintmatChangeNumNonzeros ( CMR cmr,
CMR_INTMAT matrix,
size_t  newNumNonzeros 
)

Changes the number of nonzeros and reallocates corresponding arrays.

Parameters
cmrCMR environment.
matrixA matrix.
newNumNonzerosNew number of nonzeros.

◆ CMRintmatCheckEqual()

CMR_EXPORT bool CMRintmatCheckEqual ( CMR_INTMAT matrix1,
CMR_INTMAT matrix2 
)

Checks whether two int matrices are equal.

Parameters
matrix1First matrix.
matrix2Second matrix.

◆ CMRintmatCheckTranspose()

CMR_EXPORT CMR_ERROR CMRintmatCheckTranspose ( CMR cmr,
CMR_INTMAT matrix1,
CMR_INTMAT matrix2,
bool *  pareTranspose 
)

Checks whether two int matrices are transposes of each other.

Parameters
cmrCMR environment.
matrix1First matrix
matrix2Second matrix
pareTransposePointer for storing whether matrix1 and matrix2 are tranposes of each other.

◆ CMRintmatConsistency()

CMR_EXPORT char* CMRintmatConsistency ( CMR_INTMAT matrix)

Checks an int matrix for consistency.

Checks whether the entries of a row are sorted by column in ascending order. Checks for duplicate entries. Checks for zero entries.

Returns
NULL if consistent. Otherwise, an explanation string is returned, which must free'd with free().
See also
CMRdbgConsistencyAssert() for checking the returned string and aborting in case of inconsistency.
Parameters
matrixA matrix.

◆ CMRintmatCopy()

CMR_EXPORT CMR_ERROR CMRintmatCopy ( CMR cmr,
CMR_INTMAT matrix,
CMR_INTMAT **  presult 
)

Copies an int matrix to a newly allocated one.

Parameters
cmrCMR environment.
matrixA matrix.
presultPointer for storing a copy of matrix.

◆ CMRintmatCreate()

CMR_EXPORT CMR_ERROR CMRintmatCreate ( CMR cmr,
CMR_INTMAT **  presult,
int  numRows,
int  numColumns,
int  numNonzeros 
)

Creates an int matrix of with numRows rows, numColumns columns and numNonzeros nonzeros. The actual arrays are allocated but not initialized.

Parameters
cmrCMR environment.
presultPointer for storing the created matrix.
numRowsNumber of rows.
numColumnsNumber of columns.
numNonzerosNumber of nonzeros.

◆ CMRintmatCreateFromDenseFile()

CMR_EXPORT CMR_ERROR CMRintmatCreateFromDenseFile ( CMR cmr,
const char *  fileName,
const char *  stdinName,
CMR_INTMAT **  presult 
)

Reads an int matrix from a file name fileName in dense format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL. Expects that the file contains only the matrix and no additional data.

Parameters
cmrCMR environment.
fileNameFile stream to read from.
stdinNameIf not NULL, indicates which file name represents stdin.
presultPointer for storing the matrix.

◆ CMRintmatCreateFromDenseStream()

CMR_EXPORT CMR_ERROR CMRintmatCreateFromDenseStream ( CMR cmr,
FILE *  stream,
CMR_INTMAT **  presult 
)

Reads an int matrix from a file stream in dense format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL.

Parameters
cmrCMR environment.
streamFile stream to read from.
presultPointer for storing the matrix.

◆ CMRintmatCreateFromSparseFile()

CMR_EXPORT CMR_ERROR CMRintmatCreateFromSparseFile ( CMR cmr,
const char *  fileName,
const char *  stdinName,
CMR_INTMAT **  presult 
)

Reads an int matrix from a file name fileName in sparse format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL. Expects that the file contains only the matrix and no additional data.

Parameters
cmrCMR environment.
fileNameFile stream to read from.
stdinNameIf not NULL, indicates which file name represents stdin.
presultPointer for storing the matrix.

◆ CMRintmatCreateFromSparseStream()

CMR_EXPORT CMR_ERROR CMRintmatCreateFromSparseStream ( CMR cmr,
FILE *  stream,
CMR_INTMAT **  presult 
)

Reads an int matrix from a file stream in sparse format.

Returns CMR_ERROR_INPUT in case of errors. In this case, *presult will be NULL.

Parameters
cmrCMR environment.
streamFile stream to read from.
presultPointer for storing the matrix.

◆ CMRintmatFindEntry()

CMR_EXPORT CMR_ERROR CMRintmatFindEntry ( CMR_INTMAT matrix,
size_t  row,
size_t  column,
size_t *  pentry 
)

Finds a specific entry of an int matrix.

Searches for the entry at (row, column) using binary search.

Parameters
matrixInput matrix.
rowA row.
columnA column.
pentryPointer for storing the entry at row, column, or SIZE_MAX if it is zero.

◆ CMRintmatFree()

CMR_EXPORT CMR_ERROR CMRintmatFree ( CMR cmr,
CMR_INTMAT **  pmatrix 
)

Frees the memory of an int matrix.

Parameters
cmrCMR environment.
pmatrixPointer to matrix.

◆ CMRintmatIsBinary()

CMR_EXPORT bool CMRintmatIsBinary ( CMR cmr,
CMR_INTMAT matrix,
CMR_SUBMAT **  psubmatrix 
)

Checks if an int matrix has only entries in \( \{0,1\} \).

Parameters
cmrCMR environment.
matrixA matrix.
psubmatrixPointer for storing a non-binary entry as a submatrix (may be NULL).

◆ CMRintmatIsTernary()

CMR_EXPORT bool CMRintmatIsTernary ( CMR cmr,
CMR_INTMAT matrix,
CMR_SUBMAT **  psubmatrix 
)

Checks if an int matrix has only entries in \( \{-1,0,+1\} \).

Parameters
cmrCMR environment.
matrixA matrix.
psubmatrixPointer for storing a non-ternary entry as a submatrix (may be NULL).

◆ CMRintmatPermute()

CMR_EXPORT CMR_ERROR CMRintmatPermute ( CMR cmr,
CMR_INTMAT matrix,
size_t *  rows,
size_t *  columns,
CMR_INTMAT **  presult 
)

Creates the int matrix obtained from matrix by applying row- and column-permutations.

Parameters
cmrCMR environment.
matrixGiven matrix.
rowsMapping from new rows to rows of matrix (may be NULL for identity).
columnsMapping from new columns to columns of matrix (may be NULL for identity).
presultPointer for storing the permuted matrix.

◆ CMRintmatPrintDense()

CMR_EXPORT CMR_ERROR CMRintmatPrintDense ( CMR cmr,
CMR_INTMAT matrix,
FILE *  stream,
char  zeroChar,
bool  header 
)

Prints an int matrix in dense format.

Parameters
cmrCMR environment.
matrixA matrix.
streamFile stream to print to.
zeroCharCharacter to print for a zero.
headerWhether to print row and column indices.

◆ CMRintmatPrintSparse()

CMR_EXPORT CMR_ERROR CMRintmatPrintSparse ( CMR cmr,
CMR_INTMAT matrix,
FILE *  stream 
)

Prints an int matrix in sparse format.

Parameters
cmrCMR environment.
matrixA matrix.
streamFile stream to print to.

◆ CMRintmatSignedSupport()

CMR_EXPORT CMR_ERROR CMRintmatSignedSupport ( CMR cmr,
CMR_INTMAT matrix,
CMR_CHRMAT **  presult 
)

Creates the (ternary) signed support matrix of an int matrix as a char matrix.

Parameters
cmrCMR environment.
matrixDouble matrix
presultPointer for storing the signed support matrix of matrix.

◆ CMRintmatSlice()

CMR_EXPORT CMR_ERROR CMRintmatSlice ( CMR cmr,
CMR_INTMAT matrix,
CMR_SUBMAT submatrix,
CMR_INTMAT **  presult 
)

Slices a submatrix of an int matrix.

Parameters
cmrCMR environment.
matrixA matrix
submatrixA submatrix of matrix.
presultPointer for storing the resulting matrix.

◆ CMRintmatSortNonzeros()

CMR_EXPORT CMR_ERROR CMRintmatSortNonzeros ( CMR cmr,
CMR_INTMAT matrix 
)

Sorts the nonzeros of an int matrix by column in ascending order.

Parameters
cmrCMR environment.
matrixA matrix.

◆ CMRintmatSupport()

CMR_EXPORT CMR_ERROR CMRintmatSupport ( CMR cmr,
CMR_INTMAT matrix,
CMR_CHRMAT **  presult 
)

Creates the (binary) support matrix of an int matrix as a char matrix.

Parameters
cmrCMR environment.
matrixDouble matrix
presultPointer for storing the support matrix of matrix.

◆ CMRintmatToChr()

CMR_EXPORT CMR_ERROR CMRintmatToChr ( CMR cmr,
CMR_INTMAT matrix,
CMR_CHRMAT **  presult 
)

Converts an int matrix to a char matrix.

Returns
CMR_ERROR_OVERFLOW in case of overflow.
Parameters
cmrCMR environment.
matrixInput matrix.
presultPointer for storing the output matrix.

◆ CMRintmatTranspose()

CMR_EXPORT CMR_ERROR CMRintmatTranspose ( CMR cmr,
CMR_INTMAT matrix,
CMR_INTMAT **  presult 
)

Creates the transpose of an int matrix.

Parameters
cmrCMR environment.
matrixGiven matrix.
presultPointer for storing the transpose of matrix.

◆ CMRsubmatCreate()

CMR_EXPORT CMR_ERROR CMRsubmatCreate ( CMR cmr,
size_t  numRows,
size_t  numColumns,
CMR_SUBMAT **  psubmatrix 
)

Creates a submatrix of given size.

Only allocates the memory. Use rows and columns attributes of *psubmatrix to actually set the row and column indices, respectively.

Parameters
cmrCMR environment.
numRowsNumber of rows
numColumnsNumber of columns
psubmatrixPointer to where the submatrix is to be stored.

◆ CMRsubmatCreate1x1()

CMR_EXPORT CMR_ERROR CMRsubmatCreate1x1 ( CMR cmr,
size_t  row,
size_t  column,
CMR_SUBMAT **  psubmatrix 
)

Creates a 1-by-1 submatrix.

Parameters
cmrCMR environment.
rowRow of entry
columnColumn of entry
psubmatrixPointer to submatrix

◆ CMRsubmatFree()

CMR_EXPORT CMR_ERROR CMRsubmatFree ( CMR cmr,
CMR_SUBMAT **  psubmatrix 
)

Frees a submatrix.

Parameters
cmrCMR environment.
psubmatrixPointer to submatrix.

◆ CMRsubmatPrint()

CMR_EXPORT CMR_ERROR CMRsubmatPrint ( CMR cmr,
CMR_SUBMAT submatrix,
size_t  numRows,
size_t  numColumns,
FILE *  stream 
)

Writes the submatrix submatrix to the file stream by means of lists of row and column indices.

In the stream, row and column indices start at 1 while they start at 0 in submatrix.

Parameters
cmrCMR environment.
submatrixReference submatrix.
numRowsNumber of rows of original matrix.
numColumnsNumber of columns of original matrix.
streamFile stream to save submatrix to.

◆ CMRsubmatReadFromStream()

CMR_EXPORT CMR_ERROR CMRsubmatReadFromStream ( CMR cmr,
CMR_SUBMAT **  psubmatrix,
size_t *  pnumMatrixRows,
size_t *  pnumMatrixColumns,
FILE *  stream 
)

Reads the submatrix *psubmatrix from the file stream.

In the stream, row and column indices start at 1 while they start at 0 in submatrix.

Parameters
cmrCMR environment.
psubmatrixPointer for storing the submatrix.
pnumMatrixRowsPointer for storing the number of rows of the original matrix; may be NULL.
pnumMatrixColumnsPointer for storing the number of rows of the original matrix; may be NULL.
streamFile stream to save submatrix to.

◆ CMRsubmatSlice()

CMR_EXPORT CMR_ERROR CMRsubmatSlice ( CMR cmr,
CMR_SUBMAT base,
CMR_SUBMAT input,
CMR_SUBMAT **  poutput 
)

Returns the submatrix input as a submatrix of the base submatrix.

Assumes that each row/column of input also appear inbase. After the call *poutput will refer to the same rows/columns but from the viewpoint of base. Otherwise, CMR_ERROR_INPUT is returned.

Parameters
cmrCMR environment.
baseReference submatrix.
inputInput submatrix.
poutputPointer for storing the output submatrix.

◆ CMRsubmatTranspose()

CMR_EXPORT CMR_ERROR CMRsubmatTranspose ( CMR_SUBMAT submatrix)

Transposes a submatrix.

Parameters
submatrixSubmatrix to transpose.

◆ CMRsubmatUnslice()

CMR_EXPORT CMR_ERROR CMRsubmatUnslice ( CMR cmr,
CMR_SUBMAT base,
CMR_SUBMAT input,
CMR_SUBMAT **  poutput 
)

Returns the sub-submatrix input of base as a submatrix of its parent.

The rows/columns of input are interpreted as those of base. After the call *poutput will refer to the saem rows/columns but as those of the parent.

Parameters
cmrCMR environment.
baseReference submatrix.
inputInput submatrix.
poutputPointer for storing the output submatrix.

◆ CMRsubmatWriteToFile()

CMR_EXPORT CMR_ERROR CMRsubmatWriteToFile ( CMR cmr,
CMR_SUBMAT submatrix,
size_t  numRows,
size_t  numColumns,
const char *  fileName 
)

Writes the submatrix submatrix to the file fileName by means of lists of row and column indices.

In the file, row and column indices start at 1 while they start at 0 in submatrix.

Parameters
cmrCMR environment.
submatrixReference submatrix.
numRowsNumber of rows of original matrix.
numColumnsNumber of columns of original matrix.
fileNameFile name to save submatrix to; NULL indicates stdout.