module Numeric.LinearAlgebra.Array.Simple (
None(..),
Array,
listArray
) where
import Numeric.LinearAlgebra.Array.Internal
import Data.Packed
import Data.List(intersperse)
instance Show (Idx None) where
show (Idx _t n s) = s ++ ":" ++ show n
data None = None deriving (Eq,Show)
instance Compat None where
compat d1 d2 = iDim d1 == iDim d2
opos = id
type Array t = NArray None t
instance (Coord t) => Show (Array t) where
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)
ps = concat $ intersperse ", " $ map show (parts t n)
listArray :: (Coord t)
=> [Int]
-> [t]
-> Array t
listArray ds cs = mkNArray dms (product ds |> (cs ++ repeat 0))
where dms = zipWith3 Idx (repeat None) ds (map show [1::Int ..])