H2Lib  3.0
Data Structures | Typedefs | Functions
amatrix

Representation of a matrix as an array in column-major order. More...

Data Structures

struct  _amatrix
 Representation of a matrix as an array in column-major order. More...
 

Typedefs

typedef struct _amatrix amatrix
 Representation of a matrix as a column-order array.
 
typedef amatrixpamatrix
 Pointer to amatrix object.
 
typedef const amatrixpcamatrix
 Pointer to constant amatrix object.
 

Functions

pamatrix init_amatrix (pamatrix a, uint rows, uint cols)
 Initialize an amatrix object. More...
 
pamatrix init_sub_amatrix (pamatrix a, pamatrix src, uint rows, uint roff, uint cols, uint coff)
 Initialize an amatrix object to represent a submatrix. More...
 
pamatrix init_vec_amatrix (pamatrix a, pavector src, uint rows, uint cols)
 Initialize an amatrix object by a vector. More...
 
pamatrix init_pointer_amatrix (pamatrix a, pfield src, uint rows, uint cols)
 Initialize an amatrix object using a given array for the coefficients. More...
 
pamatrix init_zero_amatrix (pamatrix a, uint rows, uint cols)
 Initialize an amatrix object and set it to zero. More...
 
pamatrix init_identity_amatrix (pamatrix a, uint rows, uint cols)
 Initialize an amatrix object and set it to identity. More...
 
void uninit_amatrix (pamatrix a)
 Uninitialize an amatrix object. More...
 
pamatrix new_amatrix (uint rows, uint cols)
 Create a new amatrix object. More...
 
pamatrix new_sub_amatrix (pamatrix src, uint rows, uint roff, uint cols, uint coff)
 Create a new amatrix object representing a submatrix. More...
 
pamatrix new_pointer_amatrix (field *src, uint rows, uint cols)
 Create a new amatrix object using a given array for the coefficients. More...
 
pamatrix new_zero_amatrix (uint rows, uint cols)
 Create a new amatrix object representing a zero matrix. More...
 
pamatrix new_identity_amatrix (uint rows, uint cols)
 Create a new amatrix object representing the identity. More...
 
void del_amatrix (pamatrix a)
 Delete an amatrix object. More...
 
void resize_amatrix (pamatrix a, uint rows, uint cols)
 Change the dimensions of an amatrix object without preserving its coefficients. More...
 
void resizecopy_amatrix (pamatrix a, uint rows, uint cols)
 Change the dimensions of an amatrix object while preserving as many of its coefficients as possible. More...
 
field getentry_amatrix (pcamatrix a, uint row, uint col)
 Read a matrix entry $a_{ij}$. More...
 
void setentry_amatrix (pamatrix a, uint row, uint col, field x)
 Set a matrix entry, $a_{ij}\gets x$. More...
 
field addentry_amatrix (pamatrix a, uint row, uint col, field x)
 Add to a matrix entry, $a_{ij} \gets a_{ij} + x$. More...
 
uint getactives_amatrix ()
 Get number of currently initialized amatrix objects. More...
 
size_t getsize_amatrix (pcamatrix a)
 Get size of a given amatrix object. More...
 
size_t getsize_heap_amatrix (pcamatrix a)
 Get heap size of a given amatrix object. More...
 
void clear_amatrix (pamatrix a)
 Set a matrix to zero. More...
 
void clear_lower_amatrix (pamatrix a, bool strict)
 Set the lower triangular part of a matrix to zero. More...
 
void clear_upper_amatrix (pamatrix a, bool strict)
 Set the upper triangular part of a matrix to zero. More...
 
void identity_amatrix (pamatrix a)
 Set a matrix to identity. More...
 
void random_amatrix (pamatrix a)
 Fill a matrix with random values. More...
 
void random_invertible_amatrix (pamatrix a, real alpha)
 Fill a square matrix with random values and ensure that it is invertible. More...
 
void random_selfadjoint_amatrix (pamatrix a)
 Fill a matrix with random values and ensure that it is self-adjoint. More...
 
void random_spd_amatrix (pamatrix a, real alpha)
 Fill a matrix with random values and ensure that it is positive definite. More...
 
void copy_amatrix (bool atrans, pcamatrix a, pamatrix b)
 Copy a matrix into another matrix, $B \gets A$ or $B \gets A^*$. More...
 
void copy_colpiv_amatrix (bool atrans, pcamatrix a, const uint *colpiv, pamatrix b)
 Copy a matrix into another matrix, permuting the columns, i.e., $B \gets A P_\pi$ or $B \gets (A P_\pi)^*$. More...
 
