jonathanfishbein1/linear-algebra/14.2.0

NOTE: the latest version is 30.0.0

Matrix

A module for Matrix

Types

type RowVector a
= RowVector (Vector a)

Row Vector

= ColumnVector (Vector a)

Column Vector

type Matrix a
= Matrix (List (RowVector a))

Matrix type

type Solution a
= UniqueSolution (ColumnVector a)
| InfiniteSolutions
{ nullity : Int
, rank : Int
}

Type to represent result of Gauss-Jordan reduction if system is consistant

= Consistant (Solution a)
| Inconsistant String

Type to represent result of Gauss-Jordan reduction

= VectorDimension Int

Type to represent vector space such as R, R2, R3

Square Matrix type

Invertable Matrix type

Hermitian Matrix type

Unitary Matrix type

Constructors

squareMatrix : Matrix a -> Result String (SquareMatrix a)

Construct a Square Matrix

realInvertableMatrix : SquareMatrix Float -> Result String (InvertableMatrix Float)

Construct a Real numbered Invertable Matrix

-> Result String (DoublyStochasticMatrix Float)

Construct a Doubly Stochastic Matrix

SquareMatrix (ComplexNumber Float)
-> Result String (InvertableMatrix (ComplexNumber Float))

Construct a Complex numbered Invertable Matrix

SquareMatrix (ComplexNumber Float)
-> Result String (HermitianMatrix (ComplexNumber Float))

Construct a Hermitian Matrix

InvertableMatrix (ComplexNumber Float)
-> Result String (UnitaryMatrix (ComplexNumber Float))

Construct an Unitary Matrix

Values

identity : Field a -> Int -> Matrix a

Create Identity Matrix with n dimension

zeros : Field a -> Int -> Int -> Matrix a

Create Matrix with m x n dimension filled with zeros

zeroSquareMatrix : Field a -> Int -> Matrix a

Create square Matrix with n dimension filled with zeros

Unitary Operations

scalarMultiplication : Field a -> a -> Matrix a -> Matrix a

Scalar multiplication over a Matrix

Transpose a Matrix

conjugate : Matrix (ComplexNumber number) -> Matrix (ComplexNumber number)

Take the complex conjugate of a Complex Numbered Matrix

adjoint : Matrix (ComplexNumber number) -> Matrix (ComplexNumber number)

Perform the adjoint operation on a Complex Numbered Matrix

invert : InnerProductSpace a -> SquareMatrix a -> Result String (Matrix a)

Try to calculate the inverse of a matrix

subMatrix : Int -> Int -> Int -> Int -> Matrix a -> Matrix a

Calculate the submatrix given a starting and ending row and column index

nullSpace : InnerProductSpace a -> Matrix a -> Consistancy a

Calculate the null space of a matrix

determinant : VectorSpace a -> InvertableMatrix a -> Result String a

Try to calculate the determinant

normReal : Matrix Float -> Result String Float

Calculate the norm of a Matrix

normComplex : Matrix (ComplexNumber Float) -> Result String Float

Calculate the norm of a Matrix

leftNullSpace : InnerProductSpace a -> Matrix a -> Consistancy a

Calculate the left nullspace of a Matrix

getDiagonal : Matrix a -> Maybe (List a)

Get the diagonal of a Matrix

getDiagonalProduct : Field a -> Matrix a -> Maybe a

Get the Product of the diagonal of a Matrix

rank : InnerProductSpace a -> Matrix a -> Int

Calculate the rank of a Matrix

Create a Matrix from a list of Column Vectors

Binary Operations

add : Field a -> Matrix a -> Matrix a -> Matrix a

Add two Matrices together

subtract : Field a -> Matrix a -> Matrix a -> Matrix a

Subtract two Matrices

InnerProductSpace a
-> Matrix a
-> Vector a
-> Result String (Vector a)

Multiply a Vector by a Matrix

InnerProductSpace a
-> Matrix a
-> Matrix a
-> Result String (Matrix a)

Matrix Matrix multiplication

dotProduct : InnerProductSpace a -> Matrix a -> Matrix a -> Result String a

Calculate the dot product of two Matricies

tensorProduct : Field a -> Matrix a -> Matrix a -> Matrix a

Calculate the tensor product of two Matricies

InnerProductSpace a
-> Matrix a
-> Matrix a
-> Result String (Matrix a)

Calculate the commuter of two Hermitian Matricies

Matrix Predicates and Properties

Determine whether a matirx is square

Predicate to determine if Matrix is symmetric

isHermitian : SquareMatrix (ComplexNumber number) -> Bool

Predicate to determine if Matrix is Hermitian

isOnto : InnerProductSpace a -> Matrix a -> Result String (Matrix a)

Determine whether a matirx is onto

