-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Type-safe matrix operations
--   
--   Please see the README on GitHub at
--   <a>https://github.com/wchresta/matrix-static#readme</a>
@package matrix-static
@version 0.2


-- | Data.Matrix.Static wraps <tt>matrix</tt>'s Data.Matrix functions and
--   adds size information on the type level. The name of the functions are
--   mostly the same as in <tt>Data.Matrix</tt>. Exceptions are, when there
--   is a safer version of a function due to the additional type-level
--   information. In that case, there may be an unsafe variant of the
--   function with the postfix <tt>Unsafe</tt>.
module Data.Matrix.Static

-- | A matrix over the type <tt>f</tt> with <tt>m</tt> rows and <tt>n</tt>
--   columns. This just wraps the <a>Matrix</a> constructor and adds size
--   information to the type
data Matrix (m :: Nat) (n :: Nat) (a :: Type)

-- | Display a matrix as a <a>String</a> using the <a>Show</a> instance of
--   its elements.
prettyMatrix :: forall m n a. Show a => Matrix m n a -> String
nrows :: forall m n a. KnownNat m => Matrix m n a -> Int
ncols :: forall m n a. KnownNat n => Matrix m n a -> Int

-- | <i>O(rows*cols)</i>. Similar to <a>force</a>. It copies the matrix
--   content dropping any extra memory.
--   
--   Useful when using <a>submatrix</a> from a big matrix.
forceMatrix :: forall m n a. Matrix m n a -> Matrix m n a

-- | <i>O(rows*cols)</i>. Generate a matrix from a generator function. |
--   The elements are 1-indexed, i.e. top-left element is <tt>(1,1)</tt>.
--   Example of usage:
--   
--   <pre>
--   matrix (\(i,j) -&gt; 2*i - j) :: Matrix 2 4 Int
--   ( 1  0 -1 -2 )
--   ( 3  2  1  0 )
--   </pre>
matrix :: forall m n a. (KnownNat m, KnownNat n) => ((Int, Int) -> a) -> Matrix m n a

-- | <i>O(1)</i>. Represent a vector as a one row matrix.
rowVector :: forall m a. KnownNat m => Vector a -> Maybe (RowVector m a)

-- | <i>O(1)</i>. Represent a vector as a one row matrix.
colVector :: forall n a. KnownNat n => Vector a -> Maybe (ColumnVector n a)

-- | <i>O(rows*cols)</i>. The zero matrix This produces a zero matrix of
--   the size given by the type. Often, the correct dimensions can be
--   inferred by the compiler. If you want a specific size, give a type.
--   
--   <pre>
--   zero :: Matrix 2 2 Int
--   ( 0 0 )
--   ( 0 0 )
--   </pre>
zero :: forall m n a. (Num a, KnownNat n, KnownNat m) => Matrix m n a

-- | <i>O(rows*cols)</i>. Identity matrix
--   
--   <pre>
--   identitiy @n =
--   ( 1 0 0 ... 0 0 )
--   ( 0 1 0 ... 0 0 )
--   (       ...     )
--   ( 0 0 0 ... 1 0 )
--   ( 0 0 0 ... 0 1 )
--   </pre>
identity :: forall n a. (Num a, KnownNat n) => Matrix n n a

-- | Similar to <tt>diagonalList</tt>, but using <a>Vector</a>, which
--   should be more efficient. The size of the vector is <i>not</i> checked
--   and will lead to an exception if it's not of size n.
diagonal :: forall n a. KnownNat n => a -> Vector a -> Maybe (Matrix n n a)

-- | Similar to <tt>diagonalList</tt>, but using <a>Vector</a>, which
--   should be more efficient. The size of the vector is <i>not</i> checked
--   and will lead to an exception if it's not of size n.
diagonalUnsafe :: forall n a. a -> Vector a -> Matrix n n a

-- | <i>O(rows*cols)</i>. Permutation matrix. The parameters are given as
--   type level Nats. To use this, use <tt>-XDataKinds</tt> and
--   <tt>-XTypeApplications</tt>. The first type parameter gives the
--   matrix' size, the two following give the rows (or columns) to permute.
--   
--   <pre>
--   permMatrix @n @i @j =
--                 i     j       n
--     1 ( 1 0 ... 0 ... 0 ... 0 0 )
--     2 ( 0 1 ... 0 ... 0 ... 0 0 )
--       (     ...   ...   ...     )
--     i ( 0 0 ... 0 ... 1 ... 0 0 )
--       (     ...   ...   ...     )
--     j ( 0 0 ... 1 ... 0 ... 0 0 )
--       (     ...   ...   ...     )
--       ( 0 0 ... 0 ... 0 ... 1 0 )
--     n ( 0 0 ... 0 ... 0 ... 0 1 )
--   </pre>
--   
--   When <tt>i == j</tt> it reduces to <a>identity</a> <tt>n</tt>.
permMatrix :: forall n i j a. (Num a, KnownNat n, KnownNat i, KnownNat j, 1 <= i, i <= n, 1 <= j, j <= n) => Matrix n n a

