From 5eba1bc309d7845366e8d00849d85426bf8f666d Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Thu, 8 Jan 2015 13:55:57 +0100 Subject: update other pkgs to ghc-7.10 --- packages/gsl/hmatrix-gsl.cabal | 4 ++-- packages/gsl/src/Graphics/Plot.hs | 4 ++-- packages/gsl/src/Numeric/GSL/Fitting.hs | 16 +++++++++------- packages/gsl/src/Numeric/GSL/Fourier.hs | 5 ++--- packages/gsl/src/Numeric/GSL/IO.hs | 2 +- packages/gsl/src/Numeric/GSL/Internal.hs | 7 +++---- packages/gsl/src/Numeric/GSL/LinearAlgebra.hs | 2 +- packages/gsl/src/Numeric/GSL/Minimization.hs | 17 ++++++++++------- packages/gsl/src/Numeric/GSL/ODE.hs | 16 ++++++++++------ packages/gsl/src/Numeric/GSL/Polynomials.hs | 7 +++---- packages/gsl/src/Numeric/GSL/Random.hs | 16 +++++++++------- packages/gsl/src/Numeric/GSL/Root.hs | 18 ++++++++++-------- packages/gsl/src/Numeric/GSL/Vector.hs | 3 +-- 13 files changed, 63 insertions(+), 54 deletions(-) (limited to 'packages/gsl') diff --git a/packages/gsl/hmatrix-gsl.cabal b/packages/gsl/hmatrix-gsl.cabal index 95fa3ed..70e4246 100644 --- a/packages/gsl/hmatrix-gsl.cabal +++ b/packages/gsl/hmatrix-gsl.cabal @@ -1,5 +1,5 @@ Name: hmatrix-gsl -Version: 0.16.0.3 +Version: 0.17.0.0 License: GPL License-file: LICENSE Author: Alberto Ruiz @@ -25,7 +25,7 @@ flag onlygsl library - Build-Depends: base<5, hmatrix>=0.16, array, vector, + Build-Depends: base<5, hmatrix>=0.17, array, vector, process, random diff --git a/packages/gsl/src/Graphics/Plot.hs b/packages/gsl/src/Graphics/Plot.hs index 0ea41ac..d2ea192 100644 --- a/packages/gsl/src/Graphics/Plot.hs +++ b/packages/gsl/src/Graphics/Plot.hs @@ -27,13 +27,13 @@ module Graphics.Plot( ) where -import Numeric.Container +import Numeric.LinearAlgebra.HMatrix import Data.List(intersperse) import System.Process (system) -- | From vectors x and y, it generates a pair of matrices to be used as x and y arguments for matrix functions. meshdom :: Vector Double -> Vector Double -> (Matrix Double , Matrix Double) -meshdom r1 r2 = (outer r1 (constant 1 (dim r2)), outer (constant 1 (dim r1)) r2) +meshdom r1 r2 = (outer r1 (konst 1 (size r2)), outer (konst 1 (size r1)) r2) {- | Draws a 3D surface representation of a real matrix. diff --git a/packages/gsl/src/Numeric/GSL/Fitting.hs b/packages/gsl/src/Numeric/GSL/Fitting.hs index 0a92373..db9d82f 100644 --- a/packages/gsl/src/Numeric/GSL/Fitting.hs +++ b/packages/gsl/src/Numeric/GSL/Fitting.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE FlexibleContexts #-} + {- | Module : Numeric.GSL.Fitting Copyright : (c) Alberto Ruiz 2010 @@ -50,7 +52,7 @@ module Numeric.GSL.Fitting ( fitModelScaled, fitModel ) where -import Numeric.LinearAlgebra +import Numeric.LinearAlgebra.HMatrix import Numeric.GSL.Internal import Foreign.Ptr(FunPtr, freeHaskellFunPtr) @@ -80,13 +82,13 @@ nlFitting :: FittingMethod nlFitting method epsabs epsrel maxit fun jac xinit = nlFitGen (fi (fromEnum method)) fun jac xinit epsabs epsrel maxit nlFitGen m f jac xiv epsabs epsrel maxit = unsafePerformIO $ do - let p = dim xiv - n = dim (f xiv) + let p = size xiv + n = size (f xiv) fp <- mkVecVecfun (aux_vTov (checkdim1 n p . f)) jp <- mkVecMatfun (aux_vTom (checkdim2 n p . jac)) rawpath <- createMatrix RowMajor maxit (2+p) app2 (c_nlfit m fp jp epsabs epsrel (fi maxit) (fi n)) vec xiv mat rawpath "c_nlfit" - let it = round (rawpath @@> (maxit-1,0)) + let it = round (rawpath `atIndex` (maxit-1,0)) path = takeRows it rawpath [sol] = toRows $ dropRows (it-1) path freeHaskellFunPtr fp @@ -99,7 +101,7 @@ foreign import ccall safe "nlfit" ------------------------------------------------------- checkdim1 n _p v - | dim v == n = v + | size v == n = v | otherwise = error $ "Error: "++ show n ++ " components expected in the result of the function supplied to nlFitting" @@ -114,9 +116,9 @@ err (model,deriv) dat vsol = zip sol errs where sol = toList vsol c = max 1 (chi/sqrt (fromIntegral dof)) dof = length dat - (rows cov) - chi = norm2 (fromList $ cost (resMs model) dat sol) + chi = norm_2 (fromList $ cost (resMs model) dat sol) js = fromLists $ jacobian (resDs deriv) dat sol - cov = inv $ trans js <> js + cov = inv $ tr js <> js errs = toList $ scalar c * sqrt (takeDiag cov) diff --git a/packages/gsl/src/Numeric/GSL/Fourier.hs b/packages/gsl/src/Numeric/GSL/Fourier.hs index 734325b..d824b4f 100644 --- a/packages/gsl/src/Numeric/GSL/Fourier.hs +++ b/packages/gsl/src/Numeric/GSL/Fourier.hs @@ -16,14 +16,13 @@ module Numeric.GSL.Fourier ( ifft ) where -import Data.Packed +import Numeric.LinearAlgebra.HMatrix import Numeric.GSL.Internal -import Data.Complex import Foreign.C.Types import System.IO.Unsafe (unsafePerformIO) genfft code v = unsafePerformIO $ do - r <- createVector (dim v) + r <- createVector (size v) app2 (c_fft code) vec v vec r "fft" return r diff --git a/packages/gsl/src/Numeric/GSL/IO.hs b/packages/gsl/src/Numeric/GSL/IO.hs index 0d6031a..936f6bf 100644 --- a/packages/gsl/src/Numeric/GSL/IO.hs +++ b/packages/gsl/src/Numeric/GSL/IO.hs @@ -14,7 +14,7 @@ module Numeric.GSL.IO ( fileDimensions, loadMatrix, fromFile ) where -import Data.Packed +import Numeric.LinearAlgebra.HMatrix hiding(saveMatrix, loadMatrix) import Numeric.GSL.Vector import System.Process(readProcess) diff --git a/packages/gsl/src/Numeric/GSL/Internal.hs b/packages/gsl/src/Numeric/GSL/Internal.hs index a1c4e0c..a269224 100644 --- a/packages/gsl/src/Numeric/GSL/Internal.hs +++ b/packages/gsl/src/Numeric/GSL/Internal.hs @@ -22,14 +22,13 @@ module Numeric.GSL.Internal( aux_vTom, createV, createMIO, - module Data.Packed.Development, + module Numeric.LinearAlgebra.Devel, check, Res,TV,TM,TCV,TCM ) where -import Data.Packed -import Data.Packed.Development hiding (check) -import Data.Complex +import Numeric.LinearAlgebra.HMatrix +import Numeric.LinearAlgebra.Devel hiding (check) import Foreign.Marshal.Array(copyArray) import Foreign.Ptr(Ptr, FunPtr) diff --git a/packages/gsl/src/Numeric/GSL/LinearAlgebra.hs b/packages/gsl/src/Numeric/GSL/LinearAlgebra.hs index 17e2258..cb78bf4 100644 --- a/packages/gsl/src/Numeric/GSL/LinearAlgebra.hs +++ b/packages/gsl/src/Numeric/GSL/LinearAlgebra.hs @@ -15,7 +15,7 @@ module Numeric.GSL.LinearAlgebra ( fileDimensions, loadMatrix, fromFile ) where -import Data.Packed +import Numeric.LinearAlgebra.HMatrix hiding (RandDist,randomVector,saveMatrix,loadMatrix) import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) import Foreign.Marshal.Alloc(free) diff --git a/packages/gsl/src/Numeric/GSL/Minimization.hs b/packages/gsl/src/Numeric/GSL/Minimization.hs index 056d463..00e0619 100644 --- a/packages/gsl/src/Numeric/GSL/Minimization.hs +++ b/packages/gsl/src/Numeric/GSL/Minimization.hs @@ -1,3 +1,6 @@ +{-# LANGUAGE FlexibleContexts #-} + + {- | Module : Numeric.GSL.Minimization Copyright : (c) Alberto Ruiz 2006-9 @@ -56,7 +59,7 @@ module Numeric.GSL.Minimization ( ) where -import Data.Packed +import Numeric.LinearAlgebra.HMatrix hiding(step) import Numeric.GSL.Internal import Foreign.Ptr(Ptr, FunPtr, freeHaskellFunPtr) @@ -99,7 +102,7 @@ uniMinimizeGen m f xmin xl xu epsrel maxit = unsafePerformIO $ do rawpath <- createMIO maxit 4 (c_uniMinize m fp epsrel (fi maxit) xmin xl xu) "uniMinimize" - let it = round (rawpath @@> (maxit-1,0)) + let it = round (rawpath `atIndex` (maxit-1,0)) path = takeRows it rawpath [sol] = toLists $ dropRows (it-1) path freeHaskellFunPtr fp @@ -137,13 +140,13 @@ minimize method eps maxit sz f xi = v2l $ minimizeV method eps maxit (fromList s ww2 w1 o1 w2 o2 f = w1 o1 $ \a1 -> w2 o2 $ \a2 -> f a1 a2 minimizeV method eps maxit szv f xiv = unsafePerformIO $ do - let n = dim xiv + let n = size xiv fp <- mkVecfun (iv f) rawpath <- ww2 vec xiv vec szv $ \xiv' szv' -> createMIO maxit (n+3) (c_minimize (fi (fromEnum method)) fp eps (fi maxit) // xiv' // szv') "minimize" - let it = round (rawpath @@> (maxit-1,0)) + let it = round (rawpath `atIndex` (maxit-1,0)) path = takeRows it rawpath sol = flatten $ dropColumns 3 $ dropRows (it-1) path freeHaskellFunPtr fp @@ -191,7 +194,7 @@ minimizeD method eps maxit istep tol f df xi = v2l $ minimizeVD minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do - let n = dim xiv + let n = size xiv f' = f df' = (checkdim1 n . df) fp <- mkVecfun (iv f') @@ -200,7 +203,7 @@ minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do createMIO maxit (n+2) (c_minimizeD (fi (fromEnum method)) fp dfp istep tol eps (fi maxit) // xiv') "minimizeD" - let it = round (rawpath @@> (maxit-1,0)) + let it = round (rawpath `atIndex` (maxit-1,0)) path = takeRows it rawpath sol = flatten $ dropColumns 2 $ dropRows (it-1) path freeHaskellFunPtr fp @@ -217,6 +220,6 @@ foreign import ccall safe "gsl-aux.h minimizeD" --------------------------------------------------------------------- checkdim1 n v - | dim v == n = v + | size v == n = v | otherwise = error $ "Error: "++ show n ++ " components expected in the result of the gradient supplied to minimizeD" diff --git a/packages/gsl/src/Numeric/GSL/ODE.hs b/packages/gsl/src/Numeric/GSL/ODE.hs index 7549a65..3258b83 100644 --- a/packages/gsl/src/Numeric/GSL/ODE.hs +++ b/packages/gsl/src/Numeric/GSL/ODE.hs @@ -1,3 +1,6 @@ +{-# LANGUAGE FlexibleContexts #-} + + {- | Module : Numeric.GSL.ODE Copyright : (c) Alberto Ruiz 2010 @@ -32,7 +35,7 @@ module Numeric.GSL.ODE ( odeSolve, odeSolveV, ODEMethod(..), Jacobian ) where -import Data.Packed +import Numeric.LinearAlgebra.HMatrix import Numeric.GSL.Internal import Foreign.Ptr(FunPtr, nullFunPtr, freeHaskellFunPtr) @@ -68,7 +71,7 @@ odeSolve -> Vector Double -- ^ desired solution times -> Matrix Double -- ^ solution odeSolve xdot xi ts = odeSolveV RKf45 hi epsAbs epsRel (l2v xdot) (fromList xi) ts - where hi = (ts@>1 - ts@>0)/100 + where hi = (ts!1 - ts!0)/100 epsAbs = 1.49012e-08 epsRel = 1.49012e-08 l2v f = \t -> fromList . f t . toList @@ -107,14 +110,14 @@ odeSolveV' -> Vector Double -- ^ desired solution times -> Matrix Double -- ^ solution odeSolveV' method mbjac h epsAbs epsRel f xiv ts = unsafePerformIO $ do - let n = dim xiv + let n = size xiv fp <- mkDoubleVecVecfun (\t -> aux_vTov (checkdim1 n . f t)) jp <- case mbjac of Just jac -> mkDoubleVecMatfun (\t -> aux_vTom (checkdim2 n . jac t)) Nothing -> return nullFunPtr sol <- vec xiv $ \xiv' -> vec (checkTimes ts) $ \ts' -> - createMIO (dim ts) n + createMIO (size ts) n (ode_c (method) h epsAbs epsRel fp jp // xiv' // ts' ) "ode" freeHaskellFunPtr fp @@ -126,7 +129,7 @@ foreign import ccall safe "ode" ------------------------------------------------------- checkdim1 n v - | dim v == n = v + | size v == n = v | otherwise = error $ "Error: "++ show n ++ " components expected in the result of the function supplied to odeSolve" @@ -135,6 +138,7 @@ checkdim2 n m | otherwise = error $ "Error: "++ show n ++ "x" ++ show n ++ " Jacobian expected in odeSolve" -checkTimes ts | dim ts > 1 && all (>0) (zipWith subtract ts' (tail ts')) = ts +checkTimes ts | size ts > 1 && all (>0) (zipWith subtract ts' (tail ts')) = ts | otherwise = error "odeSolve requires increasing times" where ts' = toList ts + diff --git a/packages/gsl/src/Numeric/GSL/Polynomials.hs b/packages/gsl/src/Numeric/GSL/Polynomials.hs index b1be85d..246e301 100644 --- a/packages/gsl/src/Numeric/GSL/Polynomials.hs +++ b/packages/gsl/src/Numeric/GSL/Polynomials.hs @@ -16,9 +16,8 @@ module Numeric.GSL.Polynomials ( polySolve ) where -import Data.Packed +import Numeric.LinearAlgebra.HMatrix import Numeric.GSL.Internal -import Data.Complex import System.IO.Unsafe (unsafePerformIO) #if __GLASGOW_HASKELL__ >= 704 @@ -47,8 +46,8 @@ polySolve :: [Double] -> [Complex Double] polySolve = toList . polySolve' . fromList polySolve' :: Vector Double -> Vector (Complex Double) -polySolve' v | dim v > 1 = unsafePerformIO $ do - r <- createVector (dim v-1) +polySolve' v | size v > 1 = unsafePerformIO $ do + r <- createVector (size v-1) app2 c_polySolve vec v vec r "polySolve" return r | otherwise = error "polySolve on a polynomial of degree zero" diff --git a/packages/gsl/src/Numeric/GSL/Random.hs b/packages/gsl/src/Numeric/GSL/Random.hs index f1f49e5..139c921 100644 --- a/packages/gsl/src/Numeric/GSL/Random.hs +++ b/packages/gsl/src/Numeric/GSL/Random.hs @@ -21,11 +21,13 @@ module Numeric.GSL.Random ( ) where import Numeric.GSL.Vector -import Numeric.LinearAlgebra(cholSH) -import Numeric.Container hiding ( +import Numeric.LinearAlgebra.HMatrix hiding ( randomVector, gaussianSample, - uniformSample + uniformSample, + Seed, + rand, + randn ) import System.Random(randomIO) @@ -40,10 +42,10 @@ gaussianSample :: Seed -> Matrix Double -- ^ covariance matrix -> Matrix Double -- ^ result gaussianSample seed n med cov = m where - c = dim med + c = size med meds = konst 1 n `outer` med rs = reshape c $ randomVector seed Gaussian (c * n) - m = rs `mXm` cholSH cov `add` meds + m = rs <> cholSH cov + meds -- | Obtains a matrix whose rows are pseudorandom samples from a multivariate -- uniform distribution. @@ -55,10 +57,10 @@ uniformSample seed n rgs = m where (as,bs) = unzip rgs a = fromList as cs = zipWith subtract as bs - d = dim a + d = size a dat = toRows $ reshape n $ randomVector seed Uniform (n*d) am = konst 1 n `outer` a - m = fromColumns (zipWith scale cs dat) `add` am + m = fromColumns (zipWith scale cs dat) + am -- | pseudorandom matrix with uniform elements between 0 and 1 randm :: RandDist diff --git a/packages/gsl/src/Numeric/GSL/Root.hs b/packages/gsl/src/Numeric/GSL/Root.hs index b9f3b94..724f32f 100644 --- a/packages/gsl/src/Numeric/GSL/Root.hs +++ b/packages/gsl/src/Numeric/GSL/Root.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE FlexibleContexts #-} + {- | Module : Numeric.GSL.Root Copyright : (c) Alberto Ruiz 2009 @@ -39,7 +41,7 @@ module Numeric.GSL.Root ( rootJ, RootMethodJ(..), ) where -import Data.Packed +import Numeric.LinearAlgebra.HMatrix import Numeric.GSL.Internal import Foreign.Ptr(FunPtr, freeHaskellFunPtr) import Foreign.C.Types @@ -69,7 +71,7 @@ uniRootGen m f xl xu epsrel maxit = unsafePerformIO $ do rawpath <- createMIO maxit 4 (c_root m fp epsrel (fi maxit) xl xu) "root" - let it = round (rawpath @@> (maxit-1,0)) + let it = round (rawpath `atIndex` (maxit-1,0)) path = takeRows it rawpath [sol] = toLists $ dropRows (it-1) path freeHaskellFunPtr fp @@ -100,7 +102,7 @@ uniRootJGen m f df x epsrel maxit = unsafePerformIO $ do rawpath <- createMIO maxit 2 (c_rootj m fp dfp epsrel (fi maxit) x) "rootj" - let it = round (rawpath @@> (maxit-1,0)) + let it = round (rawpath `atIndex` (maxit-1,0)) path = takeRows it rawpath [sol] = toLists $ dropRows (it-1) path freeHaskellFunPtr fp @@ -132,13 +134,13 @@ root method epsabs maxit fun xinit = rootGen (fi (fromEnum method)) fun xinit ep rootGen m f xi epsabs maxit = unsafePerformIO $ do let xiv = fromList xi - n = dim xiv + n = size xiv fp <- mkVecVecfun (aux_vTov (checkdim1 n . fromList . f . toList)) rawpath <- vec xiv $ \xiv' -> createMIO maxit (2*n+1) (c_multiroot m fp epsabs (fi maxit) // xiv') "multiroot" - let it = round (rawpath @@> (maxit-1,0)) + let it = round (rawpath `atIndex` (maxit-1,0)) path = takeRows it rawpath [sol] = toLists $ dropRows (it-1) path freeHaskellFunPtr fp @@ -169,14 +171,14 @@ rootJ method epsabs maxit fun jac xinit = rootJGen (fi (fromEnum method)) fun ja rootJGen m f jac xi epsabs maxit = unsafePerformIO $ do let xiv = fromList xi - n = dim xiv + n = size xiv fp <- mkVecVecfun (aux_vTov (checkdim1 n . fromList . f . toList)) jp <- mkVecMatfun (aux_vTom (checkdim2 n . fromLists . jac . toList)) rawpath <- vec xiv $ \xiv' -> createMIO maxit (2*n+1) (c_multirootj m fp jp epsabs (fi maxit) // xiv') "multiroot" - let it = round (rawpath @@> (maxit-1,0)) + let it = round (rawpath `atIndex` (maxit-1,0)) path = takeRows it rawpath [sol] = toLists $ dropRows (it-1) path freeHaskellFunPtr fp @@ -189,7 +191,7 @@ foreign import ccall safe "multirootj" ------------------------------------------------------- checkdim1 n v - | dim v == n = v + | size v == n = v | otherwise = error $ "Error: "++ show n ++ " components expected in the result of the function supplied to root" diff --git a/packages/gsl/src/Numeric/GSL/Vector.hs b/packages/gsl/src/Numeric/GSL/Vector.hs index af79f32..0cd99eb 100644 --- a/packages/gsl/src/Numeric/GSL/Vector.hs +++ b/packages/gsl/src/Numeric/GSL/Vector.hs @@ -14,8 +14,7 @@ module Numeric.GSL.Vector ( fwriteVector, freadVector, fprintfVector, fscanfVector ) where -import Data.Packed -import Numeric.LinearAlgebra(RandDist(..)) +import Numeric.LinearAlgebra.HMatrix hiding(randomVector, saveMatrix) import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) import Foreign.Marshal.Alloc(free) -- cgit v1.2.3