pamatrix clone_amatrix (pcamatrix src)
 Create a duplicate of an existing amatrix. More...
 
void copy_sub_amatrix (bool atrans, pcamatrix a, pamatrix b)
 Copy a matrix into another matrix, $B \gets A$ or $B \gets A^*$. More...
 
void print_amatrix (pcamatrix a)
 Print a matrix. More...
 
void print_matlab_amatrix (pcamatrix a)
 Print a matrix in Matlab format. More...
 
real check_ortho_amatrix (bool atrans, pcamatrix a)
 Check whether a matrix $A$ or its adjoint $A^*$ is isometric. More...
 
void scale_amatrix (field alpha, pamatrix a)
 Scale a matrix $A$ by a factor $\alpha$, $A \gets \alpha A$. More...
 
void conjugate_amatrix (pamatrix a)
 compute the complex conjugate $ \bar A $ of a matrix $ A $. More...
 
field dotprod_amatrix (pcamatrix a, pcamatrix b)
 Compute the Frobenius inner product $\langle A, B \rangle_F$ of two matrices $A$ and $B$. More...
 
real norm2_amatrix (pcamatrix A)
 Approximate the spectral norm $\|A\|_2$ of a matrix $A$. More...
 
real normfrob_amatrix (pcamatrix a)
 Compute the Frobenius norm $\|A\|_F$ of a matrix $A$. More...
 
real normfrob2_amatrix (pcamatrix a)
 Compute the squared Frobenius norm $\|A\|_F^2$ of a matrix $A$. More...
 
real norm2diff_amatrix (pcamatrix a, pcamatrix b)
 Approximate the spectral norm $\|A-B\|_2$ of the difference of two matrices $A$ and $B$. More...
 
void addeval_amatrix_avector (field alpha, pcamatrix a, pcavector src, pavector trg)
 Multiply a matrix $A$ by a vector $x$, $y \gets y + \alpha A x$. More...
 
void addevaltrans_amatrix_avector (field alpha, pcamatrix a, pcavector src, pavector trg)
 Multiply the adjoint of a matrix $A$ by a vector $x$, $y \gets y + \alpha A^* x$. More...
 
void mvm_amatrix_avector (field alpha, bool atrans, pcamatrix a, pcavector src, pavector trg)
 Multiply a matrix $A$ or its adjoint $A^*$ by a vector, $y \gets y + \alpha A x$ or $y \gets y + \alpha A^* x$. More...
 
void add_amatrix (field alpha, bool atrans, pcamatrix a, pamatrix b)
 Add two matrices, $B \gets B + \alpha A$ or $B \gets B + \alpha A^*$. More...
 
void addmul_amatrix (field alpha, bool atrans, pcamatrix a, bool btrans, pcamatrix b, pamatrix c)
 Multiply two matrices, $C \gets C + \alpha A B$, $C \gets C + \alpha A^* B$, $C \gets C + \alpha A B^*$ or $C \gets C + \alpha A^* B^*$. More...
 
void bidiagmul_amatrix (field alpha, bool atrans, pamatrix a, pcavector d, pcavector l)
 Multiply a matrix by a bidiagonal matrix, $A \gets \alpha A L$ or $A \gets \alpha L^* A$. More...
 

Detailed Description

Representation of a matrix as an array in column-major order.

The amatrix class is used to handle standard linear algebra operations like matrix multiplication, factorization, solving linear systems or eigenvalue problems.

Function Documentation

void add_amatrix ( field  alpha,
bool  atrans,
pcamatrix  a,
pamatrix  b 
)

Add two matrices, $B \gets B + \alpha A$ or $B \gets B + \alpha A^*$.

Parameters
alphaScaling factor $\alpha$.
atransSet if $A^*$ is to be added instead of $A$.
aSource matrix $A$.
bTarget matrix $B$.
field addentry_amatrix ( pamatrix  a,
uint  row,
uint  col,
field  x 
)

Add to a matrix entry, $a_{ij} \gets a_{ij} + x$.

Parameters
aMatrix $A$.
rowRow index $i$.
colColumn index $j$.
xSummand.
Returns
New value of $a_{ij}$.
void addeval_amatrix_avector ( field  alpha,
pcamatrix  a,
pcavector  src,
pavector  trg 
)

Multiply a matrix $A$ by a vector $x$, $y \gets y + \alpha A x$.