isOneToOne : InnerProductSpace a -> Matrix a -> Result String (Matrix a)

Determine whether a matirx is one to one

isInvertable : InnerProductSpace a -> SquareMatrix a -> Result String (Matrix a)

Determine whether a matirx is invertable

isUnitary : InvertableMatrix (ComplexNumber Float) -> Bool

Determine whether a matirx is unitary

areBasis : InnerProductSpace a -> VectorDimension -> List (Vector a) -> Bool

Determine whether list of vectors are a basis for a space

areLinearlyIndependent : InnerProductSpace a -> List (Vector a) -> Bool

Predicate to determine if a list of Vectors are linearly independent

VectorSpace a
-> List (Vector a)
-> Result String Bool

Determine whether list of vectors spans a space

mDimension : Matrix a -> Int

Number of rows in Matrix

nDimension : Matrix a -> Int

Number of columns in Matrix

isRightStochastic : Matrix Float -> Bool

Predicate if matrix is right stochastic

isLeftStochastic : Matrix Float -> Bool

Predicate if matrix is left stochastic

Predicate if matrix is doubly stochastic

areRowEquivalent : VectorSpace a -> Matrix a -> Matrix a -> Bool

Predicate to determine if two matricies are row equivalent

Semigroup, Monoid, Group, Ring, Field, VectorSpace, InnerProductSpace

Monoid empty for Vector

Monoidally append Matricies together horizontally

concatVertical : Monoid (Matrix a)

Monoidally append Matricies together vertically

realMatrixAdditionCommutativeSemigroup : CommutativeSemigroup (Matrix Float)

Commutative Semigroup instance for Matrix under the addition operation with real values.

complexMatrixAdditionCommutativeSemigroup : CommutativeSemigroup (Matrix (ComplexNumber Float))

Commutative Semigroup instance for Matrix under the addition operation with complex values.

realMatrixAdditionCommutativeMonoid : CommutativeMonoid (Matrix Float)

Commutative Monoid instance for Matrix under the addition operation with real values.

complexMatrixAdditionCommutativeMonoid : CommutativeMonoid (Matrix (ComplexNumber Float))

Commutative Monoid instance for Matrix under the addition operation with complex values.

realMatrixAlgebra : MatrixAlgebra Float

Real Numbered Matrix Algebra

realMatrixInnerProductSpace : InnerProductSpace Float

Real Numbered Inner Product Space for Matrix

complexMatrixAdditionAbelianGroup : AbelianGroup (Matrix (ComplexNumber Float))

Abelian Group instance for Matrix under the addition operation with complex values.

Functor, Applicative, Monad, Foldable

map : (a -> b) -> Matrix a -> Matrix b

Map over a Matrix

pure : a -> Matrix a

Applicative pure for Matrix

andMap : Matrix a -> Matrix (a -> b) -> Matrix b

Apply for Matrix

andThen : (a -> Matrix b) -> Matrix a -> Matrix b

Monad bind for Matrix

map2 : (a -> b -> c) -> Matrix a -> Matrix b -> Matrix c

Lift a binary function to work on Matrix

foldl : (a -> b -> b) -> b -> Matrix a -> b

Left fold over a Matrix

Equality

equal : (a -> a -> Bool) -> Matrix a -> Matrix a -> Bool

Compare two matricies using comparator

Matrix Forms

upperTriangle : VectorSpace a -> Matrix a -> Matrix a

Put a matrix into Upper Triangular Form

gaussianReduce : VectorSpace a -> Matrix a -> Matrix a

Gaussian Elimination

jordanReduce : VectorSpace a -> Matrix a -> Matrix a

Internal function for Jordan Elimination

gaussJordan : VectorSpace a -> Matrix a -> Matrix a

Function composition of Gaussian Elimination and Jordan Elimination

Solving

solve : InnerProductSpace a -> Matrix a -> ColumnVector a -> Consistancy a

Solve a system of linear equations using Gauss-Jordan elimination with explict column vector of constants

solveMatrix : InnerProductSpace a -> Matrix a -> Consistancy a

Solve a system of linear equations using Gauss-Jordan elimination

Manipulation

getAt : ( Int, Int ) -> Matrix a -> Maybe a

Get the value in a matrix at the specified row and column

setAt : ( Int, Int ) -> a -> Matrix a -> Matrix a

Set the value in a Matrix at the specified row and column

printRealMatrix : Matrix Float -> String

Print a Real matrix to a string

printComplexMatrix : Matrix (ComplexNumber Float) -> String

Print a Complex matrix to a string

readRealMatrix : String -> Result (List DeadEnd) (Matrix Float)

Try to read a string into a Matrix

readComplexMatrix : String -> Result (List DeadEnd) (Matrix (ComplexNumber Float))

Try to read a string into a Matrix