-- | <i>O(rows*cols)</i>. Permutation matrix. The values of the row and
--   column identifiers are not checked and if they are out of range (not
--   between 1 and n) an exception will be thrown.
--   
--   <pre>
--   permMatrixUnsafe @n i j =
--                 i     j       n
--     1 ( 1 0 ... 0 ... 0 ... 0 0 )
--     2 ( 0 1 ... 0 ... 0 ... 0 0 )
--       (     ...   ...   ...     )
--     i ( 0 0 ... 0 ... 1 ... 0 0 )
--       (     ...   ...   ...     )
--     j ( 0 0 ... 1 ... 0 ... 0 0 )
--       (     ...   ...   ...     )
--       ( 0 0 ... 0 ... 0 ... 1 0 )
--     n ( 0 0 ... 0 ... 0 ... 0 1 )
--   </pre>
--   
--   When <tt>i == j</tt> it reduces to <a>identity</a> <tt>n</tt>.
permMatrixUnsafe :: forall n a. (Num a, KnownNat n) => Int -> Int -> Matrix n n a

-- | Create a matrix from a list of elements. The list must have exactly
--   length <tt>n*m</tt> or this returns Nothing. An example:
--   
--   <pre>
--   fromList [1..9] :: Maybe (Matrix 3 3 Int)
--   Just ( 1 2 3 )
--        ( 4 5 6 )
--        ( 7 8 9 )
--   </pre>
fromList :: forall m n a. (KnownNat m, KnownNat n) => [a] -> Maybe (Matrix m n a)

-- | Create a matrix from a non-empty list given the desired size. The list
--   must have at least <i>rows*cols</i> elements. An example:
--   
--   <pre>
--   fromListUnsafe [1..9] :: Matrix 3 3 Int
--   ( 1 2 3 )
--   ( 4 5 6 )
--   ( 7 8 9 )
--   </pre>
fromListUnsafe :: forall m n a. (KnownNat m, KnownNat n) => [a] -> Matrix m n a

-- | Create a matrix from a list of rows. The list must have exactly
--   <tt>m</tt> lists of length <tt>n</tt>. Nothing is returned otherwise
--   Example:
--   
--   <pre>
--   fromLists [ [1,2,3]      ( 1 2 3 )
--             , [4,5,6]      ( 4 5 6 )
--             , [7,8,9] ] =  ( 7 8 9 )
--   </pre>
fromLists :: forall m n a. (KnownNat m, KnownNat n) => [[a]] -> Maybe (Matrix m n a)

-- | Create a matrix from a list of rows. The list must have exactly
--   <tt>m</tt> lists of length <tt>n</tt>. If this does not hold, the
--   resulting Matrix will have different static dimensions that the
--   runtime dimension and will result in hard to debug errors. Use
--   <a>fromLists</a> whenever you're unsure. Example:
--   
--   <pre>
--   fromListsUnsafe [ [1,2,3]      ( 1 2 3 )
--                   , [4,5,6]      ( 4 5 6 )
--                   , [7,8,9] ] =  ( 7 8 9 )
--   </pre>
fromListsUnsafe :: [[a]] -> Matrix m n a

-- | Get the elements of a matrix stored in a list.
--   
--   <pre>
--          ( 1 2 3 )
--          ( 4 5 6 )
--   toList ( 7 8 9 ) = [1..9]
--   </pre>
toList :: forall m n a. Matrix m n a -> [a]

-- | Get the elements of a matrix stored in a list of lists, where each
--   list contains the elements of a single row.
--   
--   <pre>
--           ( 1 2 3 )   [ [1,2,3]
--           ( 4 5 6 )   , [4,5,6]
--   toLists ( 7 8 9 ) = , [7,8,9] ]
--   </pre>
toLists :: forall m n a. Matrix m n a -> [[a]]

