jalla 0.1.0 → 0.1.0.1
raw patch · 3 files changed
+49/−127 lines, 3 files
Files
- README +36/−10
- jalla.cabal +13/−3
- tests/Test.hs +0/−114
README view
@@ -14,10 +14,41 @@ Lapacke must be compiled "by hand". 0. Get the jalla sources; say they are located in the directory "jalla/"-1. a) LAPACKE is part of LAPACK since version 3.4.- If you have that version, use that. Otherwise, follow b).- b) Get Lapacke at <http://www.netlib.org/lapack/lapacke.tgz>- or at <http://www.netlib.org/lapack/#_standard_c_language_apis_for_lapack>+1. If you do not have LAPACKE installed, follow the instructions + below under "Getting and building LAPACKE".+2. In jalla/, call + cabal configure+ cabal build+ cabal haddock+3. Look at the generated documentation, which should be quite informative now.++Please contact the author at github at goschs dot de if anything does not work!+++Getting and building LAPACKE+----------------------------+LAPACKE is part of LAPACK since version 3.4.+If you have that version, use that. Otherwise:++The following steps of getting and building +LAPACKE can be done with the script get_lapacke.sh.+You must have *wget* and *scons* installed on your +system.+From jalla's top level directory, call+ ./get_lapacke.sh+This should download lapacke and build it with our+SConstruct file, in the sub-directory ./lapacke.+You can source the file set_env.bash if you are using Bash,+in order to set the LD_LIBRARY_PATH and LIBRARY_PATH+variables.++Note that you might as well get the newest sources of LAPACK from netlib,+and copy the lapacke subdirectory from there over to the jalla directory.+Both ways worked for me.++If you want to get and build manually:+1. Get Lapacke at <http://www.netlib.org/lapack/lapacke.tgz>+ or at <http://www.netlib.org/lapack/#_standard_c_language_apis_for_lapack> 2. Unpack lapacke into "./lapacke" in the top jalla directory. 3. (Follow lapacke's instructions to build) /OR/ use the shiny new SCons file provided to build lapacke@@ -34,13 +65,8 @@ file. Jalla also expects the define LAPACK_COMPLEX_STRUCTURE in the same make.inc. This means that complex numbers are represented as C struct. -4. In jalla/, call - cabal configure- cabal build- cabal haddock-5. Look at the generated documentation, which is getting better now. -Please contact the author at github at goschs dot de if anything does not work!+ Documentation
jalla.cabal view
@@ -1,5 +1,5 @@ name: jalla-version: 0.1.0+version: 0.1.0.1 cabal-version: (>=1.8) build-type: Simple license: BSD3@@ -11,9 +11,18 @@ package-url: bug-reports: synopsis: Higher level functions for linear algebra. Wraps BLAS and LAPACKE.-description: Jalla aims at providing high level functions for linear algebra computations which+description: NOTE: Hackage does not know LAPACKE, therefore jalla and the documentation+ are not built there. You can find its documentation at+ <http://www.goschs.de/jalla>.+ .+ Jalla aims at providing high level functions for linear algebra computations which should be fast and easy enough to use. Under the hood, BLAS and LAPACKE are used (LAPACKE is a standard C interface to LAPACK which is part of LAPACK since version 3.4).+ .+ The modules Numeric.Jalla.Matrix and Numeric.Jalla.Vector are probably+ the most useful ones for users. Everything under Numeric.Jalla.Foreign+ is basically wrapping stuff.+ . Currently, I am adding new functions whenever I find some time. Please help, if you want to! There are not many tests yet, and we need some nicer error reporting (nicer than exceptions). category: Math@@ -56,7 +65,7 @@ other-extensions: extensions: extra-libraries: lapacke lapack cblas f77blas- extra-lib-dirs: ./lapacke+ -- extra-lib-dirs: ./lapacke includes: install-includes: include-dirs: ./lapacke/include@@ -75,5 +84,6 @@ Type: exitcode-stdio-1.0 Hs-source-dirs: tests Main-is: Test.hs+ ghc-options: -rtsopts -threaded Build-depends: base -any, jalla, random (>= 1.0.1), HUnit (>= 1.2.4), QuickCheck (>= 2.4.2), test-framework (>= 0.5), test-framework-hunit (>= 0.2.7), test-framework-quickcheck2 (>= 0.2.12)
− tests/Test.hs
@@ -1,114 +0,0 @@-{-# LANGUAGE FlexibleInstances, UndecidableInstances, OverlappingInstances #-}--module Main (main,- Arbitrary(..),- prop_pseudoInverse,- prop_frobNorm,- prop_frobNorm2,- prop_frobNorm3,- prop_frobNorm4) where--import Jalla.BLAS.Foreign.BlasOps-import Jalla.Matrix-import Jalla.Vector-import Jalla.Types-import Jalla.Test-import System.Random---import Test.Framework (defaultMain, testGroup)-import Test.Framework.Providers.HUnit-import Test.Framework.Providers.QuickCheck2 (testProperty)--import Test.QuickCheck-import Test.HUnit--import Data.List---main = defaultMain tests--tests = [- testGroup "Matrix Norms" [- testProperty "frob1" prop_frobNorm,- testProperty "frob2" prop_frobNorm2,- testProperty "frob3" prop_frobNorm3,- testProperty "frob4" prop_frobNorm4- ],- testGroup "Multiplications" [- testProperty "matrixMultDiag1" prop_matrixMultDiag1,- testProperty "matrixMultDiag2" prop_matrixMultDiag2,- testProperty "matrixMultDiag3" prop_matrixMultDiag3,- testProperty "matrixMultDiag4" prop_matrixMultDiag4- ],- testGroup "Inverse" [- testProperty "pseudoInverse" prop_pseudoInverse- ]- ]------instance (Random a, CMatrix mat a) => Random (mat a) where--- randomR (lo,hi) g = createMatrix $ matrixMap----prop_frobNorm :: Matrix CDouble -> Bool-prop_frobNorm m = (2 * abs (a - b) / (abs a + abs b)) <= 1e-8- where a = frobNorm m - b = sqrt $ sum $ map (^2) $ matrixList RowMajor m- -prop_frobNorm2 :: Matrix CFloat -> Bool-prop_frobNorm2 m = (2 * abs (a - b) / (abs a + abs b)) <= 1e-6- where a = frobNorm m - b = realToFrac ((sqrt $ sum $ map ((^2) . realToFrac) $ matrixList RowMajor m) :: CDouble)- -prop_frobNorm3 :: Matrix (Complex CFloat) -> Bool-prop_frobNorm3 m = 2 * realPart (abs (a - b)) / (realPart (abs a + abs b)) <= 1e-5- where a = frobNorm m - b = sqrt $ sum $ map (^2) $ matrixList RowMajor m- -prop_frobNorm4 :: Matrix (Complex CDouble) -> Bool-prop_frobNorm4 m = 2 * realPart (abs (a - b)) / (realPart (abs a + abs b)) <= 1e-8- where a = frobNorm m - b = sqrt $ sum $ map (^2) $ matrixList RowMajor m---prop_matrixMultDiag :: (BlasOps a, RealFrac a) => Matrix a -> Bool-prop_matrixMultDiag mat = frobNorm (matrixMultDiag (mat,NoTrans) (map realToFrac [1..]) ##- mat ## dm) < 1e-8 &&- frobNorm (matrixMultDiag (mat,Trans) (map realToFrac [1..]) ##- (mat,Trans) ##! (dm',NoTrans)) < 1e-8- where (m,n) = shape mat- dm = createMatrix (n,m) act- dm' = createMatrix (m,n) act- act = fill 0 >> (setDiag 0 $ map realToFrac [1..])--prop_matrixMultDiagC :: (BlasOpsComplex a, RealFloat a) => Matrix (Complex a) -> Bool-prop_matrixMultDiagC mat = realPart (frobNorm (a ##- mat ## dm)) < 1e-7 &&- realPart (frobNorm (b ##- (mat,Trans) ##! (dm',NoTrans))) < 1e-7- where - a = matrixMultDiag (mat,NoTrans) (map realToFrac [1..])- b = matrixMultDiag (mat,Trans) (map realToFrac [1..])- (m,n) = shape mat- dm = createMatrix (n,m) act- dm' = createMatrix (m,n) act- act = fill 0 >> (setDiag 0 $ map realToFrac [1..])--prop_matrixMultDiag1 :: Matrix CFloat -> Bool-prop_matrixMultDiag1 = prop_matrixMultDiag-prop_matrixMultDiag2 :: Matrix CDouble -> Bool-prop_matrixMultDiag2 = prop_matrixMultDiag-prop_matrixMultDiag3 :: Matrix (Complex CFloat) -> Bool-prop_matrixMultDiag3 = prop_matrixMultDiagC-prop_matrixMultDiag4 :: Matrix (Complex CDouble) -> Bool-prop_matrixMultDiag4 = prop_matrixMultDiagC---prop_pseudoInverse :: Matrix CDouble -> Bool-prop_pseudoInverse mat = frobNorm a < 1e-6- where- (m,n) = shape mat- mat_plus = pseudoInverse mat- a | m < n = idMatrix m ##- mat ## mat_plus- | otherwise = idMatrix n ##- mat_plus ## mat- -