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

Algebra.Matrix.Generic

Synopsis

Documentation

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

General Matrix type, with associated mutable matrix.

Minimal complete definition

basicRowCount, basicColumnCount, basicUnsafeIndexM

Methods

basicRowCount :: mat a -> Size Source #

basicColumnCount :: mat a -> Size Source #

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

default unsafeFreeze :: (PrimMonad m, Mutable mat ~ WrapImmutable mat) => Mutable mat (PrimState m) a -> m (mat a) Source #

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

default unsafeThaw :: (Mutable mat ~ WrapImmutable mat, PrimMonad m) => mat a -> m (Mutable mat (PrimState m) a) Source #

basicUnsafeIndexM :: Monad m => mat a -> Index -> Index -> m a Source #

basicUnsafeGetRowM :: Monad m => mat a -> Index -> m (Row mat a) Source #

basicUnsafeGetColumnM :: Monad m => mat a -> Index -> m (Column mat a) Source #

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

unsafeGenerate :: Size -> Size -> (Index -> Index -> a) -> mat a Source #

unsafeWrite :: mat a -> Index -> Index -> a -> mat a Source #

unsafeFromRows :: [Row mat a] -> mat a Source #

unsafeFromColumns :: [Column mat a] -> mat a Source #

toRows :: mat a -> [Row mat a] Source #

toColumns :: mat a -> [Column mat a] Source #

swapRows :: mat a -> Index -> Index -> mat a Source #

scaleRow :: Commutative a => mat a -> Index -> a -> mat a Source #

unsafeIMapRowM :: Monad m => mat a -> Index -> (Index -> a -> m a) -> m (mat a) Source #

unsafeIMapRowM_ :: Monad m => mat a -> Index -> (Index -> a -> m b) -> m () Source #

unsafeIMapRow :: mat a -> Index -> (Index -> a -> a) -> mat a Source #

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

gaussReduction :: (Eq a, Normed a, Field a) => mat a -> (mat a, mat a, a) Source #

Instances

Instances details
(UnitNormalForm a, Ring a) => Matrix Matrix a Source # 
Instance details

Defined in Algebra.Matrix.DataMatrix

Methods

basicRowCount :: Matrix a -> Size Source #

basicColumnCount :: Matrix a -> Size Source #

unsafeFreeze :: PrimMonad m => Mutable Matrix (PrimState m) a -> m (Matrix a) Source #

unsafeThaw :: PrimMonad m => Matrix a -> m (Mutable Matrix (PrimState m) a) Source #

basicUnsafeIndexM :: Monad m => Matrix a -> Index -> Index -> m a Source #

basicUnsafeGetRowM :: Monad m => Matrix a -> Index -> m (Row Matrix a) Source #

basicUnsafeGetColumnM :: Monad m => Matrix a -> Index -> m (Column Matrix a) Source #

basicUnsafeCopy :: PrimMonad m => Mutable Matrix (PrimState m) a -> Matrix a -> m () Source #

unsafeGenerate :: Size -> Size -> (Index -> Index -> a) -> Matrix a Source #

unsafeWrite :: Matrix a -> Index -> Index -> a -> Matrix a Source #

unsafeFromRows :: [Row Matrix a] -> Matrix a Source #

unsafeFromColumns :: [Column Matrix a] -> Matrix a Source #

toRows :: Matrix a -> [Row Matrix a] Source #

toColumns :: Matrix a -> [Column Matrix a] Source #

swapRows :: Matrix a -> Index -> Index -> Matrix a Source #

scaleRow :: Matrix a -> Index -> a -> Matrix a Source #

unsafeIMapRowM :: Monad m => Matrix a -> Index -> (Index -> a -> m a) -> m (Matrix a) Source #

unsafeIMapRowM_ :: Monad m => Matrix a -> Index -> (Index -> a -> m b) -> m () Source #

unsafeIMapRow :: Matrix a -> Index -> (Index -> a -> a) -> Matrix a Source #

combineRows :: Index -> a -> Index -> Matrix a -> Matrix a Source #

