hTensor 0.7.0.1 → 0.8.0
raw patch · 6 files changed
+24/−15 lines, 6 filesdep ~hmatrixPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hmatrix
API changes (from Hackage documentation)
- Numeric.LinearAlgebra.Array: instance (Coord t, Compat i) => Eq (NArray i t)
+ Numeric.LinearAlgebra.Array: instance (Eq t, Coord t, Compat i) => Eq (NArray i t)
- Numeric.LinearAlgebra.Array.Solve: mlSolve :: (Compat i, Coord t, Num (NArray i t)) => ALSParam i t -> [NArray i t] -> [NArray i t] -> NArray i t -> ([NArray i t], [Double])
+ Numeric.LinearAlgebra.Array.Solve: mlSolve :: (Compat i, Coord t, Num (NArray i t), Show (NArray i t)) => ALSParam i t -> [NArray i t] -> [NArray i t] -> NArray i t -> ([NArray i t], [Double])
- Numeric.LinearAlgebra.Array.Solve: mlSolveH :: (Compat i, Coord t, Num (NArray i t)) => ALSParam i t -> [NArray i t] -> [NArray i t] -> ([NArray i t], [Double])
+ Numeric.LinearAlgebra.Array.Solve: mlSolveH :: (Compat i, Coord t, Num (NArray i t), Show (NArray i t)) => ALSParam i t -> [NArray i t] -> [NArray i t] -> ([NArray i t], [Double])
- Numeric.LinearAlgebra.Array.Solve: solve' :: (Compat i, Coord t, Coord t1) => (Matrix t1 -> Matrix t) -> NArray i t1 -> NArray i t -> NArray i t
+ Numeric.LinearAlgebra.Array.Solve: solve' :: (Compat i, Coord t, Coord a) => (Matrix t -> Matrix a) -> NArray i t -> NArray i a -> NArray i a
- Numeric.LinearAlgebra.Array.Solve: solveFactors :: (Coord t, Random t, Compat i, Num (NArray i t)) => Int -> ALSParam i t -> [NArray i t] -> String -> NArray i t -> ([NArray i t], [Double])
+ Numeric.LinearAlgebra.Array.Solve: solveFactors :: (Coord t, Random t, Compat i, Num (NArray i t), Show (NArray i t)) => Int -> ALSParam i t -> [NArray i t] -> String -> NArray i t -> ([NArray i t], [Double])
- Numeric.LinearAlgebra.Array.Solve: solveFactorsH :: (Coord t, Random t, Compat i, Num (NArray i t)) => Int -> ALSParam i t -> [NArray i t] -> String -> ([NArray i t], [Double])
+ Numeric.LinearAlgebra.Array.Solve: solveFactorsH :: (Coord t, Random t, Compat i, Num (NArray i t), Show (NArray i t)) => Int -> ALSParam i t -> [NArray i t] -> String -> ([NArray i t], [Double])
- Numeric.LinearAlgebra.Array.Solve: solveHomog' :: (Compat i, Coord t1, Coord t) => (Matrix t -> Matrix t1) -> NArray i t -> [Name] -> Either Double Int -> [NArray i t1]
+ Numeric.LinearAlgebra.Array.Solve: solveHomog' :: (Compat i, Coord t, Coord a) => (Matrix t -> Matrix a) -> NArray i t -> [Name] -> Either Double Int -> [NArray i a]
- Numeric.LinearAlgebra.Array.Solve: solveHomog1' :: (Compat i, Coord t, Coord t1) => (Matrix t -> Matrix t1) -> NArray i t -> [Name] -> NArray i t1
+ Numeric.LinearAlgebra.Array.Solve: solveHomog1' :: (Compat i, Coord t, Coord a) => (Matrix t -> Matrix a) -> NArray i t -> [Name] -> NArray i a
- Numeric.LinearAlgebra.Array.Solve: solveP' :: Coord t => (Matrix Double -> Matrix t) -> NArray Variant Double -> NArray Variant Double -> Name -> NArray Variant t
+ Numeric.LinearAlgebra.Array.Solve: solveP' :: Coord b => (Matrix Double -> Matrix b) -> NArray Variant Double -> NArray Variant Double -> Name -> NArray Variant b
- Numeric.LinearAlgebra.Array.Util: class (Num (Vector t), Field t, Normed Vector t) => Coord t
+ Numeric.LinearAlgebra.Array.Util: class (Num (Vector t), Field t, Normed Vector t, Show t) => Coord t
Files
- hTensor.cabal +7/−3
- lib/Numeric/LinearAlgebra/Array.hs +1/−1
- lib/Numeric/LinearAlgebra/Array/Decomposition.hs +1/−1
- lib/Numeric/LinearAlgebra/Array/Internal.hs +1/−1
- lib/Numeric/LinearAlgebra/Array/Solve.hs +10/−7
- lib/Numeric/LinearAlgebra/Array/Util.hs +4/−2
hTensor.cabal view
@@ -1,5 +1,5 @@ Name: hTensor-Version: 0.7.0.1+Version: 0.8.0 License: GPL License-file: LICENSE Author: Alberto Ruiz@@ -26,7 +26,7 @@ A tutorial can be found in the website of the project. Category: Math-tested-with: GHC ==6.12.1+tested-with: GHC ==7.4 cabal-version: >=1.6 build-type: Simple@@ -42,7 +42,7 @@ else build-depends: base < 3 - Build-Depends: hmatrix >= 0.10, containers, random+ Build-Depends: hmatrix >= 0.13, containers, random hs-source-dirs: lib Exposed-modules: Numeric.LinearAlgebra.Array.Util@@ -62,4 +62,8 @@ ghc-options: -Wall -fno-warn-missing-signatures -fno-warn-orphans++source-repository head+ type: git+ location: https://github.com/AlbertoRuiz/hTensor
lib/Numeric/LinearAlgebra/Array.hs view
@@ -42,7 +42,7 @@ (.*) :: (Coord a, Compat i) => NArray i a -> NArray i a -> NArray i a (.*) = zipArray (*) -instance (Coord t, Compat i) => Eq (NArray i t) where+instance (Eq t, Coord t, Compat i) => Eq (NArray i t) where t1 == t2 = sameStructure t1 t2 && coords t1 == coords (reorder (namesR t1) t2) instance (Show (NArray i t), Coord t, Compat i) => Num (NArray i t) where
lib/Numeric/LinearAlgebra/Array/Decomposition.hs view
@@ -25,7 +25,7 @@ import Numeric.LinearAlgebra.Array.Internal(seqIdx,namesR,sizesR,renameRaw) import Numeric.LinearAlgebra.Array.Util import Numeric.LinearAlgebra.Array.Solve-import Numeric.LinearAlgebra hiding ((.*), scalar)+import Numeric.LinearAlgebra hiding (scalar) import Data.List import System.Random --import Control.Parallel.Strategies
lib/Numeric/LinearAlgebra/Array/Internal.hs view
@@ -76,7 +76,7 @@ debug m f x = trace (m ++ show (f x)) x -- | Types that can be elements of the multidimensional arrays.-class (Num (Vector t), Field t, Normed Vector t) => Coord t+class (Num (Vector t), Field t, Normed Vector t, Show t) => Coord t instance Coord Double instance Coord (Complex Double)
lib/Numeric/LinearAlgebra/Array/Solve.hs view
@@ -31,7 +31,7 @@ import Numeric.LinearAlgebra.Array.Util import Numeric.LinearAlgebra.Exterior import Numeric.LinearAlgebra.Array.Internal(mkNArray, selDims, debug, namesR)-import Numeric.LinearAlgebra hiding ((.*), scalar)+import Numeric.LinearAlgebra hiding (scalar) import Data.List import System.Random @@ -172,7 +172,7 @@ -- | Solution of a multilinear system a x y z ... = b based on alternating least squares. mlSolve- :: (Compat i, Coord t, Num (NArray i t))+ :: (Compat i, Coord t, Num (NArray i t), Show (NArray i t)) => ALSParam i t -- ^ optimization parameters -> [NArray i t] -- ^ coefficients (a), given as a list of factors. -> [NArray i t] -- ^ initial solution [x,y,z...]@@ -192,7 +192,7 @@ -- | Solution of the homogeneous multilinear system a x y z ... = 0 based on alternating least squares. mlSolveH- :: (Compat i, Coord t, Num (NArray i t))+ :: (Compat i, Coord t, Num (NArray i t), Show (NArray i t)) => ALSParam i t -- ^ optimization parameters -> [NArray i t] -- ^ coefficients (a), given as a list of factors. -> [NArray i t] -- ^ initial solution [x,y,z...]@@ -232,7 +232,7 @@ {- | Given two arrays a (source) and b (target), we try to compute linear transformations x,y,z,... for each dimension, such that product [a,x,y,z,...] == b. (We can use 'eqnorm' for 'post' processing, or 'id'.) -}-solveFactors :: (Coord t, Random t, Compat i, Num (NArray i t))+solveFactors :: (Coord t, Random t, Compat i, Num (NArray i t), Show (NArray i t)) => Int -- ^ seed for random initialization -> ALSParam i t -- ^ optimization parameters -> [NArray i t] -- ^ source (also factorized)@@ -245,7 +245,7 @@ initFactorsSeq rs a pairs b | ok = as | otherwise = error "solveFactors index pairs" where- (ia,ib) = unzip (map (\[x,y]->([x],[y])) (words pairs))+ (ia,ib) = unzip (map sep (words pairs)) ic = intersect (namesR a) (namesR b) ok = sort (namesR b\\ic) == sort ib && sort (namesR a\\ic) == sort ia db = selDims (dims b) ib@@ -264,7 +264,7 @@ -- [\"pi\",\"qj\", \"rk\", etc.], we try to compute linear transformations -- x!\"pi\", y!\"pi\", z!\"rk\", etc. such that product [a,x,y,z,...] == 0. solveFactorsH- :: (Coord t, Random t, Compat i, Num (NArray i t))+ :: (Coord t, Random t, Compat i, Num (NArray i t), Show (NArray i t)) => Int -- ^ seed for random initialization -> ALSParam i t -- ^ optimization parameters -> [NArray i t] -- ^ coefficient array (a), (also factorized)@@ -274,7 +274,7 @@ mlSolveH params a (initFactorsHRandom seed (smartProduct a) pairs) initFactorsHSeq rs a pairs = as where- (ir,it) = unzip (map (\[x,y]->([x],[y])) (words pairs))+ (ir,it) = unzip (map sep (words pairs)) nr = map (flip size a) ir nt = map (flip size a) it ts = takes (zipWith (*) nr nt) rs@@ -282,6 +282,9 @@ f c i1 i2 d1 d2 = (mkNArray (map opos [d1,d2]) (fromList c)) `renameO` [i1,i2] initFactorsHRandom seed a pairs = initFactorsHSeq (randomRs (-1,1) (mkStdGen seed)) a pairs++sep [a,b] = ([a],[b])+sep _ = error "impossible pattern in hTensor initFactors" ----------------------------------
lib/Numeric/LinearAlgebra/Array/Util.hs view
@@ -68,8 +68,10 @@ -- For instance, @t >\@> \"pi qj\"@ changes index \"p\" to \"i\" and \"q\" to \"j\". (!>) :: (Compat i, Coord t) => NArray i t -> [Char] -> NArray i t infixl 9 !>-t !> s = renameExplicit (map (\[a,b]->([a],[b])) (words s)) t-+t !> s = renameExplicit (map f (words s)) t+ where+ f [a,b] = ([a],[b])+ f _ = error "impossible pattern in hTensor (!>)" -- | Rename indices in alphabetical order. Equal indices of compatible type are contracted out. renameO :: (Coord t, Compat i)