Integer matrices

Integer matrices — Integer matrices

Functions

Types and Values

typedef IntegerMatrix

Includes

#include "integer_matrix.h"

Description

An integer matrix library

Functions

intmat_new ()

IntegerMatrix *
intmat_new (unsigned int rows,
            unsigned int cols);

Allocates a new IntegerMatrix with all elements set to zero.

Parameters

rows

Number of rows that the new matrix is to have

 

cols

Number of columns that the new matrix is to have

 

Returns

a new IntegerMatrix, or NULL on error.


intmat_copy ()

IntegerMatrix *
intmat_copy (IntegerMatrix *m);

Parameters

m

An IntegerMatrix

 

Returns

a newly allocated copy of m , or NULL on error/


intmat_identity ()

IntegerMatrix *
intmat_identity (int size);

Parameters

size

The size of the (square) matrix

 

Returns

an identity IntegerMatrix with side length size , or NULL on error.


intmat_free ()

void
intmat_free (IntegerMatrix *m);

Frees m , unless m is NULL in which case nothing is done.

Parameters

m

An IntegerMatrix

 

intmat_get ()

signed int
intmat_get (const IntegerMatrix *m,
            unsigned int i,
            unsigned int j);

Gets the i ,j element of m .

Parameters

m

An IntegerMatrix

 

i

column number to set

 

j

row number to set

 

Returns

the i ,j element of m .


intmat_set ()

void
intmat_set (IntegerMatrix *m,
            unsigned int i,
            unsigned int j,
            signed int v);

Sets the i ,j element of m to v .

Parameters

m

An IntegerMatrix

 

i

row number to set

 

j

column number to set

 

v

value to set to

 

intmat_intmat_mult ()

IntegerMatrix *
intmat_intmat_mult (const IntegerMatrix *a,
                    const IntegerMatrix *b);

Multiplies the matrix a by the matrix b .

Parameters

a

An IntegerMatrix

 

b

An IntegerMatrix

 

Returns

a newly allocated IntegerMatrix containing the answer, or NULL on error.


intmat_intvec_mult ()

signed int *
intmat_intvec_mult (const IntegerMatrix *m,
                    const signed int *vec);

Multiplies the matrix m by the vector vec . The size of vec must equal the number of columns in m , and the size of the result equals the number of rows in m .

Parameters

m

An IntegerMatrix

 

vec

An array of signed integers

 

Returns

a newly allocated array of signed integers containing the answer, or NULL on error.


intmat_det ()

signed int
intmat_det (const IntegerMatrix *m);

Calculates the determinant of m . Inefficiently.

Parameters

m

An IntegerMatrix

 

Returns

the determinant of m .


intmat_inverse ()

IntegerMatrix *
intmat_inverse (const IntegerMatrix *m);

Calculates the inverse of m . Inefficiently.

Parameters

m

An IntegerMatrix

 

Returns

the inverse of m , or NULL on error.


intmat_equals ()

int
intmat_equals (const IntegerMatrix *a,
               const IntegerMatrix *b);

Parameters

a

An IntegerMatrix

 

b

An IntegerMatrix

 

Returns

true if a = b .


intmat_is_identity ()

int
intmat_is_identity (const IntegerMatrix *m);

Parameters

m

An IntegerMatrix

 

Returns

true if m is an identity matrix.


intmat_is_inversion ()

int
intmat_is_inversion (const IntegerMatrix *m);

Parameters

m

An IntegerMatrix

 

Returns

true if m = -I, where I is an identity matrix.


intmat_print ()

void
intmat_print (const IntegerMatrix *m);

Prints m to stderr.

Parameters

m

An IntegerMatrix

 

Types and Values

IntegerMatrix

typedef struct _integermatrix IntegerMatrix;

The IntegerMatrix is an opaque data structure representing an integer matrix.