hTensor 0.9.0 → 0.9.1
raw patch · 3 files changed
+23/−14 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Numeric.LinearAlgebra.Array: infixl 7 .*
+ Numeric.LinearAlgebra.Array: infixl 8 ~>
+ Numeric.LinearAlgebra.Array: infixl 9 !>
+ Numeric.LinearAlgebra.Array.Util: infixl 5 |*|
+ Numeric.LinearAlgebra.Array.Util: infixl 8 ~>
+ Numeric.LinearAlgebra.Array.Util: infixl 9 !
+ Numeric.LinearAlgebra.Array.Util: reshapeVector :: (Compat i, Coord t) => [Idx i] -> Vector t -> NArray i t
+ Numeric.LinearAlgebra.Exterior: infixl 4 \/
+ Numeric.LinearAlgebra.Exterior: infixl 5 /\
+ Numeric.LinearAlgebra.Multivector: infixl 7 \/
- 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: solve' :: (Coord a, Coord t, Compat i, Field a) => (Matrix t -> Matrix a) -> NArray i t -> NArray i t -> 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: solveHomog' :: (Coord a, Coord t, Compat i, Field a) => (Matrix t -> Matrix a) -> NArray i t -> [Name] -> Either Double Int -> [NArray i a]
Files
- hTensor.cabal +1/−1
- lib/Numeric/LinearAlgebra/Array/Internal.hs +21/−12
- lib/Numeric/LinearAlgebra/Array/Util.hs +1/−1
hTensor.cabal view
@@ -1,5 +1,5 @@ Name: hTensor-Version: 0.9.0+Version: 0.9.1 License: BSD3 License-file: LICENSE Author: Alberto Ruiz
lib/Numeric/LinearAlgebra/Array/Internal.hs view
@@ -27,7 +27,7 @@ -- * Array creation scalar, mkNArray,- fromVector, fromMatrix,+ fromVector, fromMatrix, reshapeVector, -- * Array manipulation renameRaw, parts, partsRaw,@@ -148,7 +148,7 @@ namesR :: NArray i t -> [Name] namesR = map iName . dims --- | Index names.+-- | Index names (in alphabetical order). names :: NArray i t -> [Name] names = sort . namesR @@ -159,6 +159,7 @@ sizesR :: NArray i t -> [Int] sizesR = map iDim . dims +-- | Dimensions of indices (in alphabetical order of indices). sizes :: NArray i t -> [Int] sizes t = map (flip size t) (names t) @@ -250,20 +251,24 @@ where (_:ds,m) = firstIdx name a f t = A {dims=ds, coords=t} -tridx [] t = t-tridx (name:rest) t = A (d:ds) (vjoin ts) where- d = case lastIdx name t of- ((_,d':_),_) -> d'- _ -> error "wrong index sequence to reorder"- ps = map (tridx rest) (partsRaw t name)- ts = map coords ps- ds = dims (head ps)+tridx names' t0 | done (namesR t0) names' = t0+ | otherwise = go names' t0+ where done oldNames newNames = and $ zipWith (==) newNames (oldNames ++ error "too many indices to reorder")+ go [] t = t+ go (name:rest) t = A (d:ds) (vjoin ts) where+ d = case lastIdx name t of+ ((_,d':_),_) -> d'+ _ -> error "wrong index sequence to reorder"+ ps = partsRaw t name+ ps' | done (namesR $ head ps) rest = ps+ | otherwise = map (go rest) ps+ ts = map coords ps'+ ds = dims (head ps') -- | Change the internal layout of coordinates. -- The array, considered as an abstract object, does not change. reorder :: (Coord t) => [Name] -> NArray i t -> NArray i t-reorder ns b | ns == namesR b = b- | sort ns == sort (namesR b) = tridx ns b+reorder ns b | sort ns == sort (namesR b) = tridx ns b | otherwise = error $ "wrong index sequence " ++ show ns ++ " to reorder "++(show $ namesR b) @@ -405,6 +410,10 @@ fromMatrix :: (Compat i, Coord t) => i -> i -> Matrix t -> NArray i t fromMatrix ir ic m = mkNArray [Idx ir (rows m) "1", Idx ic (cols m) "2"] (flatten m)++-- | Create an 'NArray' from a 'Vector' by specifying the 'dims' and 'coords'.+reshapeVector :: (Compat i, Coord t) => [Idx i] -> Vector t -> NArray i t+reshapeVector dms vec = contract $ mkNArray dms vec ------------------------------------------------------------------------
lib/Numeric/LinearAlgebra/Array/Util.hs view
@@ -39,7 +39,7 @@ resetCoords, asScalar, asVector, asMatrix, applyAsMatrix, fibers, matrixator, matrixatorFree, analyzeProduct,- fromVector, fromMatrix+ fromVector, fromMatrix, reshapeVector -- ,Container(..), ) where