# bed-and-breakfast

 Latest on Hackage: 0.4.3

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

# bed-and-breakfast

Matrix operations in 100% pure Haskell.

Bed and Breakfast is a linear algebra library written in Haskell. It provides fast matrix operations like finding the determinant or the inverse of a matrix.

## Example (GHCi Session)

``````*Numeric.Matrix> let m = fromList [[0,3,2],[5,6,10],[4,3,2.0]] :: Matrix Double
*Numeric.Matrix> inv m
Just  -0.2499999999999999  0.0  0.25
0.4166666666666667  -0.11111111111111112  0.1388888888888889
-0.12500000000000006  0.16666666666666669  -0.20833333333333334

*Numeric.Matrix> let m = fromList [[0,3,2],[5,6,10],[4,3,2.0]] :: Matrix Rational
*Numeric.Matrix> inv m
Just  (-1) % 4  0 % 1  1 % 4
5 % 12  (-1) % 9  5 % 36
(-1) % 8  1 % 6  (-5) % 24``````

## Example (with Template Haskell Syntactic Sugar)

``````{-# LANGUAGE Haskell2010, TemplateHaskell, QuasiQuotes #-}

import Numeric.Matrix
import Numeric.Matrix.Sugar

m :: Matrix Double
m = [dMatrix| 20   30 40
40.5 71 23
20   20 27 |]

mInv = maybe (error "not invertible") id \$ inv m``````

## Changes

v0.1
Initial version, features `det`, basic arithmetic operations, and instances for `Float`, `Double`, `Complex`, and `Rational`.
v0.1.1
Fixed wrong algorithm for computing the inverse of a `Matrix`.
v0.1.2
Added instances for `Num Matrix`, `Fractional Matrix`, and `Eq Matrix`.
v0.1.3
`inv` is now a total function and will no longer call `error` if a matrix is not invertible. Also `Matrix` derives `Data.Typeable`. now.
v0.1.4
Added `scale`, and methods for joining matrices vertically and horizontally. Corrected a bug in `isUnit` reported by Charles Durham. `isUnit` returned True for any matrix for which `all (== 1) . trace` would have, which is wrong).
v0.2
A little bit more documentation. Also moved some functions (`isXXX`) away from the type class `MatrixElement`. Properly flagged the package as experimental (was improperly marked as `stable`, copied form a template).
v0.2.1
Added `cofactors`, `adjugate`, `minor`, and `minorMatrix`.
v0.2.2
`rank` works now for any Matrix component type.
v0.2.3
Added `Read` instance for `Matrix`. Improved on documentation.
v0.3
Added a QuickCheck test suite, fixed a bug in `det` (det would crash for singular matrices, where it should return 0).
v0.3.1
Added TemplateHaskell syntactic sugar (see `Numeric.Matrix.Sugar`). Rewrote multiplication. `matrix` function build an array faster now.
v0.3.2
`Numeric.Matrix.Sugar` was not mentioned in the cabal file. Improved test suite. Improved documentation.
v0.4
Fixed a bug regarding `empty` and `fromList`. Use unsafe operations where it is safe for speed. Added RULES. Added an instance for binary.
v0.4.1
The unsafe operations used in v0.4 turned out to fatally fail on certain platforms. Revoked this change.
v0.4.2
Fixed a tiny bug regarding the `row` function for extracting the number of rows in a Matrix. Thanks to Tim Makarios for finding and fixing the bug.
v0.4.3
Fixed a bug in @transpose@ that prevented it from working correctly with non-square matrices. Thanks to @owst@ from @hub.darcs.net@.
Depends on 5 packages:
Used by 1 package: