halg-matrices-0.6.0.0: Abstraction layer ror various matrix libraries, part of halg computational algebra suite.

Algebra.Matrix.Generic.Mutable

Synopsis

# Documentation

class (Vector (Column mat) a, Vector (Row mat) a) => MMatrix mat a where Source #

Mutable, row-based 0-origin matrix

Minimal complete definition

Methods

basicUnsafeNew :: PrimMonad m => Size -> Size -> m (mat (PrimState m) a) Source #

basicUnsafeNew n m creates a mutable matrix with n rows and m columns, without initialisation. This method should not be used directly, use unsafeNew instead.

basicInitialise :: PrimMonad m => mat (PrimState m) a -> m () Source #

basicRowCount :: mat s a -> Size Source #

basicColumnCount :: mat s a -> Size Source #

unsafeGetRow :: PrimMonad m => Index -> mat (PrimState m) a -> m (Row mat a) Source #

unsafeGetColumn :: PrimMonad m => Index -> mat (PrimState m) a -> m (Column mat a) Source #

unsafeFill :: PrimMonad m => Size -> Size -> a -> m (mat (PrimState m) a) Source #

unsafeFromRow :: PrimMonad m => Row mat a -> m (mat (PrimState m) a) Source #

Construct a mutable matrix consisting of a single row, perhaps without any copy.

unsafeFromRows :: PrimMonad m => [Row mat a] -> m (mat (PrimState m) a) Source #

Construct a mutable matrix consisting a single column, perhaps without any copy.

unsafeFromColumn :: PrimMonad m => Column mat a -> m (mat (PrimState m) a) Source #

Construct a mutable matrix consisting a single column, perhaps without any copy.

unsafeFromColumns :: PrimMonad m => [Column mat a] -> m (mat (PrimState m) a) Source #

unsafeCopy :: PrimMonad m => mat (PrimState m) a -> mat (PrimState m) a -> m () Source #

usnafeCopy target source copies the content of source to target, without boundary check.

unsafeRead :: PrimMonad m => mat (PrimState m) a -> Index -> Index -> m a Source #

unsafeRead i j m reads the value at ith row in jth column in m, without boundary check.

N.B. Rows and columns are regarded as zero-origin, not 1!.

unsafeWrite :: PrimMonad m => mat (PrimState m) a -> Index -> Index -> a -> m () Source #

basicSet :: PrimMonad m => mat (PrimState m) a -> a -> m () Source #

basicUnsafeIMapRowM :: PrimMonad m => mat (PrimState m) a -> Index -> (Index -> a -> m a) -> m () Source #

basicUnsafeIMapRow :: PrimMonad m => mat (PrimState m) a -> Index -> (Index -> a -> a) -> m () Source #

basicUnsafeSwapRows :: PrimMonad m => mat (PrimState m) a -> Index -> Index -> m () Source #

unsafeScaleRow :: (PrimMonad m, Commutative a) => mat (PrimState m) a -> Index -> a -> m () Source #

unsafeGenerate :: PrimMonad m => Size -> Size -> (Index -> Index -> a) -> m (mat (PrimState m) a) Source #

unsafeGenerateM :: PrimMonad m => Size -> Size -> (Index -> Index -> m a) -> m (mat (PrimState m) a) Source #

toRows :: PrimMonad m => mat (PrimState m) a -> m [Row mat a] Source #

toColumns :: PrimMonad m => mat (PrimState m) a -> m [Column mat a] Source #

combineRows :: (Semiring a, Commutative a, PrimMonad m) => Index -> a -> Index -> mat (PrimState m) a -> m () Source #

combineRows i c j mat adds scalar multiple of jth row by c to ith.

#### Instances

Instances details

type Index = Int Source #

type Size = Int Source #

type family Column (mat :: k) :: Type -> Type Source #

#### Instances

Instances details
 type Column STMatrix Source # Instance detailsDefined in Algebra.Matrix.HMatrix type Column STMatrix = Vector type Column MIMMatrix Source # Instance detailsDefined in Algebra.Matrix.IntMap type Column Matrix Source # Instance detailsDefined in Algebra.Matrix.DataMatrix type Column Matrix = Vector type Column Matrix Source # Instance detailsDefined in Algebra.Matrix.HMatrix type Column Matrix = Vector type Column IMMatrix Source # Instance detailsDefined in Algebra.Matrix.IntMap type Column IMMatrix = Vector type Column (WrapImmutable mat :: Type -> k -> Type) Source # Instance detailsDefined in Algebra.Matrix.Generic type Column (WrapImmutable mat :: Type -> k -> Type) = Column mat

type family Row (mat :: k) :: Type -> Type Source #

#### Instances

