hmatrix

Efficient Haskell equivalent to NumPy's argsort

亡梦爱人 提交于 2020-01-01 06:05:51
问题 Is there a standard Haskell equivalent to NumPy's argsort function? I'm using HMatrix and, so, would like a function compatible with Vector R which is an alias for Data.Vector.Storable.Vector Double . The argSort function below is the implementation I'm currently using: {-# LANGUAGE NoImplicitPrelude #-} module Main where import qualified Data.List as L import qualified Data.Vector as V import qualified Data.Vector.Storable as VS import Prelude (($), Double, IO, Int, compare, print, snd) a ::

How to get more performance out of automatic differentiation?

左心房为你撑大大i 提交于 2019-12-22 01:38:56
问题 I am having a hard time optimizing a program that is relying on ad s conjugateGradientDescent function for most of it's work. Basically my code is a translation of an old papers code that is written in Matlab and C. I have not measured it, but that code is running at several iterations per second. Mine is in the order of minutes per iteration ... The code is available in this repositories: https://github.com/fhaust/aer https://github.com/fhaust/aer-utils The code in question can be run by

How to do automatic differentiation on hmatrix?

帅比萌擦擦* 提交于 2019-12-19 03:38:07
问题 Sooooo ... as it turns out going from fake matrices to hmatrix datatypes turns out to be nontrivial :) Preamble for reference: {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ParallelListComp #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FlexibleContexts #-} import Numeric.LinearAlgebra.HMatrix import Numeric.AD reconstruct :: (Container Vector a, Num (Vector a)) => [a] -> [Matrix a] -> Matrix a reconstruct as φs = sum [ a `scale` φ | a <- as | φ <- φs ]

How to build hmatrix with BLAS and LAPACK under Windows?

孤者浪人 提交于 2019-12-07 07:38:55
问题 Windows 10 x64 Cabal 1.22 I'm following steps in Windows section https://github.com/AlbertoRuiz/hmatrix/blob/master/INSTALL.md I downloaded hmatrix sources and gsl-lapack-windows.zip. When I try to install hmatrix with: D:\Projects\workspace\hmatrix-0.16.1.5>cabal install --extra-include-dirs=D:\Projects\workspace\gsl-lapack-windows\ --extra-lib-dirs=d:\Projects\workspace\gsl-lapack-windows\ I got this message that I'm still cannot solve: Configuring hmatrix-0.16.1.5... Failed to install

How to get more performance out of automatic differentiation?

こ雲淡風輕ζ 提交于 2019-12-04 22:57:24
I am having a hard time optimizing a program that is relying on ad s conjugateGradientDescent function for most of it's work. Basically my code is a translation of an old papers code that is written in Matlab and C. I have not measured it, but that code is running at several iterations per second. Mine is in the order of minutes per iteration ... The code is available in this repositories: https://github.com/fhaust/aer https://github.com/fhaust/aer-utils The code in question can be run by following these commands: $ cd aer-utils $ cabal sandbox init $ cabal sandbox add-source ../aer $ cabal

Efficient Haskell equivalent to NumPy's argsort

邮差的信 提交于 2019-12-03 16:50:58
Is there a standard Haskell equivalent to NumPy's argsort function? I'm using HMatrix and, so, would like a function compatible with Vector R which is an alias for Data.Vector.Storable.Vector Double . The argSort function below is the implementation I'm currently using: {-# LANGUAGE NoImplicitPrelude #-} module Main where import qualified Data.List as L import qualified Data.Vector as V import qualified Data.Vector.Storable as VS import Prelude (($), Double, IO, Int, compare, print, snd) a :: VS.Vector Double a = VS.fromList [40.0, 20.0, 10.0, 11.0] argSort :: VS.Vector Double -> V.Vector Int

How to do automatic differentiation on hmatrix?

旧巷老猫 提交于 2019-11-30 21:37:51
Sooooo ... as it turns out going from fake matrices to hmatrix datatypes turns out to be nontrivial :) Preamble for reference: {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ParallelListComp #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FlexibleContexts #-} import Numeric.LinearAlgebra.HMatrix import Numeric.AD reconstruct :: (Container Vector a, Num (Vector a)) => [a] -> [Matrix a] -> Matrix a reconstruct as φs = sum [ a `scale` φ | a <- as | φ <- φs ] preserveInfo :: (Container Vector a, Num (Vector a)) => Matrix a -> [a] -> [Matrix a] -> a preserveInfo img as