-- | <i>O(1)</i>. Get an element of a matrix. Indices range from
--   <i>(1,1)</i> to <i>(m,n)</i>. The parameters are given as type level
--   Nats. To use this, use <tt>-XDataKinds</tt> and
--   <tt>-XTypeApplications</tt>.
--   
--   The type parameters are: row, column
--   
--   Example:
--   
--   <pre>
--                 ( 1 2 )
--   getElem @2 @1 ( 3 4 ) = 3
--   </pre>
getElem :: forall i j m n a. (KnownNat i, KnownNat j, 1 <= i, i <= m, 1 <= j, j <= n) => Matrix m n a -> a

-- | Short alias for <a>unsafeGet</a>. Careful: This has no bounds checking
--   This deviates from <tt>Data.Matrix</tt>, where (!) does check bounds
--   on runtime.
(!) :: Matrix m n a -> (Int, Int) -> a

-- | <i>O(1)</i>. Unsafe variant of <a>getElem</a>. This will do no bounds
--   checking
unsafeGet :: Int -> Int -> Matrix m n a -> a

-- | Alias for '(!)'. This exists to keep the interface similar to
--   <tt>Data.Matrix</tt> but serves no other purpose. Use '(!)' (or even
--   better <a>getElem</a>) instead.
(!.) :: Matrix m n a -> (Int, Int) -> a

-- | Variant of <a>unsafeGet</a> that returns Maybe instead of an error.
safeGet :: forall m n a. (KnownNat n, KnownNat m) => Int -> Int -> Matrix m n a -> Maybe a

-- | Variant of <a>setElem</a> that returns Maybe instead of an error.
safeSet :: forall m n a. a -> (Int, Int) -> Matrix m n a -> Maybe (Matrix m n a)

-- | <i>O(1)</i>. Get a row of a matrix as a vector. The range of the input
--   is not checked and must be between 1 and m
getRow :: Int -> Matrix m n a -> Vector a

-- | <i>O(1)</i>. Get a column of a matrix as a vector. The range of the
--   input is not checked and must be between 1 and n
getCol :: Int -> Matrix m n a -> Vector a

-- | Varian of <a>getRow</a> that returns a maybe instead of an error Only
--   available when used with <tt>matrix &gt;= 0.3.6</tt>!
safeGetRow :: Int -> Matrix m n a -> Maybe (Vector a)

-- | Variant of <a>getCol</a> that returns a maybe instead of an error Only
--   available when used with <tt>matrix &gt;= 0.3.6</tt>!
safeGetCol :: Int -> Matrix m n a -> Maybe (Vector a)

-- | <i>O(min rows cols)</i>. Diagonal of a <i>not necessarily square</i>
--   matrix.
getDiag :: Matrix m n a -> Vector a

-- | <i>O(rows*cols)</i>. Transform a <a>Matrix</a> to a <a>Vector</a> of
--   size <i>rows*cols</i>. This is equivalent to get all the rows of the
--   matrix using <a>getRow</a> and then append them, but far more
--   efficient.
getMatrixAsVector :: Matrix m n a -> Vector a

-- | Type safe matrix multiplication This is called <tt>(*)</tt> in
--   <tt>matrix</tt>. Since the dimensions of the input matrices differ,
--   they are not the same type and we cannot use <tt>Num</tt>'s
--   <tt>(*)</tt>
(.*) :: forall m k n a. Num a => Matrix m k a -> Matrix k n a -> Matrix m n a

-- | Type safe scalar multiplication
(^*) :: forall m n a. Num a => a -> Matrix m n a -> Matrix m n a

-- | Replace the value of a cell in a matrix. The position to be replaced
--   is given by TypeLevel Nats. To use this, use <tt>-XDataKinds</tt> and
--   <tt>-XTypeApplications</tt>.
--   
--   Example: setElem <tt>1 </tt>2 0 (1 2 3) = (1 0 3)
setElem :: forall i j m n a. (KnownNat i, KnownNat j, 1 <= i, i <= m, 1 <= j, j <= n) => a -> Matrix m n a -> Matrix m n a

-- | Unsafe variant of <a>setElem</a>, without bounds checking.
unsafeSet :: a -> (Int, Int) -> Matrix m n a -> Matrix m n a

-- | <i>O(rows*cols)</i>. The transpose of a matrix. Example:
--   
--   <pre>
--             ( 1 2 3 )   ( 1 4 7 )
--             ( 4 5 6 )   ( 2 5 8 )
--   transpose ( 7 8 9 ) = ( 3 6 9 )
--   </pre>
transpose :: forall m n a. Matrix m n a -> Matrix n m a