gaussReduction :: Matrix a -> (Matrix a, Matrix a, a) Source #

DecidableZero a => Matrix IMMatrix a Source # 
Instance details

Defined in Algebra.Matrix.IntMap

Methods

basicRowCount :: IMMatrix a -> Size Source #

basicColumnCount :: IMMatrix a -> Size Source #

unsafeFreeze :: PrimMonad m => Mutable IMMatrix (PrimState m) a -> m (IMMatrix a) Source #

unsafeThaw :: PrimMonad m => IMMatrix a -> m (Mutable IMMatrix (PrimState m) a) Source #

basicUnsafeIndexM :: Monad m => IMMatrix a -> Index -> Index -> m a Source #

basicUnsafeGetRowM :: Monad m => IMMatrix a -> Index -> m (Row IMMatrix a) Source #

basicUnsafeGetColumnM :: Monad m => IMMatrix a -> Index -> m (Column IMMatrix a) Source #

basicUnsafeCopy :: PrimMonad m => Mutable IMMatrix (PrimState m) a -> IMMatrix a -> m () Source #

unsafeGenerate :: Size -> Size -> (Index -> Index -> a) -> IMMatrix a Source #

unsafeWrite :: IMMatrix a -> Index -> Index -> a -> IMMatrix a Source #

unsafeFromRows :: [Row IMMatrix a] -> IMMatrix a Source #

unsafeFromColumns :: [Column IMMatrix a] -> IMMatrix a Source #

toRows :: IMMatrix a -> [Row IMMatrix a] Source #

toColumns :: IMMatrix a -> [Column IMMatrix a] Source #

swapRows :: IMMatrix a -> Index -> Index -> IMMatrix a Source #

scaleRow :: IMMatrix a -> Index -> a -> IMMatrix a Source #

unsafeIMapRowM :: Monad m => IMMatrix a -> Index -> (Index -> a -> m a) -> m (IMMatrix a) Source #

unsafeIMapRowM_ :: Monad m => IMMatrix a -> Index -> (Index -> a -> m b) -> m () Source #

unsafeIMapRow :: IMMatrix a -> Index -> (Index -> a -> a) -> IMMatrix a Source #

combineRows :: Index -> a -> Index -> IMMatrix a -> IMMatrix a Source #

gaussReduction :: IMMatrix a -> (IMMatrix a, IMMatrix a, a) Source #

(Num a, Container Matrix a) => Matrix Matrix (WrapNum a) Source # 
Instance details

Defined in Algebra.Matrix.HMatrix

Methods

basicRowCount :: Matrix (WrapNum a) -> Size Source #

basicColumnCount :: Matrix (WrapNum a) -> Size Source #

unsafeFreeze :: PrimMonad m => Mutable Matrix (PrimState m) (WrapNum a) -> m (Matrix (WrapNum a)) Source #

unsafeThaw :: PrimMonad m => Matrix (WrapNum a) -> m (Mutable Matrix (PrimState m) (WrapNum a)) Source #

basicUnsafeIndexM :: Monad m => Matrix (WrapNum a) -> Index -> Index -> m (WrapNum a) Source #

basicUnsafeGetRowM :: Monad m => Matrix (WrapNum a) -> Index -> m (Row Matrix (WrapNum a)) Source #

basicUnsafeGetColumnM :: Monad m => Matrix (WrapNum a) -> Index -> m (Column Matrix (WrapNum a)) Source #

basicUnsafeCopy :: PrimMonad m => Mutable Matrix (PrimState m) (WrapNum a) -> Matrix (WrapNum a) -> m () Source #

unsafeGenerate :: Size -> Size -> (Index -> Index -> WrapNum a) -> Matrix (WrapNum a) Source #

unsafeWrite :: Matrix (WrapNum a) -> Index -> Index -> WrapNum a -> Matrix (WrapNum a) Source #

unsafeFromRows :: [Row Matrix (WrapNum a)] -> Matrix (WrapNum a) Source #