Instances details
 type Row STMatrix Source # Instance detailsDefined in Algebra.Matrix.HMatrix type Row STMatrix = Vector type Row MIMMatrix Source # Instance detailsDefined in Algebra.Matrix.IntMap type Row MIMMatrix = Vector type Row Matrix Source # Instance detailsDefined in Algebra.Matrix.DataMatrix type Row Matrix = Vector type Row Matrix Source # Instance detailsDefined in Algebra.Matrix.HMatrix type Row Matrix = Vector type Row IMMatrix Source # Instance detailsDefined in Algebra.Matrix.IntMap type Row IMMatrix = Vector type Row (WrapImmutable mat :: Type -> k -> Type) Source # Instance detailsDefined in Algebra.Matrix.Generic type Row (WrapImmutable mat :: Type -> k -> Type) = Row mat

new :: (MMatrix mat a, PrimMonad m) => Size -> Size -> m (mat (PrimState m) a) Source #

new n m creates a mutable matrix with n rows and m columns.

unsafeNew :: (MMatrix mat a, PrimMonad m) => Size -> Size -> m (mat (PrimState m) a) Source #

unsafeNew n m creates a mutable matrix with n rows and m columns, without memory initialisation.

See also: new.

copy :: (PrimMonad m, MMatrix mat a) => mat (PrimState m) a -> mat (PrimState m) a -> m () Source #

clone :: (PrimMonad m, MMatrix mat a) => mat (PrimState m) a -> m (mat (PrimState m) a) Source #

generate :: (PrimMonad m, MMatrix mat a) => Int -> Int -> (Index -> Index -> a) -> m (mat (PrimState m) a) Source #

generateM :: (PrimMonad m, MMatrix mat a) => Int -> Int -> (Index -> Index -> m a) -> m (mat (PrimState m) a) Source #

fromRow :: (PrimMonad m, MMatrix mat a) => Row mat a -> m (mat (PrimState m) a) Source #

fromColumn :: (PrimMonad m, MMatrix mat a) => Column mat a -> m (mat (PrimState m) a) Source #

getRow :: (MMatrix mat a, PrimMonad m) => Index -> mat (PrimState m) a -> m (Row mat a) Source #

getRow n mat retrieves nth row in mat

N.B. Index is considered as 0-origin, NOT 1!

getColumn :: (MMatrix mat a, PrimMonad m) => Index -> mat (PrimState m) a -> m (Column mat a) Source #

getColumn n mat retrieves nth colun in mat

N.B. Index is considered as 0-origin, NOT 1!

imapRow :: (PrimMonad m, MMatrix mat a) => Index -> (Index -> a -> a) -> mat (PrimState m) a -> m () Source #

imapRow i f m mutates ith row in the matrix m by applying f with column index.

See also: mapRow, imapColumn, mapColumn.

N.B. Index is considered as 0-origin, NOT 1!

mapRow :: (PrimMonad m, MMatrix mat a) => Index -> (a -> a) -> mat (PrimState m) a -> m () Source #

mapRow i f m mutates ith row in the matrix m by applying f.

See also: imapRow, imapColumn, mapColumn.

N.B. Index is considered as 0-origin, NOT 1!

fill :: (PrimMonad m, MMatrix mat a) => Size -> Size -> a -> m (mat (PrimState m) a) Source #

fill n m c creates a mutable constant matrix with n rows and m columns.

N.B. Index is considered as 0-origin, NOT 1!

read :: (PrimMonad m, MMatrix mat a) => Index -> Index -> mat (PrimState m) a -> m a Source #

read i j m reads the value at ith row in jth column in m

N.B. Index is considered as 0-origin, NOT 1!

write :: (PrimMonad m, MMatrix mat a) => Index -> Index -> mat (PrimState m) a -> a -> m () Source #

read i j m writes the value at ith row in jth column in m

N.B. Index is considered as 0-origin, NOT 1!

scaleRow :: (Multiplicative a, Commutative a, MMatrix mat a, PrimMonad m) => Index -> a -> mat (PrimState m) a -> m () Source #

scaleRowL i c m multiplies every element in ith row in m by c, from right.

See also: scaleRowL and scaleRow

unsafeSwapRows :: (PrimMonad m, MMatrix mat a) => Index -> Index -> mat (PrimState m) a -> m () Source #

unsafeSwapRows n m mat swaps nth and mth rows in m, without boundary check.

See also: swapRows.

swapRows :: (PrimMonad m, MMatrix mat a) => Index -> Index -> mat (PrimState m) a -> m () Source #

swapRows n m mat swaps nth and mth rows in m.

See also: unsafeSwapRows.

gaussReduction :: (Eq a, PrimMonad m, Field a, Normed a, MMatrix mat a) => mat (PrimState m) a -> m (mat (PrimState m) a, mat (PrimState m) a, a) Source #

Performs Gaussian reduction to given matrix, returns the pair of triangulated matrix, pivot matrix and determinant.

unsafeGaussReduction :: (MMatrix mat a, Normed a, Eq a, Field a, PrimMonad m) => mat (PrimState m) a -> m (mat (PrimState m) a, a) Source #

Performs in-place gaussian reduction to the mutable matrix, and returns the pivoting matrix and determinant.