The matrix $A$ is multiplied by the source vector $x$, the result is scaled by $\alpha$ and added to the target vector $y$.

Parameters
alphaScaling factor $\alpha$.
aMatrix $A$.
srcSource vector $x$.
trgTarget vector $y$.
void addevaltrans_amatrix_avector ( field  alpha,
pcamatrix  a,
pcavector  src,
pavector  trg 
)

Multiply the adjoint of a matrix $A$ by a vector $x$, $y \gets y + \alpha A^* x$.

The adjoint $A^*$ is multiplied by the source vector $x$, the result is scaled by $\alpha$ and added to the target vector $y$.

Parameters
alphaScaling factor $\alpha$.
aMatrix $A$.
srcSource vector $x$.
trgTarget vector $y$.
void addmul_amatrix ( field  alpha,
bool  atrans,
pcamatrix  a,
bool  btrans,
pcamatrix  b,
pamatrix  c 
)

Multiply two matrices, $C \gets C + \alpha A B$, $C \gets C + \alpha A^* B$, $C \gets C + \alpha A B^*$ or $C \gets C + \alpha A^* B^*$.

The matrices $A$ (or $A^*$) and $B$ (or $B^*$) are multiplied, the result is scaled by $\alpha$ and added to the target matrix $C$.

Parameters
alphaScaling factor $\alpha$.
atransSet if $A^*$ is to be used instead of $A$.
aLeft factor $A$.
btransSet if $B^*$ is to be used instead of $B$.
bRight factor $B$.
cTarget matrix $C$.
void bidiagmul_amatrix ( field  alpha,
bool  atrans,
pamatrix  a,
pcavector  d,
pcavector  l 
)

Multiply a matrix by a bidiagonal matrix, $A \gets \alpha A L$ or $A \gets \alpha L^* A$.

The matrix $A$ (or $A^*$) is multiplied by the lower bidiagonal matrix $L$ described by the diagonal vector $d$ and the subdiagonal vector $l$, the result is scaled by $\alpha$ and written back into $A$, i.e., $a_{ij} \gets \alpha (a_{ij} d_j + a_{i,j+1} l_j)$ or $a_{ij} \gets \alpha (\bar d_i a_{ij} + \bar l_i a_{i,j+1})$ (adding zeros to $b$ for the last column or row).

Parameters
alphaScaling factor $\alpha$.
atransSet if $A^*$ is to be used instead of $A$.
aMatrix $A$.
dDiagonal entries of $L$.
lSubdiagonal entries of $L$.
real check_ortho_amatrix ( bool  atrans,
pcamatrix  a 
)

Check whether a matrix $A$ or its adjoint $A^*$ is isometric.

Compute either $I-A^*A$ or $I-AA^*$. If the return value is small, $A$ or $A^*$ are isometric matrices. For square matrices, this also means that they are orthogonal.

Parameters
atransSet if $A^*$ is to be checked, otherwise $A$ is used.
aMatrix $A$.
Returns
$I-A^*A$ if atrans==false and $I-AA^*$ otherwise.
void clear_amatrix ( pamatrix  a)

Set a matrix to zero.

Parameters
aTarget matrix.
void clear_lower_amatrix ( pamatrix  a,
bool  strict 
)

Set the lower triangular part of a matrix to zero.

Parameters
aTarget matrix.
strictIf set, only the strict lower triangular part should be cleared.
void clear_upper_amatrix ( pamatrix  a,
bool  strict 
)

Set the upper triangular part of a matrix to zero.

Parameters
aTarget matrix.
strictIf set, only the strict upper triangular part should be cleared.
pamatrix clone_amatrix ( pcamatrix  src)

Create a duplicate of an existing amatrix.

Parameters
srcMatrix to be duplicated.
Returns
Copy of src.
void conjugate_amatrix ( pamatrix  a)

compute the complex conjugate $ \bar A $ of a matrix $ A $.

Parameters
aMatrix that will be conjugated.
void copy_amatrix ( bool  atrans,
pcamatrix  a,
pamatrix  b 
)

Copy a matrix into another matrix, $B \gets A$ or $B \gets A^*$.

The numbers of rows and columns have to match.

Parameters
atransSet if $A^*$ is to be used instead of $A$.
aSource matrix.
bTarget matrix.
void copy_colpiv_amatrix ( bool  atrans,
pcamatrix  a,
const uint colpiv,
pamatrix  b 
)

Copy a matrix into another matrix, permuting the columns, i.e., $B \gets A P_\pi$ or $B \gets (A P_\pi)^*$.