unsafeFromColumns :: [Column Matrix (WrapNum a)] -> Matrix (WrapNum a) Source #

toRows :: Matrix (WrapNum a) -> [Row Matrix (WrapNum a)] Source #

toColumns :: Matrix (WrapNum a) -> [Column Matrix (WrapNum a)] Source #

swapRows :: Matrix (WrapNum a) -> Index -> Index -> Matrix (WrapNum a) Source #

scaleRow :: Matrix (WrapNum a) -> Index -> WrapNum a -> Matrix (WrapNum a) Source #

unsafeIMapRowM :: Monad m => Matrix (WrapNum a) -> Index -> (Index -> WrapNum a -> m (WrapNum a)) -> m (Matrix (WrapNum a)) Source #

unsafeIMapRowM_ :: Monad m => Matrix (WrapNum a) -> Index -> (Index -> WrapNum a -> m b) -> m () Source #

unsafeIMapRow :: Matrix (WrapNum a) -> Index -> (Index -> WrapNum a -> WrapNum a) -> Matrix (WrapNum a) Source #

combineRows :: Index -> WrapNum a -> Index -> Matrix (WrapNum a) -> Matrix (WrapNum a) Source #

gaussReduction :: Matrix (WrapNum a) -> (Matrix (WrapNum a), Matrix (WrapNum a), WrapNum a) Source #

(Fractional a, Container Matrix a) => Matrix Matrix (WrapFractional a) Source # 
Instance details

Defined in Algebra.Matrix.HMatrix

Methods

basicRowCount :: Matrix (WrapFractional a) -> Size Source #

basicColumnCount :: Matrix (WrapFractional a) -> Size Source #

unsafeFreeze :: PrimMonad m => Mutable Matrix (PrimState m) (WrapFractional a) -> m (Matrix (WrapFractional a)) Source #

unsafeThaw :: PrimMonad m => Matrix (WrapFractional a) -> m (Mutable Matrix (PrimState m) (WrapFractional a)) Source #

basicUnsafeIndexM :: Monad m => Matrix (WrapFractional a) -> Index -> Index -> m (WrapFractional a) Source #

basicUnsafeGetRowM :: Monad m => Matrix (WrapFractional a) -> Index -> m (Row Matrix (WrapFractional a)) Source #

basicUnsafeGetColumnM :: Monad m => Matrix (WrapFractional a) -> Index -> m (Column Matrix (WrapFractional a)) Source #

basicUnsafeCopy :: PrimMonad m => Mutable Matrix (PrimState m) (WrapFractional a) -> Matrix (WrapFractional a) -> m () Source #

unsafeGenerate :: Size -> Size -> (Index -> Index -> WrapFractional a) -> Matrix (WrapFractional a) Source #

unsafeWrite :: Matrix (WrapFractional a) -> Index -> Index -> WrapFractional a -> Matrix (WrapFractional a) Source #

unsafeFromRows :: [Row Matrix (WrapFractional a)] -> Matrix (WrapFractional a) Source #

unsafeFromColumns :: [Column Matrix (WrapFractional a)] -> Matrix (WrapFractional a) Source #

toRows :: Matrix (WrapFractional a) -> [Row Matrix (WrapFractional a)] Source #

toColumns :: Matrix (WrapFractional a) -> [Column Matrix (WrapFractional a)] Source #

swapRows :: Matrix (WrapFractional a) -> Index -> Index -> Matrix (WrapFractional a) Source #

scaleRow :: Matrix (WrapFractional a) -> Index -> WrapFractional a -> Matrix (WrapFractional a) Source #

unsafeIMapRowM :: Monad m => Matrix (WrapFractional a) -> Index -> (Index -> WrapFractional a -> m (WrapFractional a)) -> m (Matrix (WrapFractional a)) Source #

unsafeIMapRowM_ :: Monad m => Matrix (WrapFractional a) -> Index -> (Index -> WrapFractional a -> m b) -> m () Source #

