Simple Matrix Arithmetic
1 Introduction
matrix?
column
2 Arithmetic
matrix+
matrix*
matrix-expt
transpose
determinant
3 Utilities
adjugate
invert-matrix
8.12

Simple Matrix Arithmetic🔗ℹ

Deren Dohoda <deren.dohoda@gmail.com>

 (require simple-matrix) package: simple-matrix

1 Introduction🔗ℹ

This library is used to perform some simple matrix arithmetic like multiplication, transposition, addition, and inversion. It is truly "simple" and very naive in its implementation but it will do its job without much overhead from typed racket.

Matrices are represented as lists of rows, which are lists of numbers. So a 3x3 identity matrix would look like '((1 0 0) (0 1 0) (0 0 1)).

procedure

(matrix? maybe-m)  boolean?

  maybe-m : any/c
Determines if the argument is a matrix in the sense this library understands.

procedure

(column vector)  matrix?

  vector : (listof number?)
A convenience for turning a simple list of numbers into a column vector.

Example:
> (column '(1 2 -2))

'((1) (2) (-2))

2 Arithmetic🔗ℹ

procedure

(matrix+ m ...)  matrix?

  m : matrix?
Adds two matricies element-wise.

procedure

(matrix* m ...)  matrix?

  m : matrix?
Multiplies two matrices using matrix multiplication. It is an error if the sizes do not correspond to proper matrix multiplication.

procedure

(matrix-expt m e)  matrix?

  m : matrix?
  e : nonnegative-integer?
Repeated multiplication of a matrix.

procedure

(transpose m)  matrix?

  m : matrix?
Exchange rows and columns of a matrix.

procedure

(determinant m)  number?

  m : matrix?
Calculate the determinant of a matrix.

3 Utilities🔗ℹ

procedure

(adjugate m)  matrix?

  m : matrix?
The transpose of the cofactor matrix. Not efficiently calculated.

procedure

(invert-matrix m)  (or/c matrix? boolean?)

  m : matrix?
Attempts to invert a matrix. If the matrix has no inverse, then this procedure evaluates to #f.