-- | Set the size of a matrix to given parameters. Use a default element
--   for undefined entries if the matrix has been extended.
setSize :: forall newM newN m n a. (KnownNat newM, KnownNat newN, 1 <= newM, 1 <= newN) => a -> Matrix m n a -> Matrix newM newN a

-- | Extend a matrix to the expected size adding a default element. If the
--   matrix already has the required size, nothing happens. Example:
--   
--   <pre>
--                                ( 1 2 3 0 0 )
--                    ( 1 2 3 )   ( 4 5 6 0 0 )
--                    ( 4 5 6 )   ( 7 8 9 0 0 )
--   extendTo @4 @5 0 ( 7 8 9 ) = ( 0 0 0 0 0 )
--   </pre>
extendTo :: forall newM newN m n a. (KnownNat newM, KnownNat newN, n <= newN, m <= newM) => a -> Matrix m n a -> Matrix newM newN a

-- | <i>O(rows^4)</i>. The inverse of a square matrix Uses naive Gaussian
--   elimination formula.
inverse :: forall n a. (Fractional a, Eq a) => Matrix n n a -> Either String (Matrix n n a)

-- | <i>O(rows*rows*cols*cols)</i>. Converts a matrix to reduced row
--   echelon form, thus solving a linear system of equations. This requires
--   that (cols &gt; rows) if cols &lt; rows, then there are fewer
--   variables than equations and the problem cannot be solved
--   consistently. If rows = cols, then it is basically a homogenous system
--   of equations, so it will be reduced to identity or an error depending
--   on whether the marix is invertible (this case is allowed for
--   robustness).
rref :: (Fractional a, Eq a) => Matrix m n a -> Either String (Matrix m n a)

-- | <i>O(rows*cols)</i>. Map a function over a row. The row to map is
--   given by a TypeLevel Nat. To use this, use <tt>-XDataKinds</tt> and
--   <tt>-XTypeApplications</tt>. Example:
--   
--   <pre>
--                             ( 1 2 3 )   ( 1 2 3 )
--                             ( 4 5 6 )   ( 5 6 7 )
--   mapRow @2 (\_ x -&gt; x + 1) ( 7 8 9 ) = ( 7 8 9 )
--   </pre>
mapRow :: forall i m n a. (KnownNat i, KnownNat m, 1 <= i, i <= m) => (Int -> a -> a) -> Matrix m n a -> Matrix m n a

-- | <i>O(rows*cols)</i>. Map a function over a row. The bounds of the row
--   parameter is not checked and might throw an error. Example:
--   
--   <pre>
--                                  ( 1 2 3 )   ( 1 2 3 )
--                                  ( 4 5 6 )   ( 5 6 7 )
--   mapRowUnsafe (\_ x -&gt; x + 1) 2 ( 7 8 9 ) = ( 7 8 9 )
--   </pre>
mapRowUnsafe :: forall m n a. (Int -> a -> a) -> Int -> Matrix m n a -> Matrix m n a

-- | <i>O(rows*cols)</i>. Map a function over a column. The row to map is
--   given by a TypeLevel Nat. To use this, use <tt>-XDataKinds</tt> and
--   <tt>-XTypeApplications</tt>. Example:
--   
--   <pre>
--                             ( 1 2 3 )   ( 1 3 3 )
--                             ( 4 5 6 )   ( 4 6 6 )
--   mapCol @2 (\_ x -&gt; x + 1) ( 7 8 9 ) = ( 7 9 9 )
--   </pre>
mapCol :: forall j m n a. (KnownNat j, KnownNat m, 1 <= j, j <= n) => (Int -> a -> a) -> Matrix m n a -> Matrix m n a

-- | <i>O(rows*cols)</i>. Map a function over a column. The bounds of the
--   row parameter is not checked and might throw an error. Example:
--   
--   <pre>
--                                  ( 1 2 3 )   ( 1 3 3 )
--                                  ( 4 5 6 )   ( 4 6 6 )
--   mapColUnsafe (\_ x -&gt; x + 1) 2 ( 7 8 9 ) = ( 7 9 9 )
--   </pre>
mapColUnsafe :: forall m n a. (Int -> a -> a) -> Int -> Matrix m n a -> Matrix m n a