unsafeIMapRow :: Matrix (WrapFractional a) -> Index -> (Index -> WrapFractional a -> WrapFractional a) -> Matrix (WrapFractional a) Source #

combineRows :: Index -> WrapFractional a -> Index -> Matrix (WrapFractional a) -> Matrix (WrapFractional a) Source #

gaussReduction :: Matrix (WrapFractional a) -> (Matrix (WrapFractional a), Matrix (WrapFractional a), WrapFractional a) Source #

(Integral a, Container Matrix a) => Matrix Matrix (WrapIntegral a) Source # 
Instance details

Defined in Algebra.Matrix.HMatrix

Methods

basicRowCount :: Matrix (WrapIntegral a) -> Size Source #

basicColumnCount :: Matrix (WrapIntegral a) -> Size Source #

unsafeFreeze :: PrimMonad m => Mutable Matrix (PrimState m) (WrapIntegral a) -> m (Matrix (WrapIntegral a)) Source #

unsafeThaw :: PrimMonad m => Matrix (WrapIntegral a) -> m (Mutable Matrix (PrimState m) (WrapIntegral a)) Source #

basicUnsafeIndexM :: Monad m => Matrix (WrapIntegral a) -> Index -> Index -> m (WrapIntegral a) Source #

basicUnsafeGetRowM :: Monad m => Matrix (WrapIntegral a) -> Index -> m (Row Matrix (WrapIntegral a)) Source #

basicUnsafeGetColumnM :: Monad m => Matrix (WrapIntegral a) -> Index -> m (Column Matrix (WrapIntegral a)) Source #

basicUnsafeCopy :: PrimMonad m => Mutable Matrix (PrimState m) (WrapIntegral a) -> Matrix (WrapIntegral a) -> m () Source #

unsafeGenerate :: Size -> Size -> (Index -> Index -> WrapIntegral a) -> Matrix (WrapIntegral a) Source #

unsafeWrite :: Matrix (WrapIntegral a) -> Index -> Index -> WrapIntegral a -> Matrix (WrapIntegral a) Source #

unsafeFromRows :: [Row Matrix (WrapIntegral a)] -> Matrix (WrapIntegral a) Source #

unsafeFromColumns :: [Column Matrix (WrapIntegral a)] -> Matrix (WrapIntegral a) Source #

toRows :: Matrix (WrapIntegral a) -> [Row Matrix (WrapIntegral a)] Source #

toColumns :: Matrix (WrapIntegral a) -> [Column Matrix (WrapIntegral a)] Source #

swapRows :: Matrix (WrapIntegral a) -> Index -> Index -> Matrix (WrapIntegral a) Source #

scaleRow :: Matrix (WrapIntegral a) -> Index -> WrapIntegral a -> Matrix (WrapIntegral a) Source #

unsafeIMapRowM :: Monad m => Matrix (WrapIntegral a) -> Index -> (Index -> WrapIntegral a -> m (WrapIntegral a)) -> m (Matrix (WrapIntegral a)) Source #

unsafeIMapRowM_ :: Monad m => Matrix (WrapIntegral a) -> Index -> (Index -> WrapIntegral a -> m b) -> m () Source #

unsafeIMapRow :: Matrix (WrapIntegral a) -> Index -> (Index -> WrapIntegral a -> WrapIntegral a) -> Matrix (WrapIntegral a) Source #

combineRows :: Index -> WrapIntegral a -> Index -> Matrix (WrapIntegral a) -> Matrix (WrapIntegral a) Source #

gaussReduction :: Matrix (WrapIntegral a) -> (Matrix (WrapIntegral a), Matrix (WrapIntegral a), WrapIntegral a) Source #

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

Instances

Instances details
type Column STMatrix Source # 
Instance details

Defined in Algebra.Matrix.HMatrix

type Column STMatrix = Vector
type Column MIMMatrix Source # 
Instance details

Defined in Algebra.Matrix.IntMap

type Column Matrix Source # 
Instance details

Defined in Algebra.Matrix.DataMatrix

type Column Matrix = Vector
type Column Matrix Source # 
Instance details

Defined in Algebra.Matrix.HMatrix

type Column Matrix = Vector
type Column IMMatrix Source # 
Instance details

Defined in Algebra.Matrix.IntMap

type Column (WrapImmutable mat :: Type -> k -> Type) Source # 
Instance details

Defined 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 details

Defined in Algebra.Matrix.HMatrix

type Row STMatrix = Vector
type Row MIMMatrix Source # 
Instance details

Defined in Algebra.Matrix.IntMap

type Row Matrix Source # 
Instance details

Defined in Algebra.Matrix.DataMatrix

type Row Matrix = Vector
type Row Matrix Source # 
Instance details

Defined in Algebra.Matrix.HMatrix

type Row Matrix = Vector
type Row IMMatrix Source # 
Instance details

Defined in Algebra.Matrix.IntMap

type Row (WrapImmutable mat :: Type -> k -> Type) Source # 
Instance details

Defined in Algebra.Matrix.Generic

type Row (WrapImmutable mat :: Type -> k -> Type) = Row mat

type Size = Int Source #

type Index = Int Source #

data WrapImmutable mat s a Source #

Wrapper type for matrix types without mutable representation.

N.B. To make things work, you have to provide all methods of Matrix class except unsafeThaw, unsafeFreeze, basicUnsafeCopy, unsafeIMapRowM, and gaussReduction.

Instances

Instances details
(Monoidal a, Matrix mat a) => MMatrix (WrapImmutable mat) a Source # 
Instance details

Defined in Algebra.Matrix.Generic

Methods

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

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

basicRowCount :: WrapImmutable mat s a -> Size Source #

basicColumnCount :: WrapImmutable mat s a -> Size Source #

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

type Row (WrapImmutable mat :: Type -> k -> Type) Source # 
Instance details

Defined in Algebra.Matrix.Generic

type Row (WrapImmutable mat :: Type -> k -> Type) = Row mat
type Column (WrapImmutable mat :: Type -> k -> Type) Source # 
Instance details

Defined in Algebra.Matrix.Generic

type Column (WrapImmutable mat :: Type -> k -> Type) = Column mat

type family Mutable (v :: Type -> Type) = (mv :: Type -> Type -> Type) | mv -> v #

Instances

Instances details
type Mutable Vector 
Instance details

Defined in Data.Vector

type Mutable Vector = MVector
type Mutable Vector 
Instance details

Defined in Data.Vector.Primitive

type Mutable Vector = MVector
type Mutable Vector 
Instance details

Defined in Data.Vector.Storable

type Mutable Vector = MVector
type Mutable Vector 
Instance details

Defined in Data.Vector.Unboxed.Base

type Mutable Vector = MVector
type Mutable Matrix Source # 
Instance details

Defined in Algebra.Matrix.DataMatrix

type Mutable Matrix
type Mutable Matrix Source # 
Instance details

Defined in Algebra.Matrix.HMatrix

type Mutable Matrix = STMatrix
type Mutable IMMatrix Source # 
Instance details

Defined in Algebra.Matrix.IntMap

rowCount :: Matrix mat a => mat a -> Size Source #

columnCount :: Matrix mat a => mat a -> Size Source #

generate :: Matrix mat a => Size -> Size -> (Index -> Index -> a) -> mat a Source #

freeze :: (Matrix mat a, PrimMonad m) => Mutable mat (PrimState m) a -> m (mat a) Source #

thaw :: (Matrix mat a, PrimMonad m) => mat a -> m (Mutable mat (PrimState m) a) Source #

fromRows :: Matrix mat a => [Row mat a] -> mat a Source #

fromColumns :: Matrix mat a => [Column mat a] -> mat a Source #

create :: Matrix mat a => (forall s. ST s (Mutable mat s a)) -> mat a Source #

(!) :: Matrix mat a => mat a -> (Index, Index) -> a Source #

wrapImmutable :: (PrimMonad m, Matrix mat a) => mat a -> m (WrapImmutable mat (PrimState m) a) Source #