packages feed

hTensor 0.8.2 → 0.9.0

raw patch · 11 files changed

+48/−46 lines, 11 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, Fractional (NArray i t), Floating t, Floating (Vector t)) => Floating (NArray i t)
- Numeric.LinearAlgebra.Array: instance (Coord t, Compat i, Num (NArray i t)) => Fractional (NArray i t)
- Numeric.LinearAlgebra.Array: instance (Eq t, Coord t, Compat i) => Eq (NArray i t)
- Numeric.LinearAlgebra.Array: instance (Show (NArray i t), Coord t, Compat i) => Num (NArray i t)
- Numeric.LinearAlgebra.Array.Decomposition: delta :: ALSParam i t -> Double
- Numeric.LinearAlgebra.Array.Decomposition: epsilon :: ALSParam i t -> Double
- Numeric.LinearAlgebra.Array.Decomposition: nMax :: ALSParam i t -> Int
- Numeric.LinearAlgebra.Array.Decomposition: post :: ALSParam i t -> [NArray i t] -> [NArray i t]
- Numeric.LinearAlgebra.Array.Decomposition: postk :: ALSParam i t -> Int -> NArray i t -> NArray i t
- Numeric.LinearAlgebra.Array.Decomposition: presys :: ALSParam i t -> Matrix t -> Matrix t
- Numeric.LinearAlgebra.Array.Solve: delta :: ALSParam i t -> Double
- Numeric.LinearAlgebra.Array.Solve: eps :: Double
- Numeric.LinearAlgebra.Array.Solve: epsilon :: ALSParam i t -> Double
- Numeric.LinearAlgebra.Array.Solve: nMax :: ALSParam i t -> Int
- Numeric.LinearAlgebra.Array.Solve: post :: ALSParam i t -> [NArray i t] -> [NArray i t]
- Numeric.LinearAlgebra.Array.Solve: postk :: ALSParam i t -> Int -> NArray i t -> NArray i t
- Numeric.LinearAlgebra.Array.Solve: presys :: ALSParam i t -> Matrix t -> Matrix t
- Numeric.LinearAlgebra.Array.Util: iDim :: Idx i -> Int
- Numeric.LinearAlgebra.Array.Util: iName :: Idx i -> Name
- Numeric.LinearAlgebra.Array.Util: iType :: Idx i -> i
- Numeric.LinearAlgebra.Multivector: instance Eq Multivector
- Numeric.LinearAlgebra.Multivector: instance Fractional Multivector
- Numeric.LinearAlgebra.Multivector: instance Num Multivector
- Numeric.LinearAlgebra.Multivector: instance Show Multivector
- Numeric.LinearAlgebra.Tensor: instance Compat Variant
- Numeric.LinearAlgebra.Tensor: instance Coord t => Show (Tensor t)
- Numeric.LinearAlgebra.Tensor: instance Eq Variant
- Numeric.LinearAlgebra.Tensor: instance Show (Idx Variant)
- Numeric.LinearAlgebra.Tensor: instance Show Variant
+ Numeric.LinearAlgebra.Array: instance (GHC.Classes.Eq t, Numeric.LinearAlgebra.Array.Internal.Coord t, Numeric.LinearAlgebra.Array.Internal.Compat i) => GHC.Classes.Eq (Numeric.LinearAlgebra.Array.Internal.NArray i t)
+ Numeric.LinearAlgebra.Array: instance (GHC.Real.Fractional t, Numeric.LinearAlgebra.Array.Internal.Coord t, Numeric.LinearAlgebra.Array.Internal.Compat i, GHC.Num.Num (Numeric.LinearAlgebra.Array.Internal.NArray i t)) => GHC.Real.Fractional (Numeric.LinearAlgebra.Array.Internal.NArray i t)
+ Numeric.LinearAlgebra.Array: instance (GHC.Show.Show (Numeric.LinearAlgebra.Array.Internal.NArray i t), Numeric.LinearAlgebra.Array.Internal.Coord t, Numeric.LinearAlgebra.Array.Internal.Compat i) => GHC.Num.Num (Numeric.LinearAlgebra.Array.Internal.NArray i t)
+ Numeric.LinearAlgebra.Array: instance (Numeric.LinearAlgebra.Array.Internal.Coord t, Numeric.LinearAlgebra.Array.Internal.Compat i, GHC.Real.Fractional (Numeric.LinearAlgebra.Array.Internal.NArray i t), GHC.Float.Floating t, GHC.Float.Floating (Data.Vector.Storable.Vector t)) => GHC.Float.Floating (Numeric.LinearAlgebra.Array.Internal.NArray i t)
+ Numeric.LinearAlgebra.Array.Decomposition: [delta] :: ALSParam i t -> Double
+ Numeric.LinearAlgebra.Array.Decomposition: [epsilon] :: ALSParam i t -> Double
+ Numeric.LinearAlgebra.Array.Decomposition: [nMax] :: ALSParam i t -> Int
+ Numeric.LinearAlgebra.Array.Decomposition: [post] :: ALSParam i t -> [NArray i t] -> [NArray i t]
+ Numeric.LinearAlgebra.Array.Decomposition: [postk] :: ALSParam i t -> Int -> NArray i t -> NArray i t
+ Numeric.LinearAlgebra.Array.Decomposition: [presys] :: ALSParam i t -> Matrix t -> Matrix t
+ Numeric.LinearAlgebra.Array.Solve: [delta] :: ALSParam i t -> Double
+ Numeric.LinearAlgebra.Array.Solve: [epsilon] :: ALSParam i t -> Double
+ Numeric.LinearAlgebra.Array.Solve: [nMax] :: ALSParam i t -> Int
+ Numeric.LinearAlgebra.Array.Solve: [post] :: ALSParam i t -> [NArray i t] -> [NArray i t]
+ Numeric.LinearAlgebra.Array.Solve: [postk] :: ALSParam i t -> Int -> NArray i t -> NArray i t
+ Numeric.LinearAlgebra.Array.Solve: [presys] :: ALSParam i t -> Matrix t -> Matrix t
+ Numeric.LinearAlgebra.Array.Util: [iDim] :: Idx i -> Int
+ Numeric.LinearAlgebra.Array.Util: [iName] :: Idx i -> Name
+ Numeric.LinearAlgebra.Array.Util: [iType] :: Idx i -> i
+ Numeric.LinearAlgebra.Multivector: instance GHC.Classes.Eq Numeric.LinearAlgebra.Multivector.Multivector
+ Numeric.LinearAlgebra.Multivector: instance GHC.Num.Num Numeric.LinearAlgebra.Multivector.Multivector
+ Numeric.LinearAlgebra.Multivector: instance GHC.Real.Fractional Numeric.LinearAlgebra.Multivector.Multivector
+ Numeric.LinearAlgebra.Multivector: instance GHC.Show.Show Numeric.LinearAlgebra.Multivector.Multivector
+ Numeric.LinearAlgebra.Tensor: instance GHC.Classes.Eq Numeric.LinearAlgebra.Tensor.Variant
+ Numeric.LinearAlgebra.Tensor: instance GHC.Show.Show (Numeric.LinearAlgebra.Array.Internal.Idx Numeric.LinearAlgebra.Tensor.Variant)
+ Numeric.LinearAlgebra.Tensor: instance GHC.Show.Show Numeric.LinearAlgebra.Tensor.Variant
+ Numeric.LinearAlgebra.Tensor: instance Numeric.LinearAlgebra.Array.Internal.Compat Numeric.LinearAlgebra.Tensor.Variant
+ Numeric.LinearAlgebra.Tensor: instance Numeric.LinearAlgebra.Array.Internal.Coord t => GHC.Show.Show (Numeric.LinearAlgebra.Tensor.Tensor t)
- Numeric.LinearAlgebra.Array: (~>) :: Coord t => NArray i t -> String -> NArray i t
+ Numeric.LinearAlgebra.Array: (~>) :: (Coord t) => NArray i t -> String -> NArray i t
- Numeric.LinearAlgebra.Array: listArray :: Coord t => [Int] -> [t] -> Array t
+ Numeric.LinearAlgebra.Array: listArray :: (Coord t) => [Int] -> [t] -> Array t
- 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: mlSolve :: (Compat i, Coord t, Field 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), Show (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, Field 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) => NArray i t -> NArray i t -> NArray i t
+ Numeric.LinearAlgebra.Array.Solve: solve :: (Compat i, Coord t, Field t) => NArray i t -> NArray i t -> NArray i t
- Numeric.LinearAlgebra.Array.Solve: solve' :: (Coord a, Coord t, Compat i) => (Matrix t -> Matrix a) -> NArray i t -> NArray i t -> NArray i a
+ Numeric.LinearAlgebra.Array.Solve: solve' :: (Field a, Compat i, Coord t, Coord a) => (Matrix t -> Matrix a) -> NArray i t -> NArray i t -> NArray i a
- 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: solveFactors :: (Coord t, Field 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), Show (NArray i t)) => Int -> ALSParam i t -> [NArray i t] -> String -> ([NArray i t], [Double])
+ Numeric.LinearAlgebra.Array.Solve: solveFactorsH :: (Coord t, Random t, Field 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: solveH :: (Compat i, Coord t) => NArray i t -> [Char] -> NArray i t
+ Numeric.LinearAlgebra.Array.Solve: solveH :: (Compat i, Coord t, Field t) => NArray i t -> [Char] -> NArray i t
- Numeric.LinearAlgebra.Array.Solve: solveHomog :: (Compat i, Coord t) => NArray i t -> [Name] -> Either Double Int -> [NArray i t]
+ Numeric.LinearAlgebra.Array.Solve: solveHomog :: (Compat i, Coord t, Field t) => NArray i t -> [Name] -> Either Double Int -> [NArray i t]
- Numeric.LinearAlgebra.Array.Solve: solveHomog' :: (Coord a, Coord t, Compat i) => (Matrix t -> Matrix a) -> NArray i t -> [Name] -> Either Double Int -> [NArray i a]
+ Numeric.LinearAlgebra.Array.Solve: solveHomog' :: (Field a, 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) => NArray i t -> [Name] -> NArray i t
+ Numeric.LinearAlgebra.Array.Solve: solveHomog1 :: (Compat i, Coord t, Field t) => NArray i t -> [Name] -> NArray i t
- Numeric.LinearAlgebra.Array.Solve: solveHomog1' :: (Coord a, Coord t, Compat i) => (Matrix t -> Matrix a) -> NArray i t -> [Name] -> NArray i a
+ Numeric.LinearAlgebra.Array.Solve: solveHomog1' :: (Field a, Compat i, Coord t, Coord a) => (Matrix t -> Matrix a) -> NArray i t -> [Name] -> NArray i a
- Numeric.LinearAlgebra.Array.Solve: solveP' :: Coord b => (Matrix Double -> Matrix b) -> NArray Variant Double -> NArray Variant Double -> Name -> NArray Variant b
+ Numeric.LinearAlgebra.Array.Solve: solveP' :: (Field b, Coord b) => (Matrix Double -> Matrix b) -> NArray Variant Double -> NArray Variant Double -> Name -> NArray Variant b
- Numeric.LinearAlgebra.Array.Util: (~>) :: Coord t => NArray i t -> String -> NArray i t
+ Numeric.LinearAlgebra.Array.Util: (~>) :: (Coord t) => NArray i t -> String -> NArray i t
- Numeric.LinearAlgebra.Array.Util: asMatrix :: Coord t => NArray i t -> Matrix t
+ Numeric.LinearAlgebra.Array.Util: asMatrix :: (Coord t) => NArray i t -> Matrix t
- Numeric.LinearAlgebra.Array.Util: asScalar :: Coord t => NArray i t -> t
+ Numeric.LinearAlgebra.Array.Util: asScalar :: (Coord t) => NArray i t -> t
- Numeric.LinearAlgebra.Array.Util: asVector :: Coord t => NArray i t -> Vector t
+ Numeric.LinearAlgebra.Array.Util: asVector :: (Coord t) => NArray i t -> Vector t
- Numeric.LinearAlgebra.Array.Util: class (Num (Vector t), Field t, Normed Vector t, Show t) => Coord t
+ Numeric.LinearAlgebra.Array.Util: class (Num (Vector t), Normed (Vector t), Show t, Numeric t, Indexable (Vector t) t) => Coord t
- Numeric.LinearAlgebra.Array.Util: formatFixed :: Compat i => Int -> NArray i Double -> String
+ Numeric.LinearAlgebra.Array.Util: formatFixed :: (Compat i) => Int -> NArray i Double -> String
- Numeric.LinearAlgebra.Array.Util: formatScaled :: Compat i => Int -> NArray i Double -> String
+ Numeric.LinearAlgebra.Array.Util: formatScaled :: (Compat i) => Int -> NArray i Double -> String
- Numeric.LinearAlgebra.Array.Util: mapArray :: Coord b => (Vector a -> Vector b) -> NArray i a -> NArray i b
+ Numeric.LinearAlgebra.Array.Util: mapArray :: (Coord b) => (Vector a -> Vector b) -> NArray i a -> NArray i b
- Numeric.LinearAlgebra.Array.Util: matrixator :: Coord t => NArray i t -> [Name] -> [Name] -> Matrix t
+ Numeric.LinearAlgebra.Array.Util: matrixator :: (Coord t) => NArray i t -> [Name] -> [Name] -> Matrix t
- Numeric.LinearAlgebra.Array.Util: matrixatorFree :: Coord t => NArray i t -> [Name] -> (Matrix t, [Name])
+ Numeric.LinearAlgebra.Array.Util: matrixatorFree :: (Coord t) => NArray i t -> [Name] -> (Matrix t, [Name])
- Numeric.LinearAlgebra.Array.Util: parts :: Coord t => NArray i t -> Name -> [NArray i t]
+ Numeric.LinearAlgebra.Array.Util: parts :: (Coord t) => NArray i t -> Name -> [NArray i t]
- Numeric.LinearAlgebra.Array.Util: reorder :: Coord t => [Name] -> NArray i t -> NArray i t
+ Numeric.LinearAlgebra.Array.Util: reorder :: (Coord t) => [Name] -> NArray i t -> NArray i t
- Numeric.LinearAlgebra.Array.Util: sameStructure :: Eq i => NArray i t1 -> NArray i t2 -> Bool
+ Numeric.LinearAlgebra.Array.Util: sameStructure :: (Eq i) => NArray i t1 -> NArray i t2 -> Bool
- Numeric.LinearAlgebra.Exterior: (/\) :: Coord t => Tensor t -> Tensor t -> Tensor t
+ Numeric.LinearAlgebra.Exterior: (/\) :: (Coord t, Fractional t) => Tensor t -> Tensor t -> Tensor t
- Numeric.LinearAlgebra.Exterior: inner :: Coord t => Tensor t -> Tensor t -> Tensor t
+ Numeric.LinearAlgebra.Exterior: inner :: (Coord t, Fractional t) => Tensor t -> Tensor t -> Tensor t

Files

hTensor.cabal view
@@ -1,5 +1,5 @@ Name:               hTensor-Version:            0.8.2+Version:            0.9.0 License:            BSD3 License-file:       LICENSE Author:             Alberto Ruiz@@ -35,7 +35,7 @@  library -    Build-Depends:      base<5, hmatrix>=0.16, containers, random+    Build-Depends:      base<5, hmatrix>=0.17, containers, random      hs-source-dirs:     lib     Exposed-modules:    Numeric.LinearAlgebra.Array.Util
lib/Numeric/LinearAlgebra/Array.hs view
@@ -28,7 +28,7 @@ import Numeric.LinearAlgebra.Array.Util import Numeric.LinearAlgebra.Array.Internal(namesR) import Numeric.LinearAlgebra.Array.Display(printA)-import Data.Packed(Vector)+import Numeric.LinearAlgebra.HMatrix(Vector)  -- | Create an 'Array' from a list of parts (@index = 'newIndex' 'None'@). index :: Coord t => Name -> [Array t] -> Array t@@ -51,7 +51,7 @@     abs _ = error "abs for arrays not defined"     signum _ = error "signum for arrays not defined" -instance (Coord t, Compat i, Num (NArray i t)) => Fractional (NArray i t) where+instance (Fractional t, Coord t, Compat i, Num (NArray i t)) => Fractional (NArray i t) where     fromRational = scalar . fromRational     (/) = zipArray (/)     recip = mapArray recip
lib/Numeric/LinearAlgebra/Array/Decomposition.hs view
@@ -24,7 +24,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.HMatrix hiding (scalar) import Data.List import System.Random --import Control.Parallel.Strategies@@ -43,7 +43,7 @@     n = length rs     dummies = take n $ seqIdx (2*n) "" \\ (namesR t)     axs = zipWith (\a b->[a,b]) dummies (namesR t)-    factors = renameRaw core dummies : zipWith renameRaw (map (fromMatrix None None . trans) rs) axs+    factors = renameRaw core dummies : zipWith renameRaw (map (fromMatrix None None . tr) rs) axs     core = product $ renameRaw t dummies : zipWith renameRaw (map (fromMatrix None None) rs) axs  {- | Multilinear Singular Value Decomposition (or Tucker's method, see Lathauwer et al.).@@ -68,14 +68,14 @@  --check trans/ctrans usOfSVD m = if rows m < cols m-        then let (s2,u) = eigSH' $ m <> ctrans m+        then let (s2,u) = eigSH' $ m <> tr m                  s = sqrt (abs s2)               in (u,r s)-        else let (s2,v) = eigSH' $ ctrans m <> m+        else let (s2,v) = eigSH' $ tr m <> m                  s = sqrt (abs s2)                  u = m <> v <> pinv (diag s)               in (u,r s)-    where r s = (ranksv (sqrt eps) (max (rows m) (cols m)) (toList s), s)+    where r s = (ranksv (sqrt peps) (max (rows m) (cols m)) (toList s), s)                 -- (rank m, sv m) where sv m = s where (_,s,_) = svd m  @@ -89,7 +89,7 @@  ------------------------------------------------------------------------ -frobT = pnorm PNorm2 . coords+frobT = norm_2 . coords  ------------------------------------------------------------------------ 
lib/Numeric/LinearAlgebra/Array/Display.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE FlexibleContexts #-}+ ----------------------------------------------------------------------------- -- | -- Module      :  Data.Packed.Array.Display@@ -15,8 +17,7 @@ ) where  import Numeric.LinearAlgebra.Array.Internal-import Data.Packed-import Numeric.Container(format)+import Numeric.LinearAlgebra.HMatrix import Data.List import Text.Printf @@ -70,7 +71,7 @@ formatAux f x = unlines . addds . els . fmt ms $ x where     fmt [] _ = undefined -- cannot happen     fmt (g:gs) t-        | order t == 0 = rect (f (coords t @> 0))+        | order t == 0 = rect (f (coords t ! 0))         | order t == 1 =  rect $ unwords $ map f (toList $ coords t)         | order t == 2 =  decor t $ rect $ w1 $ format " " f (reshape (iDim $ last $ dims t) (coords t))         | otherwise    = decor t (g ps)
lib/Numeric/LinearAlgebra/Array/Internal.hs view
@@ -52,32 +52,31 @@     selDims, mapDims,     takeDiagT, atT,     firstIdx, fibers, matrixator, matrixatorFree,-    Coord,+    Coord,I,     asMatrix, asVector, asScalar,     resetCoords,     debug ) where -import Data.Packed-import Numeric.Container(konst)-import Data.Complex++import qualified Numeric.LinearAlgebra.HMatrix as LA+import Numeric.LinearAlgebra.HMatrix hiding (size,scalar,ident) import Data.List-import Numeric.LinearAlgebra((<>),Field,Normed)-import Control.Applicative---import Control.Arrow ((***)) import Data.Function(on)--- import Foreign(Storable)--- import Control.Parallel.Strategies import Debug.Trace +dim x = LA.size x+trans x = LA.tr x+ ident n = diagRect 0 (konst 1 n) n n  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, Show t) => Coord t+class (Num (Vector t), Normed (Vector t), Show t, Numeric t, Indexable (Vector t) t) => Coord t instance Coord Double instance Coord (Complex Double)+instance Coord I  -- | indices are denoted by strings, (frequently single-letter) type Name = String@@ -272,9 +271,9 @@  -- | Apply a function (defined on hmatrix 'Vector's) to all elements of a structure. -- Use @mapArray (mapVector f)@ for general functions.-mapArray :: Coord b => (Vector a -> Vector b) -> NArray i a -> NArray i b+mapArray :: (Coord b) => (Vector a -> Vector b) -> NArray i a -> NArray i b mapArray f t-    | null (dims t) = scalar (f (coords t)@>0)+    | null (dims t) = scalar (f (coords t)!0)     | otherwise = mkNArray (dims t) (f (coords t))  liftNA2 f (A d1 v1) (A _d2 v2) = A d1 (f v1 v2)@@ -393,7 +392,7 @@  -- | Extract the scalar element corresponding to a 0-dimensional array. asScalar :: (Coord t) => NArray i t -> t-asScalar a | order a == 0 = coords a @>0+asScalar a | order a == 0 = coords a ! 0            | otherwise = error $ "asScalar requires a 0th order array."  ------------------------------------------------------------------------@@ -504,3 +503,4 @@ -- | sequence of n indices with given prefix seqIdx :: Int -> String -> [Name] seqIdx n prefix = [prefix ++ show k | k <- [1 .. n] ]+
lib/Numeric/LinearAlgebra/Array/Simple.hs view
@@ -20,7 +20,7 @@ ) where  import Numeric.LinearAlgebra.Array.Internal-import Data.Packed+import Numeric.LinearAlgebra.HMatrix import Data.List(intersperse)  @@ -41,7 +41,7 @@ type Array t = NArray None t  instance (Coord t) => Show (Array t) where-    show t | null (dims t) = "scalar "++ show (coords t @>0)+    show t | null (dims t) = "scalar "++ show (coords t !0)            | order t == 1 = "index " ++ show n ++" " ++ (show . toList . coords $ t)            | otherwise = "index "++ show n ++ " [" ++ ps ++ "]"       where n = head (namesR t)
lib/Numeric/LinearAlgebra/Array/Solve.hs view
@@ -23,14 +23,15 @@ -- ** Factorized     solveFactors, solveFactorsH, -- * Utilities-    eps, eqnorm, infoRank,+    eqnorm, infoRank,     solve', solveHomog', solveHomog1', solveP' ) where  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.HMatrix hiding (scalar,size)+--import qualified Numeric.LinearAlgebra.HMatrix as LA import Data.List import System.Random @@ -38,7 +39,7 @@ -- | Solution of the linear system a x = b, where a and b are -- general multidimensional arrays. The structure and dimension names -- of the result are inferred from the arguments.-solve :: (Compat i, Coord t)+solve :: (Compat i, Coord t, Field t)         => NArray i t -- ^ coefficients (a)         -> NArray i t -- ^ target       (b)         -> NArray i t -- ^ result       (x)@@ -59,7 +60,7 @@ -- general multidimensional array. -- -- If the system is overconstrained we may provide the theoretical rank to get a MSE solution.-solveHomog :: (Compat i, Coord t)+solveHomog :: (Compat i, Coord t, Field t)            =>  NArray i t    -- ^ coefficients (a)            -> [Name]         -- ^ desired dimensions for the result                              --   (a subset selected from the target).@@ -77,7 +78,7 @@  -- | A simpler way to use 'solveHomog', which returns just one solution. -- If the system is overconstrained it returns the MSE solution.-solveHomog1 :: (Compat i, Coord t)+solveHomog1 :: (Compat i, Coord t, Field t)             => NArray i t             -> [Name]             -> NArray i t@@ -87,7 +88,7 @@     where k = product $ map iDim $ selDims (dims m) ns  -- | 'solveHomog1' for single letter index names.-solveH :: (Compat i, Coord t) => NArray i t -> [Char] -> NArray i t+solveH :: (Compat i, Coord t, Field t) => NArray i t -> [Char] -> NArray i t solveH m ns = solveHomog1 m (map return ns)  @@ -153,7 +154,7 @@     g v = v / atT v [n]     n = size h t - 1 -frobT t = realToFrac . pnorm PNorm2 . coords $ t+frobT t = realToFrac . norm_2 . coords $ t --unitT t = t / scalar (frobT t)  dropElemPos k xs = take k xs ++ drop (k+1) xs@@ -171,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), Show (NArray i t))+  :: (Compat i, Coord t, Field 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...]@@ -191,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), Show (NArray i t))+  :: (Compat i, Coord t, Field 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...]@@ -231,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), Show (NArray i t))+solveFactors :: (Coord t, Field 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)@@ -263,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), Show (NArray i t))+  :: (Coord t, Random t, Field 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)
lib/Numeric/LinearAlgebra/Array/Util.hs view
@@ -45,7 +45,7 @@  import Numeric.LinearAlgebra.Array.Internal import Numeric.LinearAlgebra.Array.Display-import Data.Packed(Matrix)+import Numeric.LinearAlgebra.HMatrix(Matrix) import Numeric.LinearAlgebra.Array.Simple import Data.List(intersperse,sort,foldl1') 
lib/Numeric/LinearAlgebra/Exterior.hs view
@@ -60,7 +60,7 @@ -- | The exterior (wedge) product of two tensors. Obtains the union of subspaces. -- --   Implemented as the antisymmetrization of the tensor product.-(/\) :: (Coord t)+(/\) :: (Coord t, Fractional t)      => Tensor t      -> Tensor t      -> Tensor t@@ -98,7 +98,7 @@                 Nothing -> error $ "dual with different dimensions"  -- | Euclidean inner product of multivectors.-inner :: (Coord t)+inner :: (Coord t, Fractional t)       => Tensor t       -> Tensor t       -> Tensor t
lib/Numeric/LinearAlgebra/Multivector.hs view
@@ -23,7 +23,7 @@     fromTensor ) where -import Numeric.LinearAlgebra(toList,reshape,(<\>),(@>))+import Numeric.LinearAlgebra.HMatrix(toList,reshape,(<\>),atIndex) import Numeric.LinearAlgebra.Array.Internal hiding (scalar,coords) import Numeric.LinearAlgebra.Array.Display (showBases) import Numeric.LinearAlgebra.Tensor hiding (scalar,vector)@@ -246,7 +246,7 @@ -- (We do not check that the tensor is actually antisymmetric.) fromTensor :: Tensor Double -> Multivector fromTensor t = MV $ filter ((/=0.0).fst) $ zip vals basis-    where vals = map ((@> 0). Array.coords .foldl' partF t) (map (map pred) basis)+    where vals = map ((`atIndex` 0). Array.coords .foldl' partF t) (map (map pred) basis)           r = length (dims t)           n = iDim . head . dims $ t           partF s i = part s (name,i) where name = iName . head . dims $ s
lib/Numeric/LinearAlgebra/Tensor.hs view
@@ -26,7 +26,7 @@ ) where  import Numeric.LinearAlgebra.Array.Internal-import Numeric.LinearAlgebra+import Numeric.LinearAlgebra.HMatrix hiding (vector) import Numeric.LinearAlgebra.Array import Data.List(intersperse) @@ -43,7 +43,7 @@     show (Idx Contra n s) = s ++ "^" ++ show n  instance (Coord t) => Show (Tensor t) where-    show t | null (dims t) = "scalar "++ show (coords t @>0)+    show t | null (dims t) = "scalar "++ show (coords t `atIndex` 0)            | order t == 1 = ixn ++ show n ++" " ++ (show . toList . coords $ t)            | otherwise = ixn ++ show n ++ " [" ++ ps ++ "]"       where n = head (namesR t)