-- | <i>O(rows*cols)</i>. Map a function over elements. Example:
--   
--   <pre>
--                              ( 1 2 3 )   ( 0 -1 -2 )
--                              ( 4 5 6 )   ( 1  0 -1 )
--   mapPos (\(r,c) _ -&gt; r - c) ( 7 8 9 ) = ( 2  1  0 )
--   </pre>
--   
--   Only available when used with <tt>matrix &gt;= 0.3.6</tt>!
mapPos :: ((Int, Int) -> a -> b) -> Matrix m n a -> Matrix m n b

-- | <i>O(1)</i>. Extract a submatrix from the given position. The type
--   parameters expected are the starting and ending indices of row and
--   column elements.
submatrix :: forall iFrom jFrom iTo jTo m n a. (KnownNat iFrom, KnownNat iTo, KnownNat jFrom, KnownNat jTo, 1 <= iFrom, 1 <= ((iTo - iFrom) + 1), ((iTo - iFrom) + 1) <= m, 1 <= jFrom, 1 <= ((jTo - jFrom) + 1), ((jTo - jFrom) + 1) <= n) => Matrix m n a -> Matrix ((iTo - iFrom) + 1) ((jTo - jFrom) + 1) a

-- | <i>O(1)</i>. Extract a submatrix from the given position. The type
--   parameters are the dimension of the returned matrix, the run-time
--   indices are the indiced of the top-left element of the new matrix.
--   Example:
--   
--   <pre>
--                             ( 1 2 3 )
--                             ( 4 5 6 )   ( 2 3 )
--   submatrixUnsafe @2 @2 1 2 ( 7 8 9 ) = ( 5 6 )
--   </pre>
submatrixUnsafe :: forall rows cols m n a. (KnownNat rows, KnownNat cols, 1 <= rows, rows <= m, 1 <= cols, cols <= n) => Int -> Int -> Matrix m n a -> Matrix rows cols a

-- | <i>O(rows*cols)</i>. Remove a row and a column from a matrix. Example:
--   
--   <pre>
--                     ( 1 2 3 )
--                     ( 4 5 6 )   ( 1 3 )
--   minorMatrix @2 @2 ( 7 8 9 ) = ( 7 9 )
--   </pre>
minorMatrix :: forall delRow delCol m n a. (KnownNat delRow, KnownNat delCol, 1 <= delRow, 1 <= delCol, delRow <= m, delCol <= n, 2 <= n, 2 <= m) => Matrix m n a -> Matrix (m - 1) (n - 1) a

-- | <i>O(rows*cols)</i>. Remove a row and a column from a matrix. Example:
--   
--   <pre>
--                         ( 1 2 3 )
--                         ( 4 5 6 )   ( 1 3 )
--   minorMatrixUnsafe 2 2 ( 7 8 9 ) = ( 7 9 )
--   </pre>
minorMatrixUnsafe :: (2 <= n, 2 <= m) => Int -> Int -> Matrix m n a -> Matrix (m - 1) (n - 1) a

-- | <i>O(1)</i>. Make a block-partition of a matrix using a given element
--   as reference. The element will stay in the bottom-right corner of the
--   top-left corner matrix. This means, the ranges of the pivot elements
--   positions are &lt;math&gt;
--   
--   <pre>
--                     (             )   ( TR   | TL   )
--                     (             )   ( ...  | ...  )
--                     (    x        )   (    x |      )
--   splitBlocks @i @j (             ) = (-------------) , where x = a_{i,j}
--                     (             )   ( BL   | BR   )
--                     (             )   ( ...  | ...  )
--                     (             )   (      |      )
--   </pre>
--   
--   Note that contrary to the <tt>matrix</tt> version of this function,
--   blocks will never be empty. Also, because of TypeLits not providing
--   proper dependent types, there is no way to have a type safe variant of
--   this functon where the pivot element is given at run-time.
splitBlocks :: forall mt nl mb nr a. (KnownNat mt, KnownNat nl, 1 <= mt, 1 <= mb, 1 <= nl, 1 <= nr) => Matrix (mt + mb) (nl + nr) a -> (Matrix mt nl a, Matrix mt nr a, Matrix mb nl a, Matrix mb nr a)

-- | Horizontally join two matrices. Visually:
--   
--   <pre>
--   ( A ) &lt;|&gt; ( B ) = ( A | B )
--   </pre>
(<|>) :: forall m n k a. Matrix m n a -> Matrix m k a -> Matrix m (k + n) a

