From 3290b56b975ec151a389223f720c071b6404f6cc Mon Sep 17 00:00:00 2001 From: Vivian McPhail Date: Tue, 21 Sep 2010 03:45:09 +0000 Subject: add MatrixBoot.hs to darcs --- lib/Numeric/MatrixBoot.hs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/Numeric/MatrixBoot.hs (limited to 'lib/Numeric') diff --git a/lib/Numeric/MatrixBoot.hs b/lib/Numeric/MatrixBoot.hs new file mode 100644 index 0000000..13560b1 --- /dev/null +++ b/lib/Numeric/MatrixBoot.hs @@ -0,0 +1,41 @@ +{-# LANGUAGE FlexibleContexts #-} +----------------------------------------------------------------------------- +-- | +-- Module : Numeric.MatrixBoot +-- Copyright : (c) Alberto Ruiz 2010 +-- License : GPL-style +-- +-- Maintainer : Alberto Ruiz +-- Stability : provisional +-- Portability : portable +-- +-- Module to avoid cyclic dependency +-- +----------------------------------------------------------------------------- + +module Numeric.MatrixBoot ( + ctrans, diag, ident, + ) where + +import Data.Packed.Vector +import Data.Packed.Matrix +import Data.Packed.Internal.Matrix +import Numeric.Container + +------------------------------------------------------------------- + +-- | conjugate transpose +ctrans :: (Container Vector e, Element e) => Matrix e -> Matrix e +ctrans = liftMatrix conj . trans + +-- | Creates a square matrix with a given diagonal. +diag :: (Num a, Element a) => Vector a -> Matrix a +diag v = diagRect 0 v n n where n = dim v + +-- | creates the identity matrix of given dimension +ident :: (Num a, Element a) => Int -> Matrix a +ident n = diag (constantD 1 n) + +---------------------------------------------------- + + -- cgit v1.2.3