From 92b1ed5e7fcbebbfbcde34206c040a8472d847d9 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Thu, 7 Jun 2007 11:13:32 +0000 Subject: adapting lapack wrappers --- lib/Data/Packed/Internal/Matrix.hs | 14 ++++++++++++++ lib/Data/Packed/Internal/Tensor.hs | 4 ---- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/Data') diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index ec6657a..db53cd1 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs @@ -160,6 +160,10 @@ toRows m = toRows' 0 where toRows' k | k == r*c = [] | otherwise = subVector k c v : toRows' (k+c) +----------------------------------------------------------------- + +liftMatrix f m = m { dat = f dat, tdat = f tdat } -- check sizes + ------------------------------------------------------------------ dotL a b = sum (zipWith (*) a b) @@ -208,6 +212,16 @@ multiplyD order a b ---------------------------------------------------------------------- +outer u v = dat (multiply RowMajor r c) + where r = matrixFromVector RowMajor 1 u + c = matrixFromVector RowMajor (dim v) v + +dot u v = dat (multiply RowMajor r c) `at` 0 + where r = matrixFromVector RowMajor (dim u) u + c = matrixFromVector RowMajor 1 v + +---------------------------------------------------------------------- + -- | extraction of a submatrix of a real matrix subMatrixR :: (Int,Int) -- ^ (r0,c0) starting position -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix diff --git a/lib/Data/Packed/Internal/Tensor.hs b/lib/Data/Packed/Internal/Tensor.hs index b66d6b8..67dcb09 100644 --- a/lib/Data/Packed/Internal/Tensor.hs +++ b/lib/Data/Packed/Internal/Tensor.hs @@ -27,10 +27,6 @@ data Tensor t = T { dims :: [(Int,(IdxTp,String))] 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) -- cgit v1.2.3