-- | Horizontally join two matrices. Visually:
--   
--   <pre>
--                     ( A )
--   ( A ) &lt;-&gt; ( B ) = ( - )
--                     ( B )
--   </pre>
(<->) :: forall m k n a. Matrix m n a -> Matrix k n a -> Matrix (m + k) n a

-- | Join blocks of the form detailed in <a>splitBlocks</a>. Precisely:
--   
--   <pre>
--   joinBlocks (tl,tr,bl,br) =
--     (tl &lt;|&gt; tr)
--         &lt;-&gt;
--     (bl &lt;|&gt; br)
--   </pre>
joinBlocks :: forall mt mb nl nr a. (1 <= mt, 1 <= mb, 1 <= nl, 1 <= nr) => (Matrix mt nl a, Matrix mt nr a, Matrix mb nl a, Matrix mb nr a) -> Matrix (mt + mb) (nl + nr) a

-- | Perform an operation element-wise. This uses <tt>matrix</tt>'s
--   <tt>elementwiseUnsafe</tt> since we can guarantee proper dimensions at
--   compile time.
elementwise :: forall m n a b c. (a -> b -> c) -> Matrix m n a -> Matrix m n b -> Matrix m n c

-- | Standard matrix multiplication by definition.
multStd :: forall m k n a. Num a => Matrix m k a -> Matrix k n a -> Matrix m n a

-- | Standard matrix multiplication by definition.
multStd2 :: forall m k n a. Num a => Matrix m k a -> Matrix k n a -> Matrix m n a

-- | Strassen's matrix multiplication.
multStrassen :: forall m k n a. Num a => Matrix m k a -> Matrix k n a -> Matrix m n a

-- | Mixed Strassen's matrix multiplication.
multStrassenMixed :: forall m k n a. Num a => Matrix m k a -> Matrix k n a -> Matrix m n a

-- | Scale a matrix by a given factor. Example:
--   
--   <pre>
--                 ( 1 2 3 )   (  2  4  6 )
--                 ( 4 5 6 )   (  8 10 12 )
--   scaleMatrix 2 ( 7 8 9 ) = ( 14 16 18 )
--   </pre>
scaleMatrix :: Num a => a -> Matrix m n a -> Matrix m n a

-- | Scale a row by a given factor. The input row is not checked for
--   validity. Example:
--   
--   <pre>
--                 ( 1 2 3 )   (  1  2  3 )
--                 ( 4 5 6 )   ( 12 15 18 )
--   scaleRow @2 3 ( 7 8 9 ) = (  7  8  9 )
--   </pre>
scaleRow :: forall i m n a. (KnownNat i, Num a) => a -> Matrix m n a -> Matrix m n a

-- | Scale a row by a given factor. The input row is not checked for
--   validity. Example:
--   
--   <pre>
--                      ( 1 2 3 )   (  1  2  3 )
--                      ( 4 5 6 )   ( 12 15 18 )
--   scaleRowUnsafe 3 2 ( 7 8 9 ) = (  7  8  9 )
--   </pre>
scaleRowUnsafe :: Num a => a -> Int -> Matrix m n a -> Matrix m n a

-- | Add to one row a scalar multiple of another row. Example:
--   
--   <pre>
--                       ( 1 2 3 )   (  1  2  3 )
--                       ( 4 5 6 )   (  6  9 12 )
--   combineRows @2 @1 2 ( 7 8 9 ) = (  7  8  9 )
--   </pre>
combineRows :: forall i k m n a. (KnownNat i, KnownNat k, Num a) => a -> Matrix m n a -> Matrix m n a

-- | Add to one row a scalar multiple of another row. Example:
--   
--   <pre>
--                           ( 1 2 3 )   (  1  2  3 )
--                           ( 4 5 6 )   (  6  9 12 )
--   combineRowsUnsafe 2 2 1 ( 7 8 9 ) = (  7  8  9 )
--   </pre>
combineRowsUnsafe :: Num a => Int -> a -> Int -> Matrix m n a -> Matrix m n a

-- | Switch two rows of a matrix. Example:
--   
--   <pre>
--                    ( 1 2 3 )   ( 4 5 6 )
--                    ( 4 5 6 )   ( 1 2 3 )
--   switchRows @1 @2 ( 7 8 9 ) = ( 7 8 9 )
--   </pre>
switchRows :: forall i k m n a. (KnownNat i, KnownNat k, 1 <= i, i <= m, 1 <= k, k <= m) => Matrix m n a -> Matrix m n a

-- | Switch two rows of a matrix. The validity of the input row numbers is
--   not checked Example:
--   
--   <pre>
--                        ( 1 2 3 )   ( 4 5 6 )
--                        ( 4 5 6 )   ( 1 2 3 )
--   switchRowsUnsafe 1 2 ( 7 8 9 ) = ( 7 8 9 )
--   </pre>
switchRowsUnsafe :: Int -> Int -> Matrix m n a -> Matrix m n a

-- | Switch two coumns of a matrix. Example:
--   
--   <pre>
--                    ( 1 2 3 )   ( 2 1 3 )
--                    ( 4 5 6 )   ( 5 4 6 )
--   switchCols @1 @2 ( 7 8 9 ) = ( 8 7 9 )
--   </pre>
switchCols :: forall i k m n a. (KnownNat i, KnownNat k, 1 <= i, i <= n, 1 <= k, k <= n) => Matrix m n a -> Matrix m n a

-- | Switch two coumns of a matrix. The validity of the input column
--   numbers is not checked. Example:
--   
--   <pre>
--                        ( 1 2 3 )   ( 2 1 3 )
--                        ( 4 5 6 )   ( 5 4 6 )
--   switchColsUnsafe 1 2 ( 7 8 9 ) = ( 8 7 9 )
--   </pre>
switchColsUnsafe :: Int -> Int -> Matrix m n a -> Matrix m n a

-- | Matrix LU decomposition with <i>partial pivoting</i>. The result for a
--   matrix <i>M</i> is given in the format <i>(U,L,P,d)</i> where:
--   
--   <ul>
--   <li><i>U</i> is an upper triangular matrix.</li>
--   <li><i>L</i> is an <i>unit</i> lower triangular matrix.</li>
--   <li><i>P</i> is a permutation matrix.</li>
--   <li><i>d</i> is the determinant of <i>P</i>.</li>
--   <li><i>PM = LU</i>.</li>
--   </ul>
--   
--   These properties are only guaranteed when the input matrix is
--   invertible. An additional property matches thanks to the strategy
--   followed for pivoting:
--   
--   <ul>
--   <li><i>L_(i,j)</i> &lt;= 1, for all <i>i,j</i>.</li>
--   </ul>
--   
--   This follows from the maximal property of the selected pivots, which
--   also leads to a better numerical stability of the algorithm.
--   
--   Example:
--   
--   <pre>
--            ( 1 2 0 )     ( 2 0  2 )   (   1 0 0 )   ( 0 0 1 )
--            ( 0 2 1 )     ( 0 2 -1 )   ( 1/2 1 0 )   ( 1 0 0 )
--   luDecomp ( 2 0 2 ) = ( ( 0 0  2 ) , (   0 1 1 ) , ( 0 1 0 ) , 1 )
--   </pre>
--   
--   <a>Nothing</a> is returned if no LU decomposition exists.
luDecomp :: (Ord a, Fractional a) => Matrix m n a -> Maybe (Matrix m n a, Matrix m n a, Matrix m n a, a)

-- | Unsafe version of <a>luDecomp</a>. It fails when the input matrix is
--   singular.
luDecompUnsafe :: (Ord a, Fractional a) => Matrix m n a -> (Matrix m n a, Matrix m n a, Matrix m n a, a)

-- | Matrix LU decomposition with <i>complete pivoting</i>. The result for
--   a matrix <i>M</i> is given in the format <i>(U,L,P,Q,d,e)</i> where:
--   
--   <ul>
--   <li><i>U</i> is an upper triangular matrix.</li>
--   <li><i>L</i> is an <i>unit</i> lower triangular matrix.</li>
--   <li><i>P,Q</i> are permutation matrices.</li>
--   <li><i>d,e</i> are the determinants of <i>P</i> and <i>Q</i>
--   respectively.</li>
--   <li><i>PMQ = LU</i>.</li>
--   </ul>
--   
--   These properties are only guaranteed when the input matrix is
--   invertible. An additional property matches thanks to the strategy
--   followed for pivoting:
--   
--   <ul>
--   <li><i>L_(i,j)</i> &lt;= 1, for all <i>i,j</i>.</li>
--   </ul>
--   
--   This follows from the maximal property of the selected pivots, which
--   also leads to a better numerical stability of the algorithm.
--   
--   Example:
--   
--   <pre>
--             ( 1 0 )    ( 2 1 )  (   1    0 0 )  ( 0 0 1 )
--             ( 0 2 )    ( 0 2 )  (   0    1 0 )  ( 0 1 0 )  ( 1 0 )
--   luDecomp' ( 2 1 ) = (( 0 0 ), ( 1/2 -1/4 1 ), ( 1 0 0 ), ( 0 1 ), -1 , 1 )
--   </pre>
--   
--   <a>Nothing</a> is returned if no LU decomposition exists.
luDecomp' :: (Ord a, Fractional a) => Matrix m n a -> Maybe (Matrix m n a, Matrix m m a, Matrix m m a, Matrix n n a, a, a)

-- | Unsafe version of <a>luDecomp'</a>. It fails when the input matrix is
--   singular.
luDecompUnsafe' :: (Ord a, Fractional a) => Matrix m n a -> (Matrix m n a, Matrix m m a, Matrix m m a, Matrix n n a, a, a)

-- | Simple Cholesky decomposition of a symmetric, positive definite
--   matrix. The result for a matrix <i>M</i> is a lower triangular matrix
--   <i>L</i> such that:
--   
--   <ul>
--   <li><i>M = LL^T</i>.</li>
--   </ul>
--   
--   Example:
--   
--   <pre>
--              (  2 -1  0 )   (  1.41  0     0    )
--              ( -1  2 -1 )   ( -0.70  1.22  0    )
--   cholDecomp (  0 -1  2 ) = (  0.00 -0.81  1.15 )
--   </pre>
cholDecomp :: Floating a => Matrix n n a -> Matrix n n a

-- | Sum of the elements in the diagonal. See also <a>getDiag</a>. Example:
--   
--   <pre>
--         ( 1 2 3 )
--         ( 4 5 6 )
--   trace ( 7 8 9 ) = 15
--   </pre>
trace :: Num a => Matrix m n a -> a

-- | Product of the elements in the diagonal. See also <a>getDiag</a>.
--   Example:
--   
--   <pre>
--            ( 1 2 3 )
--            ( 4 5 6 )
--   diagProd ( 7 8 9 ) = 45
--   </pre>
diagProd :: Num a => Matrix m n a -> a

-- | Matrix determinant using Laplace expansion. If the elements of the
--   <a>Matrix</a> are instance of <a>Ord</a> and <a>Fractional</a>
--   consider to use <a>detLU</a> in order to obtain better performance.
--   Function <a>detLaplace</a> is <i>extremely</i> slow.
detLaplace :: Num a => Matrix n n a -> a

-- | Matrix determinant using LU decomposition. It works even when the
--   input matrix is singular.
detLU :: (Ord a, Fractional a) => Matrix n n a -> a

-- | Flatten a matrix of matrices.
flatten :: forall m' n' m n a. Matrix m' n' (Matrix m n a) -> Matrix (m' * m) (n' * n) a

-- | Apply a map function to the unsafe inner matrix type.
applyUnary :: forall m n m' n' a b. (Matrix a -> Matrix b) -> Matrix m n a -> Matrix m' n' b

-- | Transform a binary unstatic function to a binary static function.
applyBinary :: forall m n m' n' m'' n'' a b. (Matrix a -> Matrix a -> Matrix b) -> Matrix m n a -> Matrix m' n' a -> Matrix m'' n'' b

-- | Forget static information about a matrix. This converts this converts
--   the <a>Matrix</a> type to <tt>Data.Matrix.Matrix</tt>
unpackStatic :: forall m n a. Matrix m n a -> Matrix a
instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.Matrix.Static.Matrix m n a)
instance GHC.Base.Monoid a => GHC.Base.Monoid (Data.Matrix.Static.Matrix m n a)
instance Data.Traversable.Traversable (Data.Matrix.Static.Matrix m n)
instance Data.Foldable.Foldable (Data.Matrix.Static.Matrix m n)
instance GHC.Base.Applicative (Data.Matrix.Static.Matrix m n)
instance GHC.Base.Functor (Data.Matrix.Static.Matrix m n)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Matrix.Static.Matrix m n a)
instance GHC.Base.Monoid a => GHC.Base.Semigroup (Data.Matrix.Static.Matrix m n a)
instance GHC.Show.Show f => GHC.Show.Show (Data.Matrix.Static.Matrix m n f)
instance GHC.Classes.Ord f => GHC.Classes.Ord (Data.Matrix.Static.Matrix m n f)
instance GHC.Num.Num f => GHC.Num.Num (Data.Matrix.Static.Matrix m n f)