The numbers of rows and columns have to match.

Parameters
atransSet if $A^*$ is to be used instead of $A$.
aSource matrix.
colpivArray of dimension a->cols containing the column indices.
bTarget matrix.
void copy_sub_amatrix ( bool  atrans,
pcamatrix  a,
pamatrix  b 
)

Copy a matrix into another matrix, $B \gets A$ or $B \gets A^*$.

If $B$ is smaller than $A$ (or $A^*$), only the upper left part of $A$ is copied. If $A$ (or $A^*$) is smaller than $B$, only the upper left part of $B$ is filled.

Parameters
atransSet if $A^*$ is to be used instead of $A$.
aSource matrix.
bTarget matrix.
void del_amatrix ( pamatrix  a)

Delete an amatrix object.

Releases the storage corresponding to the object.

Attention
Make sure that there are no submatrix objects referring to this object, since they will otherwise keep using pointers to invalid storage.
Parameters
aObject to be deleted.
field dotprod_amatrix ( pcamatrix  a,
pcamatrix  b 
)

Compute the Frobenius inner product $\langle A, B \rangle_F$ of two matrices $A$ and $B$.

The Frobenius inner product is given by $\langle A, B \rangle_F = \sum_{i,j} \bar a_{ij} b_{ij}$.

Parameters
aMatrix $A$.
bMatrix $B$.
Returns
Frobenius inner product $\langle A, B \rangle_F$.
uint getactives_amatrix ( )

Get number of currently initialized amatrix objects.

Calls to initialization functions like init_amatrix and constructors like new_amatrix increase an internal counter, while uninit_amatrix and del_amatrix decrease it.

Remarks
Use this function to check whether a program correctly cleans up temporary variables.
Returns
Number of currently initialized amatrix objects.
field getentry_amatrix ( pcamatrix  a,
uint  row,
uint  col 
)

Read a matrix entry $a_{ij}$.

Parameters
aMatrix $A$.
rowRow index $i$.
colColumn index $j$.
Returns
Matrix entry $a_{ij}$.
size_t getsize_amatrix ( pcamatrix  a)

Get size of a given amatrix object.

Computes the size of the amatrix object and the storage allocated for the coefficients. If the object uses the coefficients of another object (e.g., if it was created using new_sub_amatrix), no coefficient storage is added.

Parameters
aMatrix object.
Returns
Size of allocated storage in bytes.
size_t getsize_heap_amatrix ( pcamatrix  a)

Get heap size of a given amatrix object.

Computes the size of storage allocated for the coefficients on the heap, but not for the amatrix object itself. If the object uses the coefficients of another object (e.g., if it was created using new_sub_amatrix), no storage is required.

Parameters
aMatrix object.
Returns
Size of allocated heap storage in bytes.
void identity_amatrix ( pamatrix  a)

Set a matrix to identity.

Sets all diagonal entries to one and all off-diagonal entries to zero. For square matrices, this yields an identity matrix.

Parameters
aTarget matrix.
pamatrix init_amatrix ( pamatrix  a,
uint  rows,
uint  cols 
)

Initialize an amatrix object.

Sets up the components of the object and allocates storage for the coefficient array.

Remarks
Should always be matched by a call to uninit_amatrix.
Parameters
aObject to be initialized.
rowsNumber of rows.
colsNumber of columns.
Returns
Initialized amatrix object.
pamatrix init_identity_amatrix ( pamatrix  a,
uint  rows,
uint  cols 
)

Initialize an amatrix object and set it to identity.

Sets up the components of the object, allocates storage for the coefficient array, sets the diagonal to one and all off-diagonal entries to zero. For square matrices, this yields an identity matrix.

Remarks
Should always be matched by a call to uninit_amatrix.
Parameters
aObject to be initialized.
rowsNumber of rows.
colsNumber of columns.
Returns
Initialized amatrix object.
pamatrix init_pointer_amatrix ( pamatrix  a,
pfield  src,
uint  rows,
uint  cols 
)

Initialize an amatrix object using a given array for the coefficients.

Sets up the components of the object and uses the given array to represent the coefficients.

Remarks
Should always be matched by a call to uninit_amatrix that will not release the coefficient storage.
Parameters
aObject to be initialized.
srcSource array, should contain at least rows * cols elements.
rowsNumber of rows.
colsNumber of columns.
Returns
Initialized amatrix object.
pamatrix init_sub_amatrix ( pamatrix  a,
pamatrix  src,
uint  rows,
uint  roff,
uint  cols,
uint  coff 
)

