haskell-numerics / hmatrix Goto Github PK
View Code? Open in Web Editor NEWLinear algebra and numerical computation
Linear algebra and numerical computation
Versions:
[deepfire@andromedae ~]$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
[deepfire@andromedae ~]$ gcc --version
gcc (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7)
[deepfire@andromedae ~]$ rpm -qi gsl | grep Version
Version : 1.15
[deepfire@andromedae ~]$ cabal info hmatrix
* hmatrix (library)
Synopsis: Linear algebra and numerical computation
Versions available: 0.13.0.0, 0.13.1.0, 0.14.0.0, 0.14.0.1, 0.14.1.0,
0.15.0.0, 0.15.0.1, 0.15.2.0, 0.15.2.1 (and 31 others)
Versions installed: 0.15.2.1
Error message:
[36 of 36] Compiling Graphics.Plot ( lib/Graphics/Plot.hs, dist/build/Graphics/Plot.o )
lib/Numeric/GSL/gsl-aux.c: In function ‘integrate_cquad’:
lib/Numeric/GSL/gsl-aux.c:813:5:
warning: passing argument 9 of ‘gsl_integration_cquad’ from incompatible pointer type [enabled by default]
int res = gsl_integration_cquad (&F, a, b, aprec, prec, wk, result, error, neval);
^
In file included from lib/Numeric/GSL/gsl-aux.c:27:0:
/usr/include/gsl/gsl_integration.h:315:1:
note: expected ‘size_t *’ but argument is of type ‘int *’
gsl_integration_cquad (const gsl_function * f, double a, double b,
The compensated hackage package provides compensated floating-point arithmetic.
It would be nice to support these numeric types.
As I see, an Element instance should be written for Compensated types.
However I have not enough knowledge to decide whether this is possible or how hard it is.
It'd be great to have a function like unsafeMatrixToForeignPtr :: Matrix a -> ForeignPtr a
and unsafeWithMatrix :: Matrix a -> (Ptr a -> IO b) -> IO b
.
unsafeWithMatrix :: Matrix a -> (Ptr a -> IO b) -> IO b
unsafeWithMatrix m = Data.Vector.Storable.unsafeWith (xdat m)
unsafeMatrixToForeignPtr :: Matrix a -> (ForeignPtr a, Int, Int)
unsafeMatrixToForeignPtr m = Data.Vector.Storable.unsafeToForeignPtr (xdat m)
Alternatively, Matrix(..) could simply be exported from Data.Packed.Development, which could be useful for other things. Or the modules Data.Packed.Internal.* exposed.
I wanted to download http://perception.inf.um.es/hmatrix/gsl-lapack-windows.zip but that site appears to be down
The GSL manual lists a couple more ODE methods (such as multistep Adams and BDF) which are especially useful for "hard" ODE problems. Could these be added to hmatrix? I looked at the code in ODE.hs but couldn't understand how the methods were passed through to GSL.
Please modify the class declaration of Product with
class Container Vector e => Product e where ...
instead of
class Element e => Product e where ...
but it does not compile the following code
newtype DiagMatrix e = DiagMatrix {getDiag :: Vector e}
instance Mul DiagMatrix Matrix Matrix where
(<>) dm m = m mul
repmat (asColumn $ getDiag dm) 1 (cols m)
And even "Could not deduce Num e from Product e"!!!
Create a separate package hmatrix-base for the functions based on blas/lapack, with BSD license.
dot (fromList [0 :+ 1]) (fromList [0 :+ 1]) :: Complex Double
should be 1 but is (-1) instead. People can't agree if the first or the second argument should be conjugated but one of them needs to be conjugated.
Hi,
I've installed GSL in a non-standard location (path below), but the build fails thus:
cabal install hmatrix --prefix=${HOME}/installed/haskell/hmatrix --disable-shared \
--extra-lib-dirs=${HOME}/installed/gsl/lib \
--extra-include-dirs=${HOME}/installed/gsl/include
Configuring hmatrix-0.14.1.0...
Checking foreign libraries... FAIL
*** Sorry, I can't link GSL.
*** Please make sure that the appropriate -dev packages are installed.
*** You can also specify the required libraries using
*** cabal install hmatrix --configure-option=link:lib1,lib2,lib3,etc.
setup: Package hmatrix-0.14.1.0 can't be built on this system.
cabal: Error: some packages failed to install:
hmatrix-0.14.1.0 failed during the building phase. The exception was:
ExitFailure 1
Looks like --extra-* flags are not respected. I'm running Debian Squeeze, 64-bit, GHC 7.4.1. I also tried
--configure-option=link:gsl,lapack,gslcblas
but it failed with same error message.
Any help appreciated. Thanks !
When building hmatrix latest version I get:
Failed to install hmatrix-0.15.2.1
Last 10 lines of the build log ( C:\Users\is7s\AppData\Roaming\cabal\logs\hm
atrix-0.15.2.1.log ):
setup.exe: Package hmatrix-0.15.2.1 can't be built on this system.
cabal.exe: Error: some packages failed to install:
hmatrix-0.15.2.1 failed during the building phase. The exception was:
ExitFailure 1
And when building hmatrix-0.13.1.0 I get:
Failed to install hmatrix-0.13.1.0
Last 10 lines of the build log ( C:\Users\is7s\AppData\Roaming\cabal\logs\hm
atrix-0.13.1.0.log ):
Configuring hmatrix-0.13.1.0...
"#include <gsl/gsl_sf_gamma.h>
"#include <gsl/gsl_sf_exp.h>
Checking foreign libraries... OK
setup.exe: Missing dependencies on foreign libraries:
I've followed the instructions in the INSTALL file, added the relevant directories to ${PATH} and ${GSL}.
What's wrong?
Is there a reason to keep the internal implementation of Vector?
Data.Vector.Storable seems stable and implements most of the Data.Packed.Vector functions.
Code compiles, but fails with segfault:
import Numeric.GSL
import Numeric.LinearAlgebra
xdot t [x,y,ky] = [
kx * c**2 / omega
, ky * c**2 / omega
, -1 * 2 * pi / (2 * omega) * exp(-(y - y0)**2 / 20**2)
]
where
kx = 1
c = 3
omega = 6
y0 = 20
size = 300
ts = linspace size (0,10 :: Double)
sol = odeSolve xdot [0,0,1] ts
main = print sol
Build & run in gdb
:
m0nhawk@terra:ray_tracing $ gdb ./plot
GNU gdb (GDB) Fedora 7.6.1-41.fc19
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/m0nhawk/Dropbox/software/ray_tracing/plot...(no debugging symbols found)...done.
(gdb) run
Starting program: /home/m0nhawk/Dropbox/software/ray_tracing/./plot
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0xb7fcf300 in ?? () from /lib/libgsl.so.0
Missing separate debuginfos, use: debuginfo-install atlas-3dnow-3.8.4-8.fc19.i686 blas-3.4.2-2.fc19.i686 glibc-2.17-18.fc19.i686 gmp-5.1.1-2.fc19.i686 gsl-1.15-8.fc19.i686 libffi-3.0.13-4.fc19.i686 libgcc-4.8.1-1.fc19.i686 libgfortran-4.8.1-1.fc19.i686 libquadmath-4.8.1-1.fc19.i686
(gdb)
uname -a
:
Linux terra 3.11.2-201.fc19.i686.PAE #1 SMP Fri Sep 27 19:35:55 UTC 2013 i686 i686 i386 GNU/Linux
GSL 1.15, hmatrix 0.15.0.1, GHC 7.4.2.
Shouldn't it be very easy for the integration routines to compute f(x) = x over a finite interval? Yet
Prelude Numeric.GSL> integrateQNG 1e-3 id (-1.0) (1.0)
results in ERROR: failed to reach tolerance with highest-order rule
(similarly integrateQAGS
results in a roundoff error
).
Is this to be expected from a numerical integration routine? I am baffled. If the integration bounds are not symmetric as in
Prelude Numeric.GSL> integrateQNG 1e-6 id (-1.000001) (1.0)
then no exception is thrown.
On 64-bit machines, some programs (e.g. examples/minimize.hs) produce a segmentation fault when run from ghci. In that program the crash is inside gsl_multimin_fdfminimizer_alloc, in the C wrapper. If the program is run by runhaskell it just terminates prematurely, producing no results.
This problem does not happen in compiled mode.
(I don't know if this has been fixed in more recent ghc versions.)
It's typical that dot product of complex vectors is conjugated on one of the components. Thus I think that using BLAS's
gsl_blas_zdotc
for
dotC
instead of
gsl_blas_zdotu
is more sensible.
Dominics-MacBook-Pro:hmatrix-0.14.1.0 dom$ cabal install hmatrix-tests --enable-tests
Resolving dependencies...
Configuring hmatrix-tests-0.3...
Building hmatrix-tests-0.3...
Preprocessing library hmatrix-tests-0.3...
[1 of 3] Compiling Numeric.LinearAlgebra.Tests.Properties ( src/Numeric/LinearAlgebra/Tests/Properties.hs, dist/build/Numeric/LinearAlgebra/Tests/Properties.o )
[2 of 3] Compiling Numeric.LinearAlgebra.Tests.Instances ( src/Numeric/LinearAlgebra/Tests/Instances.hs, dist/build/Numeric/LinearAlgebra/Tests/Instances.o )
[3 of 3] Compiling Numeric.LinearAlgebra.Tests ( src/Numeric/LinearAlgebra/Tests.hs, dist/build/Numeric/LinearAlgebra/Tests.o )
[1 of 3] Compiling Numeric.LinearAlgebra.Tests.Properties ( src/Numeric/LinearAlgebra/Tests/Properties.hs, dist/build/Numeric/LinearAlgebra/Tests/Properties.p_o )
[2 of 3] Compiling Numeric.LinearAlgebra.Tests.Instances ( src/Numeric/LinearAlgebra/Tests/Instances.hs, dist/build/Numeric/LinearAlgebra/Tests/Instances.p_o )
[3 of 3] Compiling Numeric.LinearAlgebra.Tests ( src/Numeric/LinearAlgebra/Tests.hs, dist/build/Numeric/LinearAlgebra/Tests.p_o )
In-place registering hmatrix-tests-0.3...
Preprocessing test suite 'basic' for hmatrix-tests-0.3...
[1 of 1] Compiling Main ( src/tests.hs, dist/build/basic/basic-tmp/Main.o )
Linking dist/build/basic/basic ...
ld: warning: directory not found for option '-L/opt/local/lib/'
Running Haddock for hmatrix-tests-0.3...
Preprocessing library hmatrix-tests-0.3...
Warning: The documentation for the following packages are not installed. No
links will be generated to these packages: rts-1.0
Haddock coverage:
2% ( 1 / 51) in 'Numeric.LinearAlgebra.Tests.Properties'
3% ( 1 / 30) in 'Numeric.LinearAlgebra.Tests.Instances'
100% ( 3 / 3) in 'Numeric.LinearAlgebra.Tests'
Documentation created: dist/doc/html/hmatrix-tests/index.html
Preprocessing test suite 'basic' for hmatrix-tests-0.3...
Running 1 test suites...
Test suite basic: RUNNING...
------ mult Double
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ mult Float
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ sub-trans
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ ctrans
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ lu
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ inv (linearSolve)
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ luSolve
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ cholSolve
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ luSolveLS
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests (5% trivial).
+++ OK, passed 100 tests (5% trivial).
------ pinv (linearSolveSVD)
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ det
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ svd
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ svdCd
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ eig
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ nullSpace
+++ OK, passed 100 tests (62% trivial).
+++ OK, passed 100 tests (58% trivial).
------ qr
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ hess
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ schur
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ chol
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
*** Failed! Falsifiable (after 11 tests):
PosDef (9><9)
[ 73.87869251473286, 1.1273506615922164, 15.70466000264199, -5.862009302524614, 19.480337962051237, -0.22058730074698019, -2.3700878798513387, 10.640942994096992, 1.9200364325990043
, 1.1273506615922164, 24.928023163601647, -0.3666986789692053, 0.8824385268498705, 0.6395161007500723, -4.155772755096951, 1.5468029642875722, -4.383114266920074, -4.367630149971132
, 15.70466000264199, -0.3666986789692053, 47.97967933971645, 22.957772481032126, -4.3818804614900415, -1.1789831823495438, 16.800207237763463, 0.954401110299564, 0.7150703801317521
, -5.862009302524614, 0.8824385268498705, 22.957772481032126, 33.865196203889035, -13.299981551825011, -0.8100658896048243, -4.014418208794853, 10.946113393455471, 2.6363532608051794
, 19.480337962051237, 0.6395161007500723, -4.3818804614900415, -13.299981551825011, 17.57209430543892, 0.2997400199841638, 4.185015788464446, -1.3435757778545026, -7.704921560617375e-3
, -0.22058730074698019, -4.155772755096951, -1.1789831823495438, -0.8100658896048243, 0.2997400199841638, 45.24833543463693, -0.6617970132611875, -0.35123537737225063, 20.279934121207564
, -2.3700878798513387, 1.5468029642875722, 16.800207237763463, -4.014418208794853, 4.185015788464446, -0.6617970132611875, 33.208676787756374, -15.512017550060888, 1.1906054204341139
, 10.640942994096992, -4.383114266920074, 0.954401110299564, 10.946113393455471, -1.3435757778545026, -0.35123537737225063, -15.512017550060888, 39.71403555104348, -0.7464385074825298
, 1.9200364325990043, -4.367630149971132, 0.7150703801317521, 2.6363532608051794, -7.704921560617375e-3, 20.279934121207564, 1.1906054204341139, -0.7464385074825298, 44.22235927454882 ]
Test suite basic: FAIL
Test suite logged to: dist/test/hmatrix-tests-0.3-basic.log
0 of 1 test suites (0 of 1 test cases) passed.
Failed to install hmatrix-tests-0.3
cabal: Error: some packages failed to install:
hmatrix-tests-0.3 failed during the tests phase. The exception was:
ExitFailure 1
Dominics-MacBook-Pro:hmatrix-0.14.1.0 dom$
explaining how to supply the Jacobian
Is there a way to use hmatrix for exact computations? E.g, compute the determinant of an integer matrix.
When calling randomVector from ghci-7.4.1, I get a Bus Error when trying to use randomVector. This crashes ghci and exits the command promt.
To reproduce, simply start a ghci session and type:
import Numeric.Container
randomVector 2 Uniform 2
ghci session: https://gist.github.com/2841919
verbose ghci session: https://gist.github.com/2841930
Calling cmat
triggers transposition
import Numeric.LinearAlgebra
import Numeric.GSL.Fitting.Linear
import Data.Packed.Development
test1 :: IO ()
test1 = do
let y = fromList [1,2,3,4,5]
let x = trans $ fromLists [[1,2,3,4,5], [1,1,1,1,1]]
let x3 = fromLists [[1,1], [2,1], [3,1], [4,1], [5,1]]
print $ x == x3
print $ multifit x y
print $ multifit x3 y
test2 :: IO ()
test2 = do
let y = fromList [1,2,3,4,5]
let x = cmat $ trans $ fromLists [[1,2,3,4,5], [1,1,1,1,1]]
let x3 = fromLists [[1,1], [2,1], [3,1], [4,1], [5,1]]
print $ x == x3
print $ multifit x y
print $ multifit x3 y
main :: IO ()
main = do
test1
putStrLn ""
test2
I'm getting a build failure with 7.8rc2:
[23 of 36] Compiling Numeric.ContainerBoot ( lib/Numeric/ContainerBoot.hs, dist/build/Numeric/ContainerBoot.o )
lib/Numeric/ContainerBoot.hs:515:15:
Conflicting family instance declarations:
BoundsOf (a -> a) -- Defined at lib/Numeric/ContainerBoot.hs:515:15
BoundsOf (a -> a -> a)
-- Defined at lib/Numeric/ContainerBoot.hs:516:15
lib/Numeric/ContainerBoot.hs:520:15:
Conflicting family instance declarations:
ContainerOf (a -> a)
-- Defined at lib/Numeric/ContainerBoot.hs:520:15
ContainerOf (a -> a -> a)
-- Defined at lib/Numeric/ContainerBoot.hs:521:15
Failed to install hmatrix-0.15.2.0
I get this failure both with the hackage version and the current HEAD.
70c4b19 looks suspicious
It'd be very nice to be able to directly use Vector/Matrix CInt/CFloat/CDouble. Also, there ought to be an instance Num (Vector Int), or just a Num a => Num (Vector a) instance, although it'd need at least OverlappingInstances.
Admit empty dimensions in vectors and matrices and extend compatibility rules.
vector's vectors can be empty.
In Octave, a matrix product (2x0) x (0x2) produces a (2x2) array of zeros.
Useful for some matrix construction functions.
Prelude Numeric.LinearAlgebra> linspace 100 (0,20)
<interactive>:4:1:
No instance for (Container Vector e0)
arising from a use of `linspace'
Possible fix: add an instance declaration for (Container Vector e0)
In the expression: linspace 100 (0, 20)
In an equation for `it': it = linspace 100 (0, 20)
hmatrix-0.15.0.1 installs OK, but when I try to install hmatrix-0.15.2.0, I get the following error:
$ uname -a
Linux atsfsx115 2.6.32-431.1.2.0.1.el6.x86_64 #1 SMP Fri Dec 13 13:06:13 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
$ cabal install hmatrix
Resolving dependencies...
[1 of 2] Compiling Config ( /tmp/hmatrix-0.15.2.0-9043/hmatrix-0.15.2.0/Config.hs, /tmp/hmatrix-0.15.2.0-9043/hmatrix-0.15.2.0/dist/setup/Config.o )
[2 of 2] Compiling Main ( /tmp/hmatrix-0.15.2.0-9043/hmatrix-0.15.2.0/Setup.lhs, /tmp/hmatrix-0.15.2.0-9043/hmatrix-0.15.2.0/dist/setup/Main.o )
Linking /tmp/hmatrix-0.15.2.0-9043/hmatrix-0.15.2.0/dist/setup/setup ...
Configuring hmatrix-0.15.2.0...
Checking foreign libraries... OK gsl lapack gslcblas
Building hmatrix-0.15.2.0...
Preprocessing library hmatrix-0.15.2.0...
[ 1 of 36] Compiling Data.Packed.Internal.Signatures ( lib/Data/Packed/Internal/Signatures.hs, dist/build/Data/Packed/Internal/Signatures.o )
[ 2 of 36] Compiling Data.Packed.Internal.Common ( lib/Data/Packed/Internal/Common.hs, dist/build/Data/Packed/Internal/Common.o )
[ 3 of 36] Compiling Data.Packed.Internal.Vector ( lib/Data/Packed/Internal/Vector.hs, dist/build/Data/Packed/Internal/Vector.o )
[ 4 of 36] Compiling Numeric.GSL.Vector ( lib/Numeric/GSL/Vector.hs, dist/build/Numeric/GSL/Vector.o )
[ 5 of 36] Compiling Data.Packed.Internal.Matrix ( lib/Data/Packed/Internal/Matrix.hs, dist/build/Data/Packed/Internal/Matrix.o )
[ 6 of 36] Compiling Numeric.Conversion ( lib/Numeric/Conversion.hs, dist/build/Numeric/Conversion.o )
[ 7 of 36] Compiling Data.Packed.Internal ( lib/Data/Packed/Internal.hs, dist/build/Data/Packed/Internal.o )
[ 8 of 36] Compiling Data.Packed.ST ( lib/Data/Packed/ST.hs, dist/build/Data/Packed/ST.o )
[ 9 of 36] Compiling Data.Packed.Foreign ( lib/Data/Packed/Foreign.hs, dist/build/Data/Packed/Foreign.o )
[10 of 36] Compiling Numeric.GSL.Differentiation ( lib/Numeric/GSL/Differentiation.hs, dist/build/Numeric/GSL/Differentiation.o )
[11 of 36] Compiling Numeric.GSL.Integration ( lib/Numeric/GSL/Integration.hs, dist/build/Numeric/GSL/Integration.o )
[12 of 36] Compiling Numeric.GSL.Fourier ( lib/Numeric/GSL/Fourier.hs, dist/build/Numeric/GSL/Fourier.o )
[13 of 36] Compiling Numeric.GSL.Polynomials ( lib/Numeric/GSL/Polynomials.hs, dist/build/Numeric/GSL/Polynomials.o )
[14 of 36] Compiling Numeric.GSL.Internal ( lib/Numeric/GSL/Internal.hs, dist/build/Numeric/GSL/Internal.o )
[15 of 36] Compiling Numeric.GSL.ODE ( lib/Numeric/GSL/ODE.hs, dist/build/Numeric/GSL/ODE.o )
[16 of 36] Compiling Data.Packed.Development ( lib/Data/Packed/Development.hs, dist/build/Data/Packed/Development.o )
[17 of 36] Compiling Data.Packed.Matrix ( lib/Data/Packed/Matrix.hs, dist/build/Data/Packed/Matrix.o )
[18 of 36] Compiling Numeric.GSL.Minimization ( lib/Numeric/GSL/Minimization.hs, dist/build/Numeric/GSL/Minimization.o )
[19 of 36] Compiling Numeric.GSL.Root ( lib/Numeric/GSL/Root.hs, dist/build/Numeric/GSL/Root.o )
[20 of 36] Compiling Numeric.LinearAlgebra.LAPACK ( lib/Numeric/LinearAlgebra/LAPACK.hs, dist/build/Numeric/LinearAlgebra/LAPACK.o )
[21 of 36] Compiling Data.Packed.Vector ( lib/Data/Packed/Vector.hs, dist/build/Data/Packed/Vector.o )
[22 of 36] Compiling Data.Packed ( lib/Data/Packed.hs, dist/build/Data/Packed.o )
[23 of 36] Compiling Numeric.ContainerBoot ( lib/Numeric/ContainerBoot.hs, dist/build/Numeric/ContainerBoot.o )
[24 of 36] Compiling Numeric.Chain ( lib/Numeric/Chain.hs, dist/build/Numeric/Chain.o )
[25 of 36] Compiling Numeric.LinearAlgebra.Algorithms ( lib/Numeric/LinearAlgebra/Algorithms.hs, dist/build/Numeric/LinearAlgebra/Algorithms.o )
[26 of 36] Compiling Numeric.IO ( lib/Numeric/IO.hs, dist/build/Numeric/IO.o )
[27 of 36] Compiling Data.Packed.Random ( lib/Data/Packed/Random.hs, dist/build/Data/Packed/Random.o )
[28 of 36] Compiling Numeric.Container ( lib/Numeric/Container.hs, dist/build/Numeric/Container.o )
[29 of 36] Compiling Numeric.Matrix ( lib/Numeric/Matrix.hs, dist/build/Numeric/Matrix.o )
[30 of 36] Compiling Numeric.Vector ( lib/Numeric/Vector.hs, dist/build/Numeric/Vector.o )
[31 of 36] Compiling Numeric.LinearAlgebra ( lib/Numeric/LinearAlgebra.hs, dist/build/Numeric/LinearAlgebra.o )
[32 of 36] Compiling Numeric.GSL.Fitting ( lib/Numeric/GSL/Fitting.hs, dist/build/Numeric/GSL/Fitting.o )
[33 of 36] Compiling Numeric.GSL ( lib/Numeric/GSL.hs, dist/build/Numeric/GSL.o )
[34 of 36] Compiling Numeric.LinearAlgebra.Util.Convolution ( lib/Numeric/LinearAlgebra/Util/Convolution.hs, dist/build/Numeric/LinearAlgebra/Util/Convolution.o )
[35 of 36] Compiling Numeric.LinearAlgebra.Util ( lib/Numeric/LinearAlgebra/Util.hs, dist/build/Numeric/LinearAlgebra/Util.o )
[36 of 36] Compiling Graphics.Plot ( lib/Graphics/Plot.hs, dist/build/Graphics/Plot.o )
[ 1 of 36] Compiling Data.Packed.Internal.Signatures ( lib/Data/Packed/Internal/Signatures.hs, dist/build/Data/Packed/Internal/Signatures.p_o )
[ 2 of 36] Compiling Data.Packed.Internal.Common ( lib/Data/Packed/Internal/Common.hs, dist/build/Data/Packed/Internal/Common.p_o )
[ 3 of 36] Compiling Data.Packed.Internal.Vector ( lib/Data/Packed/Internal/Vector.hs, dist/build/Data/Packed/Internal/Vector.p_o )
[ 4 of 36] Compiling Numeric.GSL.Vector ( lib/Numeric/GSL/Vector.hs, dist/build/Numeric/GSL/Vector.p_o )
[ 5 of 36] Compiling Data.Packed.Internal.Matrix ( lib/Data/Packed/Internal/Matrix.hs, dist/build/Data/Packed/Internal/Matrix.p_o )
[ 6 of 36] Compiling Numeric.Conversion ( lib/Numeric/Conversion.hs, dist/build/Numeric/Conversion.p_o )
[ 7 of 36] Compiling Data.Packed.Internal ( lib/Data/Packed/Internal.hs, dist/build/Data/Packed/Internal.p_o )
[ 8 of 36] Compiling Data.Packed.ST ( lib/Data/Packed/ST.hs, dist/build/Data/Packed/ST.p_o )
[ 9 of 36] Compiling Data.Packed.Foreign ( lib/Data/Packed/Foreign.hs, dist/build/Data/Packed/Foreign.p_o )
[10 of 36] Compiling Numeric.GSL.Differentiation ( lib/Numeric/GSL/Differentiation.hs, dist/build/Numeric/GSL/Differentiation.p_o )
[11 of 36] Compiling Numeric.GSL.Integration ( lib/Numeric/GSL/Integration.hs, dist/build/Numeric/GSL/Integration.p_o )
[12 of 36] Compiling Numeric.GSL.Fourier ( lib/Numeric/GSL/Fourier.hs, dist/build/Numeric/GSL/Fourier.p_o )
[13 of 36] Compiling Numeric.GSL.Polynomials ( lib/Numeric/GSL/Polynomials.hs, dist/build/Numeric/GSL/Polynomials.p_o )
[14 of 36] Compiling Numeric.GSL.Internal ( lib/Numeric/GSL/Internal.hs, dist/build/Numeric/GSL/Internal.p_o )
[15 of 36] Compiling Numeric.GSL.ODE ( lib/Numeric/GSL/ODE.hs, dist/build/Numeric/GSL/ODE.p_o )
[16 of 36] Compiling Data.Packed.Development ( lib/Data/Packed/Development.hs, dist/build/Data/Packed/Development.p_o )
[17 of 36] Compiling Data.Packed.Matrix ( lib/Data/Packed/Matrix.hs, dist/build/Data/Packed/Matrix.p_o )
[18 of 36] Compiling Numeric.GSL.Minimization ( lib/Numeric/GSL/Minimization.hs, dist/build/Numeric/GSL/Minimization.p_o )
[19 of 36] Compiling Numeric.GSL.Root ( lib/Numeric/GSL/Root.hs, dist/build/Numeric/GSL/Root.p_o )
[20 of 36] Compiling Numeric.LinearAlgebra.LAPACK ( lib/Numeric/LinearAlgebra/LAPACK.hs, dist/build/Numeric/LinearAlgebra/LAPACK.p_o )
[21 of 36] Compiling Data.Packed.Vector ( lib/Data/Packed/Vector.hs, dist/build/Data/Packed/Vector.p_o )
[22 of 36] Compiling Data.Packed ( lib/Data/Packed.hs, dist/build/Data/Packed.p_o )
[23 of 36] Compiling Numeric.ContainerBoot ( lib/Numeric/ContainerBoot.hs, dist/build/Numeric/ContainerBoot.p_o )
[24 of 36] Compiling Numeric.Chain ( lib/Numeric/Chain.hs, dist/build/Numeric/Chain.p_o )
[25 of 36] Compiling Numeric.LinearAlgebra.Algorithms ( lib/Numeric/LinearAlgebra/Algorithms.hs, dist/build/Numeric/LinearAlgebra/Algorithms.p_o )
[26 of 36] Compiling Numeric.IO ( lib/Numeric/IO.hs, dist/build/Numeric/IO.p_o )
[27 of 36] Compiling Data.Packed.Random ( lib/Data/Packed/Random.hs, dist/build/Data/Packed/Random.p_o )
[28 of 36] Compiling Numeric.Container ( lib/Numeric/Container.hs, dist/build/Numeric/Container.p_o )
[29 of 36] Compiling Numeric.Matrix ( lib/Numeric/Matrix.hs, dist/build/Numeric/Matrix.p_o )
[30 of 36] Compiling Numeric.Vector ( lib/Numeric/Vector.hs, dist/build/Numeric/Vector.p_o )
[31 of 36] Compiling Numeric.LinearAlgebra ( lib/Numeric/LinearAlgebra.hs, dist/build/Numeric/LinearAlgebra.p_o )
[32 of 36] Compiling Numeric.GSL.Fitting ( lib/Numeric/GSL/Fitting.hs, dist/build/Numeric/GSL/Fitting.p_o )
[33 of 36] Compiling Numeric.GSL ( lib/Numeric/GSL.hs, dist/build/Numeric/GSL.p_o )
[34 of 36] Compiling Numeric.LinearAlgebra.Util.Convolution ( lib/Numeric/LinearAlgebra/Util/Convolution.hs, dist/build/Numeric/LinearAlgebra/Util/Convolution.p_o )
[35 of 36] Compiling Numeric.LinearAlgebra.Util ( lib/Numeric/LinearAlgebra/Util.hs, dist/build/Numeric/LinearAlgebra/Util.p_o )
[36 of 36] Compiling Graphics.Plot ( lib/Graphics/Plot.hs, dist/build/Graphics/Plot.p_o )
lib/Numeric/GSL/gsl-aux.c: In function ‘integrate_cquad’:
lib/Numeric/GSL/gsl-aux.c:809:0:
error: ‘gsl_integration_cquad_workspace’ undeclared (first use in this function)
lib/Numeric/GSL/gsl-aux.c:809:0:
error: (Each undeclared identifier is reported only once
lib/Numeric/GSL/gsl-aux.c:809:0:
error: for each function it appears in.)
lib/Numeric/GSL/gsl-aux.c:809:0:
error: ‘wk’ undeclared (first use in this function)
lib/Numeric/GSL/gsl-aux.c:809:0:
warning: implicit declaration of function ‘gsl_integration_cquad_workspace_alloc’
lib/Numeric/GSL/gsl-aux.c:813:0:
warning: implicit declaration of function ‘gsl_integration_cquad’
lib/Numeric/GSL/gsl-aux.c:815:0:
warning: implicit declaration of function ‘gsl_integration_cquad_workspace_free’
Failed to install hmatrix-0.15.2.0
cabal: Error: some packages failed to install:
hmatrix-0.15.2.0 failed during the building phase. The exception was:
ExitFailure 1
Greetings.
Did what is written at https://github.com/AlbertoRuiz/hmatrix/blob/master/INSTALL.md:
First issue: the hmatrix-tests package tries to install hmatrix-0.14.1.0 and fails.
Second issue:
Prelude> :m +Data.Packed.Matrix
Prelude Data.Packed.Matrix> (2 >< 3) [1..6]
Loading package array-0.4.0.0 ... linking ... done.
Loading package deepseq-1.3.0.0 ... linking ... done.
Loading package containers-0.4.2.1 ... linking ... done.
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package binary-0.5.1.0 ... linking ... done.
Loading package Win32-2.2.2.0 ... linking ... done.
Loading package filepath-1.3.0.0 ... linking ... done.
Loading package old-locale-1.0.0.4 ... linking ... done.
Loading package old-time-1.1.0.0 ... linking ... done.
Loading package directory-1.1.0.2 ... linking ... done.
Loading package process-1.1.0.1 ... linking ... done.
Loading package storable-complex-0.2.1 ... linking ... done.
Loading package primitive-0.4.1 ... linking ... done.
Loading package vector-0.9.1 ... linking ... done.
Loading package hmatrix-0.13.1.0 ... : gsl-0: ═х эрщфхэ єърчрээ√щ ьюфєы№.
can't load .so/.DLL for: gsl-0.dll (addDLL: could not load DLL)
(The weird string "═х эрщфхэ єърчрээ√щ ьюфєы№" means "The specified module not found").
What I do wrong?
to match zipVectorWith
lib/Numeric/ContainerBoot.hs:515:15:
Conflicting family instance declarations:
BoundsOf (a -> a) -- Defined at lib/Numeric/ContainerBoot.hs:515:15
BoundsOf (a -> a -> a)
-- Defined at lib/Numeric/ContainerBoot.hs:516:15
lib/Numeric/ContainerBoot.hs:520:15:
Conflicting family instance declarations:
ContainerOf (a -> a)
-- Defined at lib/Numeric/ContainerBoot.hs:520:15
ContainerOf (a -> a -> a)
-- Defined at lib/Numeric/ContainerBoot.hs:521:15
The complete build log is at http://hydra.cryp.to/build/44245/nixlog/2/raw.
When trying to build hstatistics, I get this error when trying to build hmatrix on OSX 10.6 - 64 bit. With GHC-7.0.4 64 bit as well.
bverdier-mbp:haskell bverdier$ cabal install hmatrix
Resolving dependencies...
[1 of 2] Compiling Config ( /var/folders/7l/7l2zlkMXEd45wvc5uOoQH0QFDwQ/-Tmp-/hmatrix-0.13.1.033264/hmatrix-0.13.1.0/Config.hs, /var/folders/7l/7l2zlkMXEd45wvc5uOoQH0QFDwQ/-Tmp-/hmatrix-0.13.1.033264/hmatrix-0.13.1.0/dist/setup/Config.o )
[2 of 2] Compiling Main ( /var/folders/7l/7l2zlkMXEd45wvc5uOoQH0QFDwQ/-Tmp-/hmatrix-0.13.1.033264/hmatrix-0.13.1.0/Setup.lhs, /var/folders/7l/7l2zlkMXEd45wvc5uOoQH0QFDwQ/-Tmp-/hmatrix-0.13.1.033264/hmatrix-0.13.1.0/dist/setup/Main.o )
Linking /var/folders/7l/7l2zlkMXEd45wvc5uOoQH0QFDwQ/-Tmp-/hmatrix-0.13.1.033264/hmatrix-0.13.1.0/dist/setup/setup ...
ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame
Configuring hmatrix-0.13.1.0...
Checking foreign libraries... FAIL
*** Sorry, I can't link GSL.
*** Please make sure that the appropriate -dev packages are installed.
*** You can also specify the required libraries using
*** cabal install hmatrix --configure-option=link:lib1,lib2,lib3,etc.
setup: Package hmatrix-0.13.1.0 can't be built on this system.
cabal: Error: some packages failed to install:
hmatrix-0.13.1.0 failed during the building phase. The exception was:
ExitFailure 1
Any help would be really appriciated.
orth(somematrix)
is built into MATLAB but doesn't seem to be available in the Haskell hmatrix library.
The installation instructions recommend using the gsl binaries at https://github.com/downloads/AlbertoRuiz/hmatrix/gsl-lapack-windows.zip under windows. Unfortunately this yields the following error. It seems the file gsl_odeiv2.h is not included.
[35 of 35] Compiling Graphics.Plot ( lib\Graphics\Plot.hs, dist\build\Graphics\Plot.o )
In file included from lib\Numeric\GSL\gsl-aux.c:1334:0:
lib\Numeric\GSL\gsl-ode.c:95:28:
fatal error: gsl/gsl_odeiv2.h: No such file or directory
compilation terminated.
Failed to install hmatrix-0.14.1.0
cabal: Error: some packages failed to install:
hmatrix-0.14.1.0 failed during the building phase. The exception was:
ExitFailure 1
Tests fail with message free(): invalid pointer
on i686-pc-linux-gnu ghc-7.0.4.
Provoking test is test (svdProp4 . cM)
dist/build/basic/basic
------ mult Double
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ mult Float
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ sub-trans
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ ctrans
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ lu
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ inv (linearSolve)
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ luSolve
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ cholSolve
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ luSolveLS
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests (5% trivial).
+++ OK, passed 100 tests (5% trivial).
------ pinv (linearSolveSVD)
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ det
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
------ svd
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
*** glibc detected *** dist/build/basic/basic: free(): invalid pointer: 0x09796790 ***
Aborted
The documentation doesn't build because GSL does not appear to exist on the server
http://hackage.haskell.org/package/hmatrix-0.15.2.0/reports/1/log
I am not sure what can be done. Possibly the admins for the server could add GSL but it might be better to find some way of generating the documentation without requiring GSL to be present.
Hi, I think this program should print two (nearly) identity matrices:
import Numeric.LinearAlgebra.LAPACK
import Numeric.LinearAlgebra
a = (2><2) [1,2,3,4]
a'a = trans a `multiplyR` a
aInv1 = linearSolveR a'a (ident 2)
aInv2 = cholSolveR a'a (ident 2)
main = do
print $ aInv1 `multiplyR` a'a
print $ aInv2 `multiplyR` a'a
I get:
(2><2)
[ 1.0000000000000115, 7.105427357601002e-15
, -7.105427357601002e-15, 0.9999999999999964 ]
(2><2)
[ 0.1, 0.1386
, 1.734723475976807e-18, 1.0000000000000026e-3 ]
Only the first one is good.
Is it possible to have a NFData instance for the Matrix type? I didn't reviewed the code carefully, but I think the type is strict in all its fields so the instance would be trivial.
It is a problem that comes up often enough for it to be useful. Just a feature request. All I'm saying is it would be nice.
I use the function conv2 to compute the convolution of two matrices:
conv2 a b
where a is a 3-by-3 matrix and b is a matrix of about 800-by-600
And I waited and waited, but nothing happens and the computing is still on!\
However, a 400-by-250 matrix will work and it takes about 20 seconds.
Are the functions provided in hmatrix working well for large matrices?
gsl-lapack-windows.zip contains an old GSL version lacking the new ODE interface
workaround:
cabal install hmatrix-0.13.1.0
When trying to install the library via msys, after unpacking the archive suggested in the installation instructions, I get the following error:
lib\Numeric\GSL\gsl-aux.c:1:29:
fatal error: gsl/gsl_complex.h: No such file or directory
compilation terminated.
Failed to install hmatrix-0.13.1.0
cabal.exe: Error: some packages failed to install:
hmatrix-0.13.1.0 failed during the building phase. The exception was:
ExitFailure 1
The strange thing is that the missing file is indeed there;
I should add that the other files are located without any error.
Do you have any suggestion?
When I give wrong values to uniRoot (and maybe other functions), it crashes with an error message. It may be better to handle errors more graciously by throwing an exception, or showing failure in the return type of the function. [edit] I would suggest for pure functions to return a Maybe type when the algorithm cannot find a solution with the given parameters. It may be also a good idea to have a default handler throw exceptions for unexpected errors, rather than crashing the program (or ghci).
Here's the error message.
Loading package hmatrix-0.15.2.1 ... : can't load .so/.DLL for: /home/amy/.cabal/lib/x86_64-linux-ghc-7.8.2/hmatrix-0.15.2.1/libHShmatrix-0.15.2.1-ghc7.8.2.so (/home/amy/.cabal/lib/x86_64-linux-ghc-7.8.2/hmatrix-0.15.2.1/libHShmatrix-0.15.2.1-ghc7.8.2.so: undefined symbol: gsl_odeiv2_step_rk8pd)
I have gsl-1.16 installed, and I did ldconfig, but the problem persists.
[amy@atsfsx115 creatur-realtra]$ ls -l /usr/local/lib/libgsl.*
-rw-r--r-- 1 root root 14577942 May 16 12:24 /usr/local/lib/libgsl.a
-rwxr-xr-x 1 root root 917 May 16 12:24 /usr/local/lib/libgsl.la
lrwxrwxrwx 1 root root 16 May 16 12:24 /usr/local/lib/libgsl.so -> libgsl.so.0.17.0
lrwxrwxrwx 1 root root 16 May 16 12:24 /usr/local/lib/libgsl.so.0 -> libgsl.so.0.17.0
-rwxr-xr-x 1 root root 8343871 May 16 12:24 /usr/local/lib/libgsl.so.0.17.0
Hi, I'm packaging hmatrix for NixOS. I ran some test builds with older GHC versions, and I noticed that GHC 7.4.2 can build the package fine, but the Haddock version that comes with that compiler fails to generate the documentation. I wonder if it may be possible (and even easy) to fix that issue?
The complete build log is at http://hydra.cryp.to/build/88232/nixlog/1/raw.
let me and other folks know when the time comes! :)
The following program segfaults on amd/64bit/ubuntu linux 11.10/ghc-7.0.3
module Test where
import Data.Packed.Matrix ( buildMatrix )
import Numeric.LinearAlgebra.LAPACK ( eigR )
main = print $ eigR m where
m = buildMatrix 100 100 (\(x, y) -> fromIntegral $! x+y)
when compiled with any backend, with or without optimization.
I have installed gsl using homebrew and most things seem (hmatrix and hmatrix-tests) to work apart from the hmatrix-special package. When building hmatrix-special using cabal, it looks for the gsl library in opt: ld: warning: directory not found for option '-L/opt/local/lib/'
.
How can I change the path in order for cabal to point to the right gsl directory (gsl lib is installed in /usr/local/Cellar/gsl/1.15/lib/)?
in gsl_interp.h, gsl_spline.h, gsl_bspline.h
I have an application where I forkIO some threads, each calling Numeric.LinearProgramming.simplex.
Using +RTS -N I get segfaults, e.g.,
glp_free: memory allocation error
Error detected in file glpenv05.c at line 145
When I do this with the non-threaded RTS, it works fine.
hmatrix-glpk-0.3.1 , ghc-7.6.2 , linux-amd64 , kernel 3.5.0 , libglpk0 4.45
Hi,
the license file is is currently somewhat lacking, as there are multiple versions of the GPL around. Which version of the GPL does apply to hmatrix? I suggest you put the full license text into LICENSE, as it is common practice.
Thanks,
Joachim
Interface to multiple integration routines:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.