libcrystfel 0.11.0
Loading...
Searching...
No Matches
Typedefs | Functions
integer_matrix.h File Reference

Typedefs

typedef struct _integermatrix IntegerMatrix
 

Functions

IntegerMatrixintmat_new (unsigned int rows, unsigned int cols)
 
IntegerMatrixintmat_copy (const IntegerMatrix *m)
 
IntegerMatrixintmat_identity (int size)
 
void intmat_free (IntegerMatrix *m)
 
void intmat_size (const IntegerMatrix *m, unsigned int *rows, unsigned int *cols)
 
void intmat_set (IntegerMatrix *m, unsigned int i, unsigned int j, signed int v)
 
signed int intmat_get (const IntegerMatrix *m, unsigned int i, unsigned int j)
 
void intmat_zero (IntegerMatrix *m)
 
IntegerMatrixintmat_create_3x3 (signed int m11, signed int m12, signed int m13, signed int m21, signed int m22, signed int m23, signed int m31, signed int m32, signed int m33)
 
signed int * transform_indices (const IntegerMatrix *P, const signed int *hkl)
 
IntegerMatrixintmat_times_intmat (const IntegerMatrix *a, const IntegerMatrix *b)
 
IntegerMatrixintmat_inverse (const IntegerMatrix *m)
 
signed int intmat_det (const IntegerMatrix *m)
 
int intmat_is_identity (const IntegerMatrix *m)
 
int intmat_is_inversion (const IntegerMatrix *m)
 
int intmat_equals (const IntegerMatrix *a, const IntegerMatrix *b)
 
void intmat_print (const IntegerMatrix *m)
 

Detailed Description

Matrix type containing only integers

Typedef Documentation

◆ IntegerMatrix

typedef struct _integermatrix IntegerMatrix

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

Function Documentation

◆ intmat_copy()

IntegerMatrix * intmat_copy ( const IntegerMatrix m)
Parameters
mAn IntegerMatrix
Returns
A newly allocated copy of m, or NULL on error

◆ intmat_create_3x3()

IntegerMatrix * intmat_create_3x3 ( signed int  m11,
signed int  m12,
signed int  m13,
signed int  m21,
signed int  m22,
signed int  m23,
signed int  m31,
signed int  m32,
signed int  m33 
)
Parameters
m11Matrix element
m12Matrix element
m13Matrix element
m21Matrix element
m22Matrix element
m23Matrix element
m31Matrix element
m32Matrix element
m33Matrix element
Returns
A newly allocated 3x3 IntegerMatrix with the given values.

◆ intmat_det()

signed int intmat_det ( const IntegerMatrix m)
Parameters
mAn IntegerMatrix

Calculates the determinant of m. Inefficiently.

Returns
The determinant of m.

◆ intmat_equals()

int intmat_equals ( const IntegerMatrix a,
const IntegerMatrix b 
)
Parameters
aAn IntegerMatrix
bAn IntegerMatrix
Returns
True if a = b.

◆ intmat_free()

void intmat_free ( IntegerMatrix m)
Parameters
mAn IntegerMatrix

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

◆ intmat_get()

signed int intmat_get ( const IntegerMatrix m,
unsigned int  i,
unsigned int  j 
)
Parameters
mAn IntegerMatrix
icolumn number to set
jrow number to set

Gets the i,j element of m.

Returns
The i,j element of m.

◆ intmat_identity()

IntegerMatrix * intmat_identity ( int  size)
Parameters
sizeThe size of the (square) matrix
Returns
An identity IntegerMatrix with side length size, or NULL on error.

◆ intmat_inverse()

IntegerMatrix * intmat_inverse ( const IntegerMatrix m)
Parameters
mAn IntegerMatrix

Calculates the inverse of m. Inefficiently.

Works only if the inverse of the matrix is also an integer matrix, i.e. if the determinant of m is +/- 1.

Returns
The inverse of m, or NULL on error.

◆ intmat_is_identity()

int intmat_is_identity ( const IntegerMatrix m)
Parameters
mAn IntegerMatrix
Returns
True if m is an identity matrix.

◆ intmat_is_inversion()

int intmat_is_inversion ( const IntegerMatrix m)
Parameters
mAn IntegerMatrix
Returns
True if m = -I, where I is an identity matrix.

◆ intmat_new()

IntegerMatrix * intmat_new ( unsigned int  rows,
unsigned int  cols 
)
Parameters
rowsNumber of rows that the new matrix is to have
colsNumber of columns that the new matrix is to have

Allocates a new IntegerMatrix with all elements set to zero.

Returns
A new IntegerMatrix, or NULL on error.

◆ intmat_print()

void intmat_print ( const IntegerMatrix m)
Parameters
mAn IntegerMatrix

Prints

Parameters
mto stderr.

◆ intmat_set()

void intmat_set ( IntegerMatrix m,
unsigned int  i,
unsigned int  j,
signed int  v 
)
Parameters
mAn IntegerMatrix
irow number to set
jcolumn number to set
vvalue to set to

Sets the i,j element of m to v.

◆ intmat_size()

void intmat_size ( const IntegerMatrix m,
unsigned int *  rows,
unsigned int *  cols 
)
Parameters
mAn IntegerMatrix
rowsLocation to store number of rows
colsLocation to store number of columns

Sets rows and cols to the size of m.

◆ intmat_times_intmat()

IntegerMatrix * intmat_times_intmat ( const IntegerMatrix a,
const IntegerMatrix b 
)
Parameters
aAn IntegerMatrix
bAn IntegerMatrix

Multiplies the matrix a by the matrix b.

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

◆ transform_indices()

signed int * transform_indices ( const IntegerMatrix P,
const signed int *  hkl 
)
Parameters
PAn IntegerMatrix
hklAn array of signed integers

Apply transformation matrix P to a set of reciprocal space Miller indices.

In other words: Multiplies the matrix P by the row vector hkl. The size of vec must equal the number of columns in P, and the size of the result equals the number of rows in P.

The multiplication looks like this: (a1, a2, a3) = (hkl1, hkl2, hkl3) P Therefore matching the notation in ITA chapter 5.1.

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