Initialize an amatrix object to represent a submatrix.

Sets up the components of the object and uses part of the storage of another amatrix for the coefficient array, leading to a new matrix representing a submatrix of the source. Changes to the coefficients of the new matrix also change coefficients of the source matrix.

Remarks
Should always be matched by a call to uninit_amatrix that will not release the coefficient storage.
Parameters
aObject to be initialized.
srcSource matrix.
rowsNumber of rows.
roffRow offset, should satisfy rows+roff<=src->rows.
colsNumber of columns.
coffColumn offset, should satisfy cols+coff<=src->cols.
Returns
Initialized amatrix object.
pamatrix init_vec_amatrix ( pamatrix  a,
pavector  src,
uint  rows,
uint  cols 
)

Initialize an amatrix object by a vector.

Sets up the components of the object and uses part of the storage of an avector in order to represent the matrix.

Remarks
Should always be matched by a call to uninit_amatrix that will not release the coefficient storage.
Parameters
aObject to be initialized.
srcSource vector.
rowsNumber of rows.
colsNumber of columns.
Returns
Initialized amatrix object.
pamatrix init_zero_amatrix ( pamatrix  a,
uint  rows,
uint  cols 
)

Initialize an amatrix object and set it to zero.

Sets up the components of the object, allocates storage for the coefficient array, and sets it to zero.

Remarks
Should always be matched by a call to uninit_amatrix.
Parameters
aObject to be initialized.
rowsNumber of rows.
colsNumber of columns.
Returns
Initialized amatrix object.
void mvm_amatrix_avector ( field  alpha,
bool  atrans,
pcamatrix  a,
pcavector  src,
pavector  trg 
)

Multiply a matrix $A$ or its adjoint $A^*$ by a vector, $y \gets y + \alpha A x$ or $y \gets y + \alpha A^* x$.

The matrix or its adjoint is multiplied by the source vector $x$, the result is scaled by $\alpha$ and added to the target vector $y$.

Parameters
alphaScaling factor $\alpha$.
atransSet if $A^*$ is to be used instead of $A$.
aMatrix $A$.
srcSource vector $x$.
trgTarget vector $y$.
pamatrix new_amatrix ( uint  rows,
uint  cols 
)

Create a new amatrix object.

Allocates storage for the object and sets up its components.

Remarks
Should always be matched by a call to del_amatrix.
Parameters
rowsNumber of rows.
colsNumber of columns.
Returns
New amatrix object.
pamatrix new_identity_amatrix ( uint  rows,
uint  cols 
)

Create a new amatrix object representing the identity.

Allocates storage for the object and sets diagonal entries to one and off-diagonal entries to zero. For square matrices, this yields an identity matrix.

Remarks
Should always be matched by a call to del_amatrix.
Parameters
rowsNumber of rows.
colsNumber of columns.
Returns
New amatrix object.
pamatrix new_pointer_amatrix ( field src,
uint  rows,
uint  cols 
)

Create a new amatrix object using a given array for the coefficients.

Parameters
srcSource array, should contain at least rows * cols elements.
rowsNumber of rows for the new matrix.
colsNumber of columns for the new matrix.
Returns
New amatrix object.
pamatrix new_sub_amatrix ( pamatrix  src,
uint  rows,
uint  roff,
uint  cols,
uint  coff 
)

Create a new amatrix object representing a submatrix.

Allocates storage for the object, but uses part of the storage of another amatrix object to keep the coefficients. Since the leading dimension of the source matrix is used, this allows us to work with a rectangular submatrix of the original matrix.

Remarks
Should always be matched by a call to del_amatrix that will not release the coefficient storage.
Parameters
srcSource matrix.
rowsNumber of rows.
roffRow offset, should satisfy rows+roff<=src->rows.
colsNumber of columns.
coffColumn offset, should satisfy cols+coff<=src->cols.
Returns
New amatrix object.
pamatrix new_zero_amatrix ( uint  rows,
uint  cols 
)

Create a new amatrix object representing a zero matrix.

Allocates storage for the object and sets all coefficients to zero.

Remarks
Should always be matched by a call to del_amatrix.
Parameters
rowsNumber of rows.
colsNumber of columns.
Returns
New amatrix object.
real norm2_amatrix ( pcamatrix  A)

Approximate the spectral norm $\|A\|_2$ of a matrix $A$.

The spectral norm is approximated by applying a few steps of the power iteration to the matrix $A^* A$ and computing the square root of the resulting eigenvalue approximation.

