From 89651db9f2577ba42dbbb91c85565a12f34d0fb2 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Mon, 10 Sep 2007 09:13:20 +0000 Subject: simplified --- lib/LinearAlgebra/Linear.hs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lib/LinearAlgebra/Linear.hs (limited to 'lib/LinearAlgebra/Linear.hs') diff --git a/lib/LinearAlgebra/Linear.hs b/lib/LinearAlgebra/Linear.hs new file mode 100644 index 0000000..5c5bf0d --- /dev/null +++ b/lib/LinearAlgebra/Linear.hs @@ -0,0 +1,45 @@ +{-# OPTIONS_GHC -fglasgow-exts #-} +----------------------------------------------------------------------------- +{- | +Module : LinearAlgebra.Linear +Copyright : (c) Alberto Ruiz 2006-7 +License : GPL-style + +Maintainer : Alberto Ruiz (aruiz at um dot es) +Stability : provisional +Portability : uses ffi + + +-} +----------------------------------------------------------------------------- + +module LinearAlgebra.Linear ( + Linear(..) +) where + + +import Data.Packed.Internal +import GSL.Vector +import Complex + + +class (Num e, Field e) => Linear c e where + scale :: e -> c e -> c e + addConstant :: e -> c e -> c e + add :: c e -> c e -> c e + sub :: c e -> c e -> c e + mul :: c e -> c e -> c e + +instance Linear Vector Double where + scale = vectorMapValR Scale + addConstant = vectorMapValR AddConstant + add = vectorZipR Add + sub = vectorZipR Sub + mul = vectorZipR Mul + +instance Linear Vector (Complex Double) where + scale = vectorMapValC Scale + addConstant = vectorMapValC AddConstant + add = vectorZipC Add + sub = vectorZipC Sub + mul = vectorZipC Mul -- cgit v1.2.3