constructive-algebra-0.3.0: A library of constructive algebra.

Algebra.Matrix

Description

A small simple matrix library.

Synopsis

Documentation

newtype Vector r Source

Row vectors

Constructors

Vec [r] 

Instances

Functor Vector 
Eq r => Eq (Vector r) 
Show r => Show (Vector r) 
Arbitrary r => Arbitrary (Vector r) 

unVec :: Vector r -> [r]Source

newtype Matrix r Source

Matrices

Constructors

M [Vector r] 

Instances

Functor Matrix 
Eq r => Eq (Matrix r) 
Show r => Show (Matrix r) 
Arbitrary r => Arbitrary (Matrix r) 

matrix :: [[r]] -> Matrix rSource

Construct a mxn matrix.

unMVec :: Matrix r -> [[r]]Source

unM :: Matrix r -> [Vector r]Source

(!!!) :: Matrix a -> (Int, Int) -> aSource

identity :: IntegralDomain r => Int -> Matrix rSource

Construct a nxn identity matrix.

mulM :: Ring r => Matrix r -> Matrix r -> Matrix rSource

Matrix multiplication.

addM :: Ring r => Matrix r -> Matrix r -> Matrix rSource

Matrix addition.

transpose :: Matrix r -> Matrix rSource

Transpose a matrix.

dimension :: Matrix r -> (Int, Int)Source

Compute the dimension of a matrix.

scale :: CommutativeRing a => Matrix a -> Int -> a -> Matrix aSource

Scale a row in a matrix.

swap :: Matrix a -> Int -> Int -> Matrix aSource

Swap two rows of a matrix.

pivot :: CommutativeRing a => Matrix a -> a -> Int -> Int -> Matrix aSource

findPivot :: (CommutativeRing a, Eq a) => Matrix a -> (Int, Int) -> Maybe (a, Int)Source

forwardElim :: (Field a, Eq a) => (Matrix a, Vector a) -> (Matrix a, Vector a)Source

Compute row echelon form of a system Ax=b.

gaussElim :: (Field a, Eq a, Show a) => (Matrix a, Vector a) -> (Matrix a, Vector a)Source

Gauss-Jordan elimination: Given A and B solve Ax=B.