From 1fb4ea70c517050d3cbad75357a4fffbf5a40e7b Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Tue, 5 Jun 2007 10:09:17 +0000 Subject: working on contraction --- lib/Data/Packed/Internal/Tensor.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/Data/Packed/Internal/Tensor.hs') diff --git a/lib/Data/Packed/Internal/Tensor.hs b/lib/Data/Packed/Internal/Tensor.hs index 11101a9..960e3c5 100644 --- a/lib/Data/Packed/Internal/Tensor.hs +++ b/lib/Data/Packed/Internal/Tensor.hs @@ -17,16 +17,24 @@ module Data.Packed.Internal.Tensor where import Data.Packed.Internal.Vector import Data.Packed.Internal.Matrix - +import Foreign.Storable data IdxTp = Covariant | Contravariant deriving Show data Tensor t = T { dims :: [(Int,(IdxTp,String))] , ten :: Vector t - } deriving Show + } rank = length . dims outer u v = dat (multiply RowMajor r c) where r = matrixFromVector RowMajor 1 u c = matrixFromVector RowMajor (dim v) v + +instance (Show a,Storable a) => Show (Tensor a) where + show T {dims = [], ten = t} = "scalar "++show (t `at` 0) + show T {dims = ds, ten = t} = "("++shdims ds ++") "++ show (toList t) + + +shdims [(n,(t,name))] = name++"["++show n++"]" +shdims (d:ds) = shdims [d] ++ "><"++ shdims ds \ No newline at end of file -- cgit v1.2.3