Parameters
ADense matrix $A$.
Returns
Approximation of $\|A\|_2$.
real norm2diff_amatrix ( pcamatrix  a,
pcamatrix  b 
)

Approximate the spectral norm $\|A-B\|_2$ of the difference of two matrices $A$ and $B$.

The spectral norm is approximated by applying a few steps of the power iteration to the matrix $(A-B)^* (A-B)$ and computing the square root of the resulting eigenvalue approximation.

Parameters
aDense matrix $A$.
bDense matrix $B$.
Returns
Approximation of $\|A-B\|_2$.
real normfrob2_amatrix ( pcamatrix  a)

Compute the squared Frobenius norm $\|A\|_F^2$ of a matrix $A$.

The Frobenius norm is given by $\|A\|_F^2 = \sum_{i,j} |a_{ij}|^2$.

Parameters
aMatrix $A$.
Returns
Squared Frobenius norm $\|A\|_F^2$.
real normfrob_amatrix ( pcamatrix  a)

Compute the Frobenius norm $\|A\|_F$ of a matrix $A$.

The Frobenius norm is given by $\|A\|_F = \left( \sum_{i,j} |a_{ij}|^2 \right)^{1/2}$.

Parameters
aMatrix $A$.
Returns
Frobenius norm $\|A\|_F$.
void print_amatrix ( pcamatrix  a)

Print a matrix.

Parameters
aMatrix object.
void print_matlab_amatrix ( pcamatrix  a)

Print a matrix in Matlab format.

Parameters
aMatrix object.
void random_amatrix ( pamatrix  a)

Fill a matrix with random values.

Parameters
aTarget matrix.
void random_invertible_amatrix ( pamatrix  a,
real  alpha 
)

Fill a square matrix with random values and ensure that it is invertible.

First the matrix is filled with random values, then the diagonal elements are set to $a_{ii} \gets \alpha + \sum_{j=1}^n |a_{ij}|$, ensuring that $A$ is diagonal dominant and therefore invertible.

Parameters
aTarget matrix.
alphaDiagonal shift $\alpha$, should be a positive number.
void random_selfadjoint_amatrix ( pamatrix  a)

Fill a matrix with random values and ensure that it is self-adjoint.

Parameters
aTarget matrix.
void random_spd_amatrix ( pamatrix  a,
real  alpha 
)

Fill a matrix with random values and ensure that it is positive definite.

First the matrix is filled with random values, ensuring that it becomes self-adjoint. Then the diagonal elements are set to $a_{ii} \gets \alpha + \sum_{j=1}^n |a_{ij}|$, ensuring that $A$ is diagonal dominant and therefore positiv definite.

Parameters
aTarget matrix.
alphaDiagonal shift $\alpha$, should be a positiv number.
void resize_amatrix ( pamatrix  a,
uint  rows,
uint  cols 
)

Change the dimensions of an amatrix object without preserving its coefficients.

Allocates new storage for the coefficients and releases the old storage.

Attention
Make sure that there are no submatrix objects referring to this object, since they might otherwise keep using pointers to invalid storage.
Parameters
aMatrix to be resized.
rowsNew number of rows.
colsNew number of columns.
void resizecopy_amatrix ( pamatrix  a,
uint  rows,
uint  cols 
)

Change the dimensions of an amatrix object while preserving as many of its coefficients as possible.

Allocates new storage for the coefficients and copies as many of the old coefficients into it. If there are more rows or columns in the new matrix, the additional coefficients are left unintialized.

Attention
Make sure that there are no submatrix objects referring to this object, since they might otherwise keep using pointers to invalid storage.
Parameters
aMatrix to be resized.
rowsNew number of rows.
colsNew number of columns.
void scale_amatrix ( field  alpha,
pamatrix  a 
)

Scale a matrix $A$ by a factor $\alpha$, $A \gets \alpha A$.

Parameters
alphaScaling factor $\alpha$.
aTarget matrix $A$.
void setentry_amatrix ( pamatrix  a,
uint  row,
uint  col,
field  x 
)

Set a matrix entry, $a_{ij}\gets x$.

Parameters
aMatrix $A$.
rowRow index $i$.
colColumn index $j$.
xNew value of $a_{ij}$.
void uninit_amatrix ( pamatrix  a)

Uninitialize an amatrix object.

Invalidates pointers, freeing corresponding storage if appropriate, and prepares the object for deletion.

Parameters
aObject to be uninitialized.