The Quipper System

Safe HaskellNone

Algorithms.CL.SNFMatrix

Description

A data structure representing an m×n matrix and some operations on it.

The SNF transformation is similar to Gaussian elimination, but using integers, which form a principal ideal domain. There is a handful of operations that we implement as operations on rows, and then using efficient transposition, these operations can be applied to columns.

Synopsis

Documentation

data SNFMatrix a Source

A data type to hold an m×n integer matrix (aij). The fields are: m, the number of rows; n, the number of columns; a, the matrix data, and isTranspose, a flag to indicate whether the matrix should be transposed.

Constructors

SNFMatrix Int Int (Array (Int, Int) a) Bool 

Instances

Show a => Show (SNFMatrix a) 

transpose :: SNFMatrix a -> SNFMatrix aSource

Transpose a matrix.

rows :: SNFMatrix a -> IntSource

Get the number of rows in the matrix.

cols :: SNFMatrix a -> IntSource

Get the number of columns in the matrix.

row_list :: SNFMatrix a -> [Int]Source

Get a list of row indices for a given matrix.

col_list :: SNFMatrix a -> [Int]Source

Get a list of column indices for a given matrix.

idx :: SNFMatrix a -> Int -> Int -> (Int, Int)Source

Get an index tuple into the matrix given row and column.

mtx_elem :: Show a => SNFMatrix a -> Int -> Int -> aSource

Get a matrix element.

mulrow :: (Show a, Num a) => SNFMatrix a -> Int -> a -> SNFMatrix aSource

Multiply a row of the matrix by a multiplier.

swaprows :: Show a => SNFMatrix a -> Int -> Int -> SNFMatrix aSource

Swap two rows of a matrix.

addmulrow :: (Show a, Num a) => SNFMatrix a -> Int -> Int -> a -> SNFMatrix aSource

Add a multiple of a row to another row.

printSNF :: Show a => SNFMatrix a -> [String]Source

Print an SNFMatrix for debugging.

matrixFromList :: [[a]] -> SNFMatrix aSource

Construct an SNFMatrix from a list.