LinAlg-magma-0.2.0.0: CUDA-based CUBLAS/MAGMA backend for LinAlg

Safe HaskellNone
LanguageHaskell2010

Numeric.LinAlg.Magma.Internal

Contents

Description

This module uses the mutable interface to provide an immutable, purely functional interface for matrix computations on the GPU. Because most of these functions are part of the LinAlg interface, there are not documented here.

Synopsis

Data types

data GArr :: Dim -> * -> * where

An immutable matrix datatype with a transpose flag, so we can avoid unnecessary transposition.

Constructors

Matrix :: !(Mat m n a) -> !(SBool b) -> GArr (M (Flip b m n) (Flip b n m)) a 
Vector :: !(Vec n a) -> GArr (V n) a 

Instances

CNum e => Matr e GArr 
CNum e => Scale Dim e GArr 
CNum e => Num (Vector n e) 
(CNum a, Show a) => Show (Vector n a) 
(CNum a, Eq a) => Eq (Matrix m n a) 
CNum e => Num (Matrix m n e) 
(CNum a, Show a) => Show (Matrix m n a) 

type Matrix m n = GArr (M m n)

type Vector n = GArr (V n)

data SBool b where

Constructors

STrue :: SBool True 
SFalse :: SBool False 

type family Flip t m n :: Nat

Equations

Flip True m n = n 
Flip False m n = m 

LinAlg operations

Data transfer

fromVect :: CNum e => Vect n e -> GArr (V n) e

toVect :: CNum e => Vector n e -> Vect n e

fromVects :: Storable a => Vect m (Vect n a) -> GArr (M m n) a

In line with the LinAlg specification, this function accepts input in row-major format.

toVects :: CNum a => Matrix m n a -> Vect m (Vect n a)

Converts a matrix to a list of lists in row-major format.

toRows :: CNum e => Matrix m n e -> Vect m (Vector n e)

toColumns :: CNum e => Matrix m n e -> Vect n (Vector m e)

fromRows :: CNum e => Vect m (Vector n e) -> GArr (M m n) e

fromColumns :: CNum e => Vect n (Vector m e) -> GArr (M m n) e

asColMat :: CNum e => Vec n e -> Matrix n 1 e

asColVec :: CNum e => Matrix m n e -> Vec (m * n) e

fromDiag :: CNum e => Vector n e -> Matrix n n e

takeDiag' :: CNum e => Matrix n n e -> Vector n e

Addition and scalar multiplication

vAddScale :: CNum e => e -> Vector n e -> Vector n e -> Vector n e

vscal :: CNum e => e -> Vector n e -> Vector n e

vplus :: CNum e => Vector n e -> Vector n e -> Vector n e

vminus :: CNum e => Vector n e -> Vector n e -> Vector n e

(.*) :: CNum e => e -> Matrix m n e -> Matrix m n e

(.+) :: CNum e => Matrix m n e -> Matrix m n e -> Matrix m n e

(.-) :: CNum e => Matrix m n e -> Matrix m n e -> Matrix m n e

Multiplication

mXv :: CNum e => Matrix m n e -> Vector n e -> Vector m e

vXm :: CNum e => Vector n e -> Matrix n m e -> Vector m e

mXm :: CNum e => Matrix m n e -> Matrix n p e -> Matrix m p e

Core operations

mdim :: Matrix m n a -> (SNat m, SNat n)

Dimension of a matrix (rows, columns).

mrows :: Matrix m n a -> SNat m

mcols :: Matrix m n a -> SNat n

len :: VecP s n a -> SNat n

the number of elements in the vector

trans :: Matrix m n a -> Matrix n m a

Matrix transpose.

ident :: CNum e => SNat n -> Matrix n n e

outer :: CNum e => Vec m e -> Vec n e -> Matrix m n e

elementwiseProdV :: CNum e => Vector n e -> Vector n e -> Vector n e

elementwiseProdM :: CNum e => Matrix m n e -> Matrix m n e -> Matrix m n e

Solving linear systems

genSolveV :: CNum e => Matrix n n e -> Vector n e -> Vector n e

General linear solver

genSolveM :: CNum e => Matrix n n e -> Matrix n p e -> Matrix n p e

General linear solver

tSolveV :: CNum e => FillMode -> Matrix n n e -> Vec n e -> Vec n e

Solution of a triangular system.

tSolveM :: CNum e => FillMode -> SideMode -> Matrix n n e -> Matrix m p e -> Matrix m p e

Solution of a triangular system. XXX: make the type more specific

(^\) :: CNum e => Matrix n n e -> Matrix n p e -> Matrix n p e

(.\) :: CNum e => Matrix n n e -> Matrix n p e -> Matrix n p e

chol :: CNum e => Matrix n n e -> Matrix n n e

Cholesky decomposition. Important Note: The entries above the diagonal are *not* zeroed out, so be careful!

Other functions

constant :: CNum a => a -> SNat n -> Vector n a

constantM :: CNum a => a -> (SNat m, SNat n) -> Matrix m n a

trsymprod :: CNum e => Matrix n n e -> Matrix n n e -> e