bed-and-breakfast 0.4.2 → 0.4.3
raw patch · 5 files changed
+183/−62 lines, 5 filesdep ~bed-and-breakfast
Dependency ranges changed: bed-and-breakfast
Files
- CHANGES.md +108/−0
- README.md +42/−0
- ROADMAP.md +25/−0
- bed-and-breakfast.cabal +6/−61
- src/Numeric/Matrix.hs +2/−1
+ CHANGES.md view
@@ -0,0 +1,108 @@+<dl>+ <dt>v0.1</dt>+ <dd>+ Initial version, features <code>det</code>,+ basic arithmetic operations, and instances for+ <code>Float</code>, <code>Double</code>, <code>Complex</code>, and+ <code>Rational</code>.+ </dd>++ <dt>v0.1.1</dt>+ <dd>+ Fixed wrong algorithm for computing the inverse of a <code>Matrix</code>.+ </dd>++ <dt>v0.1.2</dt>+ <dd>+ Added instances for <code>Num Matrix</code>,+ <code>Fractional Matrix</code>, and <code>Eq Matrix</code>.+ </dd>++ <dt>v0.1.3</dt>+ <dd>+ <code>inv</code> is now a total function and will no longer call+ <code>error</code> if a matrix is not invertible. Also <code>Matrix</code>+ derives <code>Data.Typeable</code>.+ now.+ </dd>++ <dt>v0.1.4</dt>+ <dd>+ Added <code>scale</code>, and methods for joining matrices vertically and+ horizontally. Corrected a bug in <code>isUnit</code> reported by Charles Durham.+ <code>isUnit</code> returned True for any matrix for which+ <code>all (== 1) . trace</code> would have, which is wrong).+ </dd>++ <dt>v0.2</dt>+ <dd>+ A little bit more documentation. Also moved some+ functions (<code>isXXX</code>) away from the type class <code>MatrixElement</code>.+ Properly flagged the package as experimental (was improperly marked as+ <code>stable</code>, copied form a template).+ </dd>++ <dt>v0.2.1</dt>+ <dd>+ Added <code>cofactors</code>, <code>adjugate</code>, <code>minor</code>, and+ <code>minorMatrix</code>.+ </dd>++ <dt>v0.2.2</dt>+ <dd>+ <code>rank</code> works now for any Matrix component type.+ </dd>++ <dt>v0.2.3</dt>+ <dd>+ Added <code>Read</code> instance for <code>Matrix</code>.+ Improved on documentation.+ </dd>++ <dt>v0.3</dt>+ <dd>+ Added a QuickCheck test suite, fixed a bug in <code>det</code>+ (det would crash for singular matrices, where it should+ return 0).+ </dd>++ <dt>v0.3.1</dt>+ <dd>+ Added TemplateHaskell syntactic sugar (see <code>Numeric.Matrix.Sugar</code>).+ Rewrote multiplication. <code>matrix</code> function build an array faster now.+ </dd>++ <dt>v0.3.2</dt>+ <dd>+ <code>Numeric.Matrix.Sugar</code> was not mentioned in the+ cabal file. Improved test suite. Improved documentation.+ </dd>++ <dt>v0.4</dt>+ <dd>+ Fixed a bug regarding <code>empty</code> and <code>fromList</code>.+ Use unsafe operations where it is safe for speed.+ Added RULES. Added an instance for binary.+ </dd>++ <dt>v0.4.1</dt>+ <dd>+ The unsafe operations used in v0.4 turned out+ to fatally fail on certain platforms. Revoked this change.+ </dd>++ <dt>v0.4.2</dt>+ <dd>+ Fixed a tiny bug regarding the <code>row</code> function+ for extracting the number of rows in a Matrix.+ Thanks to Tim Makarios for finding and fixing the bug.+ </dd>++ <dt>v0.4.3</dt>+ <dd>+ Fixed a bug in @transpose@ that prevented it from+ working correctly with non-square matrices.+ Thanks to @owst@ from @hub.darcs.net@.+ </dd>+</dl>+
+ README.md view
@@ -0,0 +1,42 @@+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.++- [API documentation](https://hackage.haskell.org/package/bed-and-breakfast-0.4.1/docs/Numeric-Matrix.html)+- bed-and-breakfast on [Hackage](https://hackage.haskell.org/package/bed-and-breakfast)++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+
+ ROADMAP.md view
@@ -0,0 +1,25 @@+bed-and-breakfast is steadily in development.+The goal is a version 1.0 which features (only features that are+not implemented yet are enumerated here):++* Several matrix decomposition methods+ * LU / LUP decomposition+ * QR decomposition using Gram-Schmidt+ * Singular Value Decomposition++* Computation of Eigenvalues++* Proper support for complex matrices++* Transform matrices into different forms+ * Triangular (upper, lower)+ * Hessenberg (upper, lower)+ * Tridiagonal+ * Diagonal++* Better support for vectors (currently these are just 1xN or Mx1 matrices)+ * Dot product+ * Vector product+ * Outer product++
bed-and-breakfast.cabal view
@@ -1,67 +1,10 @@ Name: bed-and-breakfast-Version: 0.4.2+Version: 0.4.3 Synopsis: Efficient Matrix operations in 100% Haskell. Description: Efficient Matrix operations in 100% Haskell. .- [@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.--+ This library uses boxed and unboxed arrays+ in the ST monad, in order to achieve efficiency. License: MIT License-File: LICENSE Author: Julian Fleischer <julian.fleischer@fu-berlin.de>@@ -72,6 +15,8 @@ Stability: experimental Homepage: https://hackage.haskell.org/package/bed-and-breakfast +Extra-Source-Files: CHANGES.md, README.md, ROADMAP.md+ Source-Repository head type: git location: https://github.com/scravy/bed-and-breakfast.git@@ -91,7 +36,7 @@ main-is: quickcheck-tests.hs GHC-Options: -O2 build-depends: base >= 4.5 && < 5,- bed-and-breakfast == 0.3.2,+ bed-and-breakfast, QuickCheck >= 2.4.2
src/Numeric/Matrix.hs view
@@ -453,7 +453,8 @@ (x:xs) -> (length xs + 1, length x) adjugate = transpose . cofactors- transpose m = matrix (dimensions m) (\(i,j) -> m `at` (j,i))+ transpose mat = matrix (n, m) (\(i,j) -> mat `at` (j,i))+ where (m, n) = dimensions mat trace = select (uncurry (==)) inv _ = Nothing