comfort-blas 0.0.2 → 0.0.3
raw patch · 19 files changed
+2345/−574 lines, 19 filesdep ~comfort-arraydep ~netlib-ffiPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: comfort-array, netlib-ffi
API changes (from Hackage documentation)
- Numeric.BLAS.Matrix.Layout: instance Control.DeepSeq.NFData Numeric.BLAS.Matrix.Layout.Order
- Numeric.BLAS.Matrix.Layout: instance GHC.Classes.Eq Numeric.BLAS.Matrix.Layout.Order
- Numeric.BLAS.Matrix.Layout: instance GHC.Show.Show Numeric.BLAS.Matrix.Layout.Order
- Numeric.BLAS.Matrix.Modifier: instance GHC.Base.Monoid Numeric.BLAS.Matrix.Modifier.Conjugation
- Numeric.BLAS.Matrix.Modifier: instance GHC.Base.Monoid Numeric.BLAS.Matrix.Modifier.Inversion
- Numeric.BLAS.Matrix.Modifier: instance GHC.Base.Monoid Numeric.BLAS.Matrix.Modifier.Transposition
- Numeric.BLAS.Matrix.Modifier: instance GHC.Base.Semigroup Numeric.BLAS.Matrix.Modifier.Conjugation
- Numeric.BLAS.Matrix.Modifier: instance GHC.Base.Semigroup Numeric.BLAS.Matrix.Modifier.Inversion
- Numeric.BLAS.Matrix.Modifier: instance GHC.Base.Semigroup Numeric.BLAS.Matrix.Modifier.Transposition
- Numeric.BLAS.Matrix.Modifier: instance GHC.Classes.Eq Numeric.BLAS.Matrix.Modifier.Conjugation
- Numeric.BLAS.Matrix.Modifier: instance GHC.Classes.Eq Numeric.BLAS.Matrix.Modifier.Inversion
- Numeric.BLAS.Matrix.Modifier: instance GHC.Classes.Eq Numeric.BLAS.Matrix.Modifier.Transposition
- Numeric.BLAS.Matrix.Modifier: instance GHC.Enum.Bounded Numeric.BLAS.Matrix.Modifier.Conjugation
- Numeric.BLAS.Matrix.Modifier: instance GHC.Enum.Bounded Numeric.BLAS.Matrix.Modifier.Inversion
- Numeric.BLAS.Matrix.Modifier: instance GHC.Enum.Bounded Numeric.BLAS.Matrix.Modifier.Transposition
- Numeric.BLAS.Matrix.Modifier: instance GHC.Enum.Enum Numeric.BLAS.Matrix.Modifier.Conjugation
- Numeric.BLAS.Matrix.Modifier: instance GHC.Enum.Enum Numeric.BLAS.Matrix.Modifier.Inversion
- Numeric.BLAS.Matrix.Modifier: instance GHC.Enum.Enum Numeric.BLAS.Matrix.Modifier.Transposition
- Numeric.BLAS.Matrix.Modifier: instance GHC.Show.Show Numeric.BLAS.Matrix.Modifier.Conjugation
- Numeric.BLAS.Matrix.Modifier: instance GHC.Show.Show Numeric.BLAS.Matrix.Modifier.Inversion
- Numeric.BLAS.Matrix.Modifier: instance GHC.Show.Show Numeric.BLAS.Matrix.Modifier.Transposition
+ Numeric.BLAS.Matrix.RowMajor: NonTransposed :: Matrix height width a -> Transposable height width a
+ Numeric.BLAS.Matrix.RowMajor: Transposed :: Matrix width height a -> Transposable height width a
+ Numeric.BLAS.Matrix.RowMajor: above :: (C heightA, C heightB) => (C width, Eq width) => Storable a => Matrix heightA width a -> Matrix heightB width a -> Matrix (heightA ::+ heightB) width a
+ Numeric.BLAS.Matrix.RowMajor: beside :: (C widthA, C widthB) => (C height, Eq height) => Storable a => Matrix height widthA a -> Matrix height widthB a -> Matrix height (widthA ::+ widthB) a
+ Numeric.BLAS.Matrix.RowMajor: data Transposable height width a
+ Numeric.BLAS.Matrix.RowMajor: flattenColumn :: Array2 height () a -> Array height a
+ Numeric.BLAS.Matrix.RowMajor: flattenRow :: Array2 () width a -> Array width a
+ Numeric.BLAS.Matrix.RowMajor: height :: Matrix height width a -> height
+ Numeric.BLAS.Matrix.RowMajor: identity :: (C sh, Floating a) => sh -> Square sh a
+ Numeric.BLAS.Matrix.RowMajor: infixr 2 `above`
+ Numeric.BLAS.Matrix.RowMajor: infixr 3 `beside`
+ Numeric.BLAS.Matrix.RowMajor: instance (Data.Array.Comfort.Shape.C height, Data.Array.Comfort.Shape.C width, Foreign.Storable.Storable a, GHC.Show.Show height, GHC.Show.Show width, GHC.Show.Show a) => GHC.Show.Show (Numeric.BLAS.Matrix.RowMajor.Transposable height width a)
+ Numeric.BLAS.Matrix.RowMajor: kronecker :: (C heightA, C widthA, C heightB, C widthB, Floating a) => Matrix heightA widthA a -> Matrix heightB widthB a -> Matrix (heightA, heightB) (widthA, widthB) a
+ Numeric.BLAS.Matrix.RowMajor: kroneckerLeftTransposable :: (C heightA, C widthA, C heightB, C widthB, Floating a) => Transposable heightA widthA a -> Matrix heightB widthB a -> Matrix (heightA, heightB) (widthA, widthB) a
+ Numeric.BLAS.Matrix.RowMajor: kroneckerTransposable :: (C heightA, C widthA, C heightB, C widthB, Floating a) => Transposable heightA widthA a -> Transposable heightB widthB a -> Transposable (heightA, heightB) (widthA, widthB) a
+ Numeric.BLAS.Matrix.RowMajor: multiply :: (C height, C width, C fuse, Eq fuse, Floating a) => Matrix height fuse a -> Matrix fuse width a -> Matrix height width a
+ Numeric.BLAS.Matrix.RowMajor: multiplyTransposable :: (C height, C width, C fuse, Eq fuse, Floating a) => Transposable height fuse a -> Transposable fuse width a -> Matrix height width a
+ Numeric.BLAS.Matrix.RowMajor: nonTransposed :: Matrix height width a -> Transposable height width a
+ Numeric.BLAS.Matrix.RowMajor: singleColumn :: Array height a -> Array2 height () a
+ Numeric.BLAS.Matrix.RowMajor: singleRow :: Array width a -> Array2 () width a
+ Numeric.BLAS.Matrix.RowMajor: takeBottom :: (C heightA, C heightB, C width, Storable a) => Matrix (heightA ::+ heightB) width a -> Matrix heightB width a
+ Numeric.BLAS.Matrix.RowMajor: takeLeft :: (C height, C widthA, C widthB, Storable a) => Matrix height (widthA ::+ widthB) a -> Matrix height widthA a
+ Numeric.BLAS.Matrix.RowMajor: takeRight :: (C height, C widthA, C widthB, Storable a) => Matrix height (widthA ::+ widthB) a -> Matrix height widthB a
+ Numeric.BLAS.Matrix.RowMajor: takeTop :: (C heightA, C heightB, C width, Storable a) => Matrix (heightA ::+ heightB) width a -> Matrix heightA width a
+ Numeric.BLAS.Matrix.RowMajor: transposeTransposable :: Transposable height width a -> Transposable width height a
+ Numeric.BLAS.Matrix.RowMajor: transposed :: Matrix height width a -> Transposable width height a
+ Numeric.BLAS.Matrix.RowMajor: type Square sh = Matrix sh sh
+ Numeric.BLAS.Matrix.RowMajor: width :: Matrix height width a -> width
- Numeric.BLAS.Matrix.Layout: data Order
+ Numeric.BLAS.Matrix.Layout: data () => Order
- Numeric.BLAS.Matrix.Modifier: data Conjugation
+ Numeric.BLAS.Matrix.Modifier: data () => Conjugation
- Numeric.BLAS.Matrix.Modifier: data Inversion
+ Numeric.BLAS.Matrix.Modifier: data () => Inversion
- Numeric.BLAS.Matrix.Modifier: data Transposition
+ Numeric.BLAS.Matrix.Modifier: data () => Transposition
Files
- Makefile +13/−8
- comfort-blas.cabal +12/−4
- src/Numeric/BLAS/Matrix/Layout.hs +7/−15
- src/Numeric/BLAS/Matrix/Modifier.hs +11/−43
- src/Numeric/BLAS/Matrix/RowMajor.hs +459/−59
- src/Numeric/BLAS/Vector.hs +55/−4
- test/Main.hs +8/−17
- test/Test/ComplexDouble/Main.hs +14/−0
- test/Test/ComplexDouble/Numeric/BLAS/Matrix/RowMajor.hs +254/−0
- test/Test/ComplexDouble/Numeric/BLAS/Vector.hs +177/−106
- test/Test/ComplexFloat/Main.hs +14/−0
- test/Test/ComplexFloat/Numeric/BLAS/Matrix/RowMajor.hs +254/−0
- test/Test/ComplexFloat/Numeric/BLAS/Vector.hs +177/−106
- test/Test/Double/Main.hs +14/−0
- test/Test/Double/Numeric/BLAS/Matrix/RowMajor.hs +254/−0
- test/Test/Double/Numeric/BLAS/Vector.hs +177/−106
- test/Test/Float/Main.hs +14/−0
- test/Test/Float/Numeric/BLAS/Matrix/RowMajor.hs +254/−0
- test/Test/Float/Numeric/BLAS/Vector.hs +177/−106
Makefile view
@@ -1,8 +1,12 @@ TYPES = Float Double ComplexFloat ComplexDouble TEST_MODULES = test/Test/Numeric/BLAS/Slice.hs \- $(patsubst %, test/Test/%/Numeric/BLAS/Vector.hs, $(TYPES)) \- $(patsubst %, test/Test/%/Numeric/BLAS/Vector/Slice.hs, $(TYPES))+ $(patsubst %, test/Test/%/Main.hs, $(TYPES))+TESTABLE = \+ src/Numeric/BLAS/Vector.hs \+ src/Numeric/BLAS/Vector/Slice.hs \+ src/Numeric/BLAS/Matrix/RowMajor.hs + run-test: update-test runhaskell Setup configure --user --enable-tests runhaskell Setup build@@ -14,10 +18,11 @@ test/Test/Numeric/BLAS/Slice.hs: src/Numeric/BLAS/Slice.hs doctest-extract-0.1 -i src/ -o test/ --module-prefix Test Numeric.BLAS.Slice -test/Test/%/Numeric/BLAS/Vector.hs: src/Numeric/BLAS/Vector.hs- doctest-extract-0.1 -i src/ -o test/ --module-prefix Test.$* Numeric.BLAS.Vector- perl -i -p -e "s:NumberModule:$*:" $@+test/Test/%/Main.hs: test-module.list $(TESTABLE)+ doctest-extract-0.1 -i src/ -o test/ --module-prefix Test.$* --library-main Main $$(cat test-module.list)+ for file in $$(find test/Test/$*/Numeric -name "*.hs"); \+ do perl -i -p -e "s:NumberModule:$*:" $$file; \+ done -test/Test/%/Numeric/BLAS/Vector/Slice.hs: src/Numeric/BLAS/Vector/Slice.hs- doctest-extract-0.1 -i src/ -o test/ --module-prefix Test.$* Numeric.BLAS.Vector.Slice- perl -i -p -e "s:NumberModule:$*:" $@+test-module.list: comfort-blas.cabal+ grep '^ \+Test\.Float\.Numeric\.BLAS\.' $< | cut -d. -f3- >$@
comfort-blas.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: 2.2 Name: comfort-blas-Version: 0.0.2+Version: 0.0.3 License: BSD-3-Clause License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de>@@ -17,7 +17,7 @@ Makefile Source-Repository this- Tag: 0.0.2+ Tag: 0.0.3 Type: darcs Location: https://hub.darcs.net/thielema/comfort-blas/ @@ -28,8 +28,8 @@ Library Build-Depends: blas-ffi >=0.0 && <0.2,- netlib-ffi >=0.1.1 && <0.2,- comfort-array >=0.5.2 && <0.6,+ netlib-ffi >=0.1.2 && <0.2,+ comfort-array >=0.5.5 && <0.6, storablevector >=0.2 && <0.3, guarded-allocation >=0.0 && <0.1, non-empty >=0.3.1 && <0.4,@@ -72,6 +72,10 @@ Hs-Source-Dirs: test Main-Is: Main.hs Other-Modules:+ Test.Float.Numeric.BLAS.Matrix.RowMajor+ Test.Double.Numeric.BLAS.Matrix.RowMajor+ Test.ComplexFloat.Numeric.BLAS.Matrix.RowMajor+ Test.ComplexDouble.Numeric.BLAS.Matrix.RowMajor Test.Float.Numeric.BLAS.Vector.Slice Test.Double.Numeric.BLAS.Vector.Slice Test.ComplexFloat.Numeric.BLAS.Vector.Slice@@ -84,6 +88,10 @@ Test.Double.Type Test.ComplexFloat.Type Test.ComplexDouble.Type+ Test.Float.Main+ Test.Double.Main+ Test.ComplexFloat.Main+ Test.ComplexDouble.Main Test.Numeric.BLAS.Slice Test.Slice Test.Generator
src/Numeric/BLAS/Matrix/Layout.hs view
@@ -1,21 +1,13 @@-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeOperators #-}-module Numeric.BLAS.Matrix.Layout where+module Numeric.BLAS.Matrix.Layout (+ Order(..),+ flipOrder,+ transposeFromOrder,+ ) where -import Control.DeepSeq (NFData, rnf)+import Numeric.Netlib.Layout (Order(..), flipOrder) -data Order = RowMajor | ColumnMajor- deriving (Eq, Show)--instance NFData Order where- rnf RowMajor = ()- rnf ColumnMajor = ()--flipOrder :: Order -> Order-flipOrder RowMajor = ColumnMajor-flipOrder ColumnMajor = RowMajor-+{-# DEPRECATED transposeFromOrder "For internal use in package 'lapack'." #-} transposeFromOrder :: Order -> Char transposeFromOrder RowMajor = 'T' transposeFromOrder ColumnMajor = 'N'
src/Numeric/BLAS/Matrix/Modifier.hs view
@@ -1,49 +1,17 @@-module Numeric.BLAS.Matrix.Modifier where--import Numeric.BLAS.Matrix.Layout (Order(RowMajor,ColumnMajor), flipOrder)--import Data.Monoid (Monoid, mempty, mappend)-import Data.Semigroup (Semigroup, (<>))----data Transposition = NonTransposed | Transposed- deriving (Eq, Show, Enum, Bounded)--instance Semigroup Transposition where- x<>y = if x==y then NonTransposed else Transposed--instance Monoid Transposition where- mempty = NonTransposed- mappend = (<>)--transposeOrder :: Transposition -> Order -> Order-transposeOrder NonTransposed = id-transposeOrder Transposed = flipOrder+module Numeric.BLAS.Matrix.Modifier (+ Modi.Transposition(..),+ Modi.transposeOrder,+ Modi.Conjugation(..),+ conjugatedOnRowMajor,+ Modi.Inversion(..),+ ) where +import qualified Numeric.Netlib.Modifier as Modi+import Numeric.Netlib.Modifier (Conjugation(NonConjugated, Conjugated))+import Numeric.Netlib.Layout (Order(RowMajor,ColumnMajor)) -data Conjugation = NonConjugated | Conjugated- deriving (Eq, Show, Enum, Bounded)--instance Semigroup Conjugation where- x<>y = if x==y then NonConjugated else Conjugated--instance Monoid Conjugation where- mempty = NonConjugated- mappend = (<>)-+{-# DEPRECATED conjugatedOnRowMajor "For internal use in package 'lapack'." #-} conjugatedOnRowMajor :: Order -> Conjugation conjugatedOnRowMajor RowMajor = Conjugated conjugatedOnRowMajor ColumnMajor = NonConjugated---data Inversion = NonInverted | Inverted- deriving (Eq, Show, Enum, Bounded)--instance Semigroup Inversion where- x<>y = if x==y then NonInverted else Inverted--instance Monoid Inversion where- mempty = NonInverted- mappend = (<>)
src/Numeric/BLAS/Matrix/RowMajor.hs view
@@ -2,10 +2,19 @@ {-# LANGUAGE TypeOperators #-} module Numeric.BLAS.Matrix.RowMajor ( Matrix,+ Square, Vector,+ height, width,+ Array2.singleRow, Array2.flattenRow,+ Array2.singleColumn, Array2.flattenColumn,+ identity, takeRow, takeColumn, fromRows,+ above,+ beside,+ takeTop, takeBottom,+ takeLeft, takeRight, tensorProduct, decomplex, recomplex,@@ -13,9 +22,15 @@ scaleColumns, multiplyVectorLeft, multiplyVectorRight,+ Transposable(..), nonTransposed, transposed,+ transposeTransposable,+ multiply,+ multiplyTransposable,+ kronecker,+ kroneckerTransposable,+ kroneckerLeftTransposable, ) where -import qualified Numeric.BLAS.Matrix.Modifier as Modifier import qualified Numeric.BLAS.Private as Private import Numeric.BLAS.Matrix.Modifier (Conjugation(NonConjugated,Conjugated)) import Numeric.BLAS.Scalar (zero, one)@@ -26,43 +41,134 @@ import qualified Numeric.Netlib.Class as Class import Foreign.Marshal.Array (copyArray, advancePtr)-import Foreign.ForeignPtr (withForeignPtr, castForeignPtr)-import Foreign.Storable (Storable)+import Foreign.ForeignPtr (ForeignPtr, withForeignPtr, castForeignPtr)+import Foreign.Storable (Storable, poke) import Control.Monad.Trans.Cont (ContT(ContT), evalContT) import Control.Monad.IO.Class (liftIO)+import Control.Applicative (liftA2) import qualified Data.Array.Comfort.Storable.Unchecked as Array+import qualified Data.Array.Comfort.Storable.Dim2 as Array2+import qualified Data.Array.Comfort.Shape.SubSize as SubSize import qualified Data.Array.Comfort.Shape as Shape import Data.Array.Comfort.Storable.Unchecked (Array(Array))+import Data.Array.Comfort.Shape ((::+)) import Data.Foldable (forM_) import Data.Complex (Complex) import Data.Tuple.HT (swap) +{- $setup+>>> import Test.NumberModule.Type (Number_)+>>> import Test.NumberModule.Numeric.BLAS.Vector (forVector, genVector, number_)+>>> import Test.Slice (ShapeInt, shapeInt)+>>> import qualified Numeric.BLAS.Matrix.RowMajor as Matrix+>>> import qualified Numeric.BLAS.Vector as Vector+>>> import qualified Numeric.Netlib.Class as Class+>>> import Numeric.BLAS.Scalar (RealOf)+>>> import qualified Data.Array.Comfort.Storable as Array+>>> import qualified Data.Array.Comfort.Shape as Shape+>>> import qualified Test.QuickCheck as QC+>>>+>>> type Matrix = Matrix.Matrix (Shape.ZeroBased Int) (Shape.ZeroBased Int)+>>> type Real_ = RealOf Number_+>>>+>>> maxDim :: Int+>>> maxDim = 10+>>>+>>> forMatrix ::+>>> (QC.Testable prop, QC.Arbitrary a, Class.Floating a, Show a) =>+>>> QC.Gen a -> (Matrix a -> prop) -> QC.Property+>>> forMatrix genElem =+>>> QC.forAll+>>> (do height <- fmap shapeInt $ QC.choose (0,maxDim)+>>> width <- fmap shapeInt $ QC.choose (0,maxDim)+>>> genVector (height, width) genElem)+>>>+>>> genIdentityTrans ::+>>> (Shape.C sh, Class.Floating a) =>+>>> sh -> QC.Gen (Matrix.Transposable sh sh a)+>>> genIdentityTrans sh = do+>>> trans <- QC.arbitrary+>>> return $+>>> if trans+>>> then Matrix.transposed (Matrix.identity sh)+>>> else Matrix.nonTransposed (Matrix.identity sh)+>>>+>>> transpose ::+>>> (Shape.C height, Eq height, Shape.C width, Class.Floating a) =>+>>> Matrix.Matrix height width a -> Matrix.Matrix width height a+>>> transpose a =+>>> Matrix.multiplyTransposable+>>> (Matrix.transposed a)+>>> (Matrix.nonTransposed (Matrix.identity (Matrix.height a)))+-}++ type Matrix height width = Array (height,width)+{- |+There is also 'Shape.Square'+but this would be incompatible with other matrix operations.+This might be addressed in a new Matrix.Square module.+But for advanced type hacks you can already use the @lapack@ package.+-}+type Square sh = Matrix sh sh type Vector = Array ++height :: Matrix height width a -> height+height = fst . Array.shape++width :: Matrix height width a -> width+width = snd . Array.shape+++{- |+>>> Matrix.identity (Shape.ZeroBased 0) :: Matrix.Square (Shape.ZeroBased Int) Real_+StorableArray.fromList (ZeroBased {... 0},ZeroBased {... 0}) []+>>> Matrix.identity (Shape.ZeroBased 3) :: Matrix.Square (Shape.ZeroBased Int) Real_+StorableArray.fromList (ZeroBased {... 3},ZeroBased {... 3}) [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]+-}+identity :: (Shape.C sh, Class.Floating a) => sh -> Square sh a+identity sh =+ Array.unsafeCreateWithAutoSizes (sh,sh) $+ \(SubSize.Sub blockSize (SubSize.Atom nint, SubSize.Atom _)) yPtr ->+ evalContT $ do+ nPtr <- Call.alloca+ xPtr <- Call.number zero+ incxPtr <- Call.cint 0+ incyPtr <- Call.cint 1+ liftIO $ do+ poke nPtr $ fromIntegral blockSize+ Blas.copy nPtr xPtr incxPtr yPtr incyPtr+ let n = fromIntegral nint+ poke nPtr n+ poke xPtr one+ poke incyPtr (n+1)+ Blas.copy nPtr xPtr incxPtr yPtr incyPtr++ takeRow :: (Shape.Indexed height, Shape.C width, Shape.Index height ~ ix, Storable a) => ix -> Matrix height width a -> Vector width a-takeRow ix (Array (height,width) x) =- Array.unsafeCreateWithSize width $ \n yPtr ->+takeRow ix (Array (height_,width_) x) =+ Array.unsafeCreateWithSize width_ $ \n yPtr -> withForeignPtr x $ \xPtr ->- copyArray yPtr (advancePtr xPtr (n * Shape.offset height ix)) n+ copyArray yPtr (advancePtr xPtr (n * Shape.offset height_ ix)) n takeColumn :: (Shape.C height, Shape.Indexed width, Shape.Index width ~ ix, Class.Floating a) => ix -> Matrix height width a -> Vector height a-takeColumn ix (Array (height,width) x) =- Array.unsafeCreateWithSize height $ \n yPtr -> evalContT $ do- let offset = Shape.offset width ix+takeColumn ix (Array (height_,width_) x) =+ Array.unsafeCreateWithSize height_ $ \n yPtr -> evalContT $ do+ let offset = Shape.offset width_ ix nPtr <- Call.cint n xPtr <- ContT $ withForeignPtr x- incxPtr <- Call.cint $ Shape.size width+ incxPtr <- Call.cint $ Shape.size width_ incyPtr <- Call.cint 1 liftIO $ Blas.copy nPtr (advancePtr xPtr offset) incxPtr yPtr incyPtr @@ -70,27 +176,72 @@ fromRows :: (Shape.C width, Eq width, Storable a) => width -> [Vector width a] -> Matrix ShapeInt width a-fromRows width rows =- Array.unsafeCreate (shapeInt $ length rows, width) $ \dstPtr ->- let widthSize = Shape.size width- in forM_ (zip (pointerSeq widthSize dstPtr) rows) $+fromRows width_ rows =+ Array.unsafeCreateWithAutoSizes (shapeInt $ length rows, width_) $+ \(SubSize.Atom _, SubSize.Atom widthSize) dstPtr ->++ forM_ (zip (pointerSeq widthSize dstPtr) rows) $ \(dstRowPtr, Array.Array rowWidth srcFPtr) -> withForeignPtr srcFPtr $ \srcPtr -> do Call.assert "Matrix.fromRows: non-matching vector size"- (width == rowWidth)+ (width_ == rowWidth) copyArray dstRowPtr srcPtr widthSize +infixr 2 `above`+infixr 3 `beside` --- ToDo: use lapack:Private.multiplyMatrix+above ::+ (Shape.C heightA, Shape.C heightB) =>+ (Shape.C width, Eq width) =>+ (Storable a) =>+ Matrix heightA width a ->+ Matrix heightB width a ->+ Matrix (heightA::+heightB) width a+above = Array2.above++beside ::+ (Shape.C widthA, Shape.C widthB) =>+ (Shape.C height, Eq height) =>+ (Storable a) =>+ Matrix height widthA a ->+ Matrix height widthB a ->+ Matrix height (widthA::+widthB) a+beside = Array2.beside++takeTop ::+ (Shape.C heightA, Shape.C heightB, Shape.C width, Storable a) =>+ Matrix (heightA::+heightB) width a ->+ Matrix heightA width a+takeTop = Array2.takeTop++takeBottom ::+ (Shape.C heightA, Shape.C heightB, Shape.C width, Storable a) =>+ Matrix (heightA::+heightB) width a ->+ Matrix heightB width a+takeBottom = Array2.takeBottom++takeLeft ::+ (Shape.C height, Shape.C widthA, Shape.C widthB, Storable a) =>+ Matrix height (widthA::+widthB) a ->+ Matrix height widthA a+takeLeft = Array2.takeLeft++takeRight ::+ (Shape.C height, Shape.C widthA, Shape.C widthB, Storable a) =>+ Matrix height (widthA::+widthB) a ->+ Matrix height widthB a+takeRight = Array2.takeRight+++{-# WARNING tensorProduct "Don't use conjugation. Left and Right are swapped." #-} tensorProduct :: (Shape.C height, Shape.C width, Class.Floating a) => Either Conjugation Conjugation -> Vector height a -> Vector width a -> Matrix height width a-tensorProduct side (Array height x) (Array width y) =- Array.unsafeCreate (height,width) $ \cPtr -> do- let m = Shape.size width- let n = Shape.size height+tensorProduct side (Array height_ x) (Array width_ y) =+ Array.unsafeCreateWithAutoSizes (height_,width_) $+ \(SubSize.Atom n, SubSize.Atom m) cPtr -> do let trans conjugated = case conjugated of NonConjugated -> 'T'; Conjugated -> 'C' let ((transa,transb),(lda,ldb)) =@@ -120,26 +271,26 @@ (Class.Real a) => Matrix height width (Complex a) -> Matrix height (width, ComplexShape) a-decomplex (Array (height,width) a) =- Array (height, (width, Shape.static)) (castForeignPtr a)+decomplex (Array (height_,width_) a) =+ Array (height_, (width_, Shape.static)) (castForeignPtr a) recomplex :: (Class.Real a) => Matrix height (width, ComplexShape) a -> Matrix height width (Complex a)-recomplex (Array (height, (width, Shape.NestedTuple _)) a) =- Array (height,width) (castForeignPtr a)+recomplex (Array (height_, (width_, Shape.NestedTuple _)) a) =+ Array (height_,width_) (castForeignPtr a) scaleRows :: (Shape.C height, Eq height, Shape.C width, Class.Floating a) => Vector height a -> Matrix height width a -> Matrix height width a-scaleRows (Array heightX x) (Array shape@(height,width) a) =- Array.unsafeCreate shape $ \bPtr -> do- Call.assert "scaleRows: sizes mismatch" (heightX == height)+scaleRows (Array heightX x) (Array shape a) =+ Array.unsafeCreateWithAutoSizes shape $+ \(SubSize.Atom m, SubSize.Atom n) bPtr -> do++ Call.assert "scaleRows: sizes mismatch" (heightX == fst shape) evalContT $ do- let m = Shape.size height- let n = Shape.size width nPtr <- Call.cint n xPtr <- ContT $ withForeignPtr x aPtr <- ContT $ withForeignPtr a@@ -157,12 +308,12 @@ scaleColumns :: (Shape.C height, Shape.C width, Eq width, Class.Floating a) => Vector width a -> Matrix height width a -> Matrix height width a-scaleColumns (Array widthX x) (Array shape@(height,width) a) =- Array.unsafeCreate shape $ \bPtr -> do- Call.assert "scaleColumns: sizes mismatch" (widthX == width)+scaleColumns (Array widthX x) (Array shape a) =+ Array.unsafeCreateWithAutoSizes shape $+ \(SubSize.Atom m, SubSize.Atom n) bPtr -> do++ Call.assert "scaleColumns: sizes mismatch" (widthX == snd shape) evalContT $ do- let m = Shape.size height- let n = Shape.size width transPtr <- Call.char 'N' nPtr <- Call.cint n klPtr <- Call.cint 0@@ -184,47 +335,106 @@ (pointerSeq n bPtr) +{- |+>>> Matrix.multiplyVectorLeft (Array.vectorFromList [3,1,4]) (Array.fromList (Shape.ZeroBased (3::Int), Shape.Range 'a' 'b') [0,1,0,0,1,0::Real_])+StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [4.0,3.0]++prop> :{+ forVector number_ $ \xs ->+ Matrix.multiplyVectorLeft xs (Matrix.identity (Array.shape xs)) == xs+:}+-} multiplyVectorLeft :: (Eq height, Shape.C height, Shape.C width, Class.Floating a) => Vector height a -> Matrix height width a -> Vector width a-multiplyVectorLeft = multiplyVector nonTransposed+multiplyVectorLeft x a = multiplyVector x (NonTransposed a) +{- |+>>> Matrix.multiplyVectorRight (Array.fromList (Shape.Range 'a' 'b', Shape.ZeroBased (3::Int)) [0,0,1,1,0,0]) (Array.vectorFromList [3,1,4::Real_])+StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [4.0,3.0]+>>> Matrix.multiplyVectorRight (Array.fromList (Shape.Range 'a' 'b', Shape.ZeroBased (3::Int)) [2,7,1,8,2,8]) (Array.vectorFromList [3,1,4::Real_])+StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [17.0,58.0]++prop> :{+ forVector number_ $ \xs ->+ Matrix.multiplyVectorRight (Matrix.identity (Array.shape xs)) xs == xs+:}++prop> :{+ forMatrix number_ $ \a ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \x ->+ Matrix.singleColumn (Matrix.multiplyVectorRight a x)+ ==+ Matrix.multiply a (Matrix.singleColumn x)+:}++prop> :{+ forMatrix number_ $ \a ->+ QC.forAll (genVector (fst $ Array.shape a) number_) $ \x ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \y ->+ Vector.dot x (Matrix.multiplyVectorRight a y)+ ==+ Vector.dot (Matrix.multiplyVectorLeft x a) y+:}++prop> :{+ forMatrix number_ $ \a ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \x ->+ Matrix.multiplyVectorRight a x+ ==+ Matrix.multiplyVectorLeft x (transpose a)+:}+-} multiplyVectorRight :: (Shape.C height, Shape.C width, Eq width, Class.Floating a) => Matrix height width a -> Vector width a -> Vector height a-multiplyVectorRight = flip $ multiplyVector transposed+multiplyVectorRight a x = multiplyVector x (Transposed a) -data Transposition heightA widthA heightB widthB =- Transposition- Modifier.Transposition Char- ((heightA,widthA) -> (heightB,widthB))+data Transposable height width a =+ NonTransposed (Matrix height width a)+ | Transposed (Matrix width height a)+ deriving (Show) -transposed :: Transposition height width width height-transposed = Transposition Modifier.Transposed 'T' swap -nonTransposed :: Transposition height width height width-nonTransposed = Transposition Modifier.NonTransposed 'N' id+nonTransposed :: Matrix height width a -> Transposable height width a+nonTransposed = NonTransposed +transposed :: Matrix height width a -> Transposable width height a+transposed = Transposed+++transposeTransposable ::+ Transposable height width a -> Transposable width height a+transposeTransposable at =+ case at of+ NonTransposed a -> Transposed a+ Transposed a -> NonTransposed a+++inspectTransposable ::+ Transposable height width a -> (Char, (height, width), ForeignPtr a)+inspectTransposable at =+ case at of+ NonTransposed (Array shA fptr) -> ('N', shA, fptr)+ Transposed (Array shA fptr) -> ('T', swap shA, fptr)+ multiplyVector ::- (Shape.C heightB, Shape.C widthB, Eq heightB, Class.Floating a) =>- Transposition heightA widthA heightB widthB ->- Vector heightB a -> Matrix heightA widthA a -> Vector widthB a-multiplyVector- (Transposition trans transChar assignDims)- (Array sh x) (Array shA a) =- let (height,width) = assignDims shA in- Array.unsafeCreateWithSize width $ \m0 yPtr -> do+ (Shape.C height, Shape.C width, Eq height, Class.Floating a) =>+ Vector height a -> Transposable height width a -> Vector width a+multiplyVector (Array sh x) at =+ let (transChar, (height_,width_), a) = inspectTransposable at in+ Array.unsafeCreateWithSize width_ $ \m0 yPtr -> do Call.assert "Matrix.RowMajor.multiplyVector: shapes mismatch"- (height == sh)- let n0 = Shape.size height+ (height_ == sh)+ let n0 = Shape.size height_ let (m,n) =- case trans of- Modifier.NonTransposed -> (m0,n0)- Modifier.Transposed -> (n0,m0)- if n==0- then fill zero m yPtr+ case at of+ NonTransposed _ -> (m0,n0)+ Transposed _ -> (n0,m0)+ if n0==0+ then fill zero m0 yPtr else evalContT $ do let lda = m@@ -242,3 +452,193 @@ Blas.gemv transPtr mPtr nPtr alphaPtr aPtr ldaPtr xPtr incxPtr betaPtr yPtr incyPtr+++{- |+>>> :{+ Matrix.multiply+ (Array.fromList (shapeInt 2, shapeInt 2) [1000,100,10,1])+ (Array.fromList (shapeInt 2, shapeInt 3) [0..5::Real_])+:}+... [300.0,1400.0,2500.0,3.0,14.0,25.0]++prop> :{+ forMatrix number_ $ \a ->+ Matrix.multiply (Matrix.identity (Matrix.height a)) a == a+:}+prop> :{+ forMatrix number_ $ \a ->+ Matrix.multiply a (Matrix.identity (Matrix.width a)) == a+:}+prop> :{+ forMatrix number_ $ \a ->+ forMatrix number_ $ \c ->+ QC.forAll (genVector (Matrix.width a, Matrix.height c) number_) $ \b ->+ Matrix.multiply a (Matrix.multiply b c)+ ==+ Matrix.multiply (Matrix.multiply a b) c+:}+-}+multiply ::+ (Shape.C height, Shape.C width, Shape.C fuse, Eq fuse, Class.Floating a) =>+ Matrix height fuse a -> Matrix fuse width a -> Matrix height width a+multiply a b = multiplyTransposable (NonTransposed a) (NonTransposed b)++{- |+prop> :{+ forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.height a)) $ \eye ->+ a == Matrix.multiplyTransposable eye (Matrix.nonTransposed a)+:}+prop> :{+ forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.width a)) $ \eye ->+ a == Matrix.multiplyTransposable (Matrix.nonTransposed a) eye+:}+prop> :{+ forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.width a)) $ \leftEye ->+ QC.forAll (genIdentityTrans (Matrix.height a)) $ \rightEye ->+ Matrix.multiplyTransposable leftEye (Matrix.transposed a)+ ==+ Matrix.multiplyTransposable (Matrix.transposed a) rightEye+:}+prop> :{+ forMatrix number_ $ \a ->+ QC.forAll (QC.choose (0,maxDim)) $ \n ->+ QC.forAll (genVector (Matrix.width a, shapeInt n) number_) $ \b ->+ transpose (Matrix.multiply a b)+ ==+ Matrix.multiplyTransposable (Matrix.transposed b) (Matrix.transposed a)+:}+-}+multiplyTransposable ::+ (Shape.C height, Shape.C width, Shape.C fuse, Eq fuse, Class.Floating a) =>+ Transposable height fuse a ->+ Transposable fuse width a ->+ Matrix height width a+multiplyTransposable a b = multiplyColumnMajor b a++multiplyColumnMajor ::+ (Shape.C height, Shape.C width, Shape.C fuse, Eq fuse, Class.Floating a) =>+ Transposable fuse height a ->+ Transposable width fuse a ->+ Matrix width height a+multiplyColumnMajor at bt =+ let (transa, (widthA,heightA), a) = inspectTransposable at in+ let (transb, (widthB,heightB), b) = inspectTransposable bt in+ Array.unsafeCreate (widthB,heightA) $ \cPtr -> do+ Call.assert+ "Matrix.RowMajor.multiply: shapes mismatch"+ (widthA == heightB)++ evalContT $ do+ let m = Shape.size heightA+ let k = Shape.size widthA+ let n = Shape.size widthB+ let lda = case at of NonTransposed _ -> m; Transposed _ -> k+ let ldb = case bt of NonTransposed _ -> k; Transposed _ -> n+ let ldc = m+ if k==0+ then liftIO $ fill zero (m*n) cPtr+ else do+ transaPtr <- Call.char transa+ transbPtr <- Call.char transb+ mPtr <- Call.cint m+ nPtr <- Call.cint n+ kPtr <- Call.cint k+ alphaPtr <- Call.number one+ aPtr <- ContT $ withForeignPtr a+ ldaPtr <- Call.leadingDim lda+ bPtr <- ContT $ withForeignPtr b+ ldbPtr <- Call.leadingDim ldb+ betaPtr <- Call.number zero+ ldcPtr <- Call.leadingDim ldc+ liftIO $+ Blas.gemm+ transaPtr transbPtr mPtr nPtr kPtr alphaPtr aPtr ldaPtr+ bPtr ldbPtr betaPtr cPtr ldcPtr+++{- |+>>> :{+ Matrix.kronecker+ (Array.fromList (shapeInt 2, shapeInt 2) [0,1,-1,0::Real_])+ (Array.fromList (shapeInt 2, shapeInt 3) [1..6])+:}+... [0.0,0.0,0.0,1.0,2.0,3.0,0.0,0.0,0.0,4.0,5.0,6.0,-1.0,-2.0,-3.0,0.0,0.0,0.0,-4.0,-5.0,-6.0,0.0,0.0,0.0]++>>> :{+ Matrix.kronecker+ (Array.fromList (shapeInt 2, shapeInt 2) [1,2,3,4::Real_])+ (Array.fromList (shapeInt 2, shapeInt 3) [1,2,4,8,16,32])+:}+... [1.0,2.0,4.0,2.0,4.0,8.0,8.0,16.0,32.0,16.0,32.0,64.0,3.0,6.0,12.0,4.0,8.0,16.0,24.0,48.0,96.0,32.0,64.0,128.0]++prop> :{+ QC.forAll (QC.choose (0,5)) $ \m ->+ QC.forAll (QC.choose (0,5)) $ \n ->+ Matrix.kronecker+ (Matrix.identity (shapeInt m))+ (Matrix.identity (shapeInt n))+ ==+ (Matrix.identity (shapeInt m, shapeInt n)+ :: Matrix.Square (ShapeInt, ShapeInt) Number_)+:}+-}+kronecker ::+ (Shape.C heightA, Shape.C widthA, Shape.C heightB, Shape.C widthB,+ Class.Floating a) =>+ Matrix heightA widthA a ->+ Matrix heightB widthB a ->+ Matrix (heightA,heightB) (widthA,widthB) a+kronecker a b = kroneckerLeftTransposable (NonTransposed a) b++kroneckerTransposable ::+ (Shape.C heightA, Shape.C widthA, Shape.C heightB, Shape.C widthB,+ Class.Floating a) =>+ Transposable heightA widthA a ->+ Transposable heightB widthB a ->+ Transposable (heightA,heightB) (widthA,widthB) a+kroneckerTransposable at bt =+ case bt of+ NonTransposed b -> NonTransposed $ kroneckerLeftTransposable at b+ Transposed b ->+ Transposed $ kroneckerLeftTransposable (transposeTransposable at) b++kroneckerLeftTransposable ::+ (Shape.C heightA, Shape.C widthA, Shape.C heightB, Shape.C widthB,+ Class.Floating a) =>+ Transposable heightA widthA a ->+ Matrix heightB widthB a ->+ Matrix (heightA,heightB) (widthA,widthB) a+kroneckerLeftTransposable at (Array (heightB,widthB) b) =+ let (_trans, (heightA,widthA), a) = inspectTransposable at+ in Array.unsafeCreate ((heightA,heightB), (widthA,widthB)) $ \cPtr ->+ evalContT $ do+ let (ma,na) = (Shape.size heightA, Shape.size widthA)+ let (mb,nb) = (Shape.size heightB, Shape.size widthB)+ let (lda,istep) =+ case at of+ NonTransposed _ -> (1,na)+ Transposed _ -> (ma,1)+ transaPtr <- Call.char 'N'+ transbPtr <- Call.char 'T'+ mPtr <- Call.cint na+ nPtr <- Call.cint nb+ kPtr <- Call.cint 1+ alphaPtr <- Call.number one+ aPtr <- ContT $ withForeignPtr a+ ldaPtr <- Call.leadingDim lda+ bPtr <- ContT $ withForeignPtr b+ ldbPtr <- Call.leadingDim 1+ betaPtr <- Call.number zero+ ldcPtr <- Call.leadingDim nb+ liftIO $+ forM_ (liftA2 (,) (take ma [0..]) (take mb [0..])) $ \(i,j) -> do+ let aiPtr = advancePtr aPtr (istep*i)+ let bjPtr = advancePtr bPtr (nb*j)+ let cijPtr = advancePtr cPtr (na*nb*(j+mb*i))+ Blas.gemm+ transbPtr transaPtr nPtr mPtr kPtr alphaPtr+ bjPtr ldbPtr aiPtr ldaPtr betaPtr cijPtr ldcPtr
src/Numeric/BLAS/Vector.hs view
@@ -102,6 +102,7 @@ >>> import Test.Generator (genNumber) >>> import Test.Slice (shapeInt) >>> import Test.Utility (approx)+>>> import qualified Numeric.BLAS.Matrix.RowMajor as Matrix >>> import qualified Numeric.BLAS.Vector as Vector >>> import qualified Numeric.Netlib.Class as Class >>> import qualified Data.Array.Comfort.Shape as Shape@@ -207,19 +208,44 @@ {- |-> constant () = singleton+prop> QC.forAll number_ $ \x -> Vector.constant () x == Vector.singleton x +prop> :{+ QC.forAll (QC.choose (0,1000)) $ \n ->+ QC.forAll number_ $ \x ->+ Vector.sum (Vector.constant (shapeInt n) x) == fromIntegral n * x+:}+ However, singleton does not need 'Class.Floating' constraint. -} constant :: (Shape.C sh, Class.Floating a) => sh -> a -> Vector sh a constant sh a = Array.unsafeCreateWithSize sh $ fill a +{- |+prop> :{+ QC.forAll (QC.choose (0,1000)) $ \n ->+ Vector.sum (Vector.zero (shapeInt n)) == (0 :: Number_)+:}+-} zero :: (Shape.C sh, Class.Floating a) => sh -> Vector sh a zero = flip constant Scalar.zero +{- |+prop> :{+ QC.forAll (QC.choose (0,1000)) $ \n ->+ Vector.sum (Vector.one (shapeInt n)) == (fromIntegral n :: Number_)+:}+-} one :: (Shape.C sh, Class.Floating a) => sh -> Vector sh a one = flip constant Scalar.one +{- |+prop> :{+ QC.forAll (fmap shapeInt $ QC.choose (1,1000)) $ \sh ->+ QC.forAll (QC.elements $ Shape.indices sh) $ \k ->+ Vector.sum (Vector.unit sh k) == (1 :: Number_)+:}+-} unit :: (Shape.Indexed sh, Class.Floating a) => sh -> Shape.Index sh -> Vector sh a@@ -288,7 +314,14 @@ {- |-prop> QC.forAll (QC.choose (1,100)) $ \dim -> QC.forAll (QC.choose (0, dim-1)) $ \i -> QC.forAll (QC.choose (0, dim-1)) $ \j -> Vector.unit (Shape.ZeroBased dim) i == (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_)+prop> :{+ QC.forAll (QC.choose (1,100)) $ \dim ->+ QC.forAll (QC.choose (0, dim-1)) $ \i ->+ QC.forAll (QC.choose (0, dim-1)) $ \j ->+ Vector.unit (Shape.ZeroBased dim) i+ ==+ (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_)+:} -} swap :: (Shape.Indexed sh, Storable a) =>@@ -308,7 +341,23 @@ newtype Dot f a = Dot {runDot :: f a -> f a -> a} {- |-> dot x y = Matrix.toScalar (singleRow x -*| singleColumn y)+prop> :{+ forVector2 number_ $ \xs ys ->+ Vector.dot xs ys+ ==+ Matrix.multiply (Matrix.singleRow xs) (Matrix.singleColumn ys) ! ((),())+:}++prop> :{+ QC.forAll (QC.choose (1,100)) $ \dim ->+ QC.forAll (QC.choose (0, dim-1)) $ \i ->+ QC.forAll (QC.choose (0, dim-1)) $ \j ->+ Vector.dot+ (Vector.unit (shapeInt dim) i)+ (Vector.unit (shapeInt dim) j)+ ==+ (fromIntegral (fromEnum (i==j)) :: Number_)+:} -} dot, (-*|) :: (Shape.C sh, Eq sh, Class.Floating a) =>@@ -323,6 +372,8 @@ (Dot $ dotComplex 'T') {- |+Scalar product+ prop> forVector2 number_ $ \xs ys -> Vector.inner xs ys == Vector.dot (Vector.conjugate xs) ys -} inner ::@@ -575,7 +626,7 @@ {- | prop> forVector real_ $ \xs -> isNonEmpty xs ==> Vector.limits xs == Array.limits xs -In contrast to 'Array.limits'+In contrast to 'CheckedArray.limits' this implementation is based on fast BLAS functions. It should be faster than @Array.minimum@ and @Array.maximum@ although it is certainly not as fast as possible.
test/Main.hs view
@@ -2,15 +2,10 @@ import qualified Test.Numeric.BLAS.Slice as Slice -import qualified Test.Float.Numeric.BLAS.Vector as VectorFloat-import qualified Test.Double.Numeric.BLAS.Vector as VectorDouble-import qualified Test.ComplexFloat.Numeric.BLAS.Vector as VectorComplexFloat-import qualified Test.ComplexDouble.Numeric.BLAS.Vector as VectorComplexDouble--import qualified Test.Float.Numeric.BLAS.Vector.Slice as SliceFloat-import qualified Test.Double.Numeric.BLAS.Vector.Slice as SliceDouble-import qualified Test.ComplexFloat.Numeric.BLAS.Vector.Slice as SliceComplexFloat-import qualified Test.ComplexDouble.Numeric.BLAS.Vector.Slice as SliceComplexDouble+import qualified Test.Float.Main as TestFloat+import qualified Test.Double.Main as TestDouble+import qualified Test.ComplexFloat.Main as TestComplexFloat+import qualified Test.ComplexDouble.Main as TestComplexDouble import qualified Test.DocTest.Driver as DocTest @@ -19,14 +14,10 @@ DocTest.printLine "\nSlice" Slice.test DocTest.printLine "\nFloat"- VectorFloat.test- SliceFloat.test+ TestFloat.main DocTest.printLine "\nDouble"- VectorDouble.test- SliceDouble.test+ TestDouble.main DocTest.printLine "\nComplex Float"- VectorComplexFloat.test- SliceComplexFloat.test+ TestComplexFloat.main DocTest.printLine "\nComplex Double"- VectorComplexDouble.test- SliceComplexDouble.test+ TestComplexDouble.main
+ test/Test/ComplexDouble/Main.hs view
@@ -0,0 +1,14 @@+-- Do not edit! Automatically created with doctest-extract.+module Test.ComplexDouble.Main where++import qualified Test.ComplexDouble.Numeric.BLAS.Matrix.RowMajor+import qualified Test.ComplexDouble.Numeric.BLAS.Vector.Slice+import qualified Test.ComplexDouble.Numeric.BLAS.Vector++import qualified Test.DocTest.Driver as DocTest++main :: DocTest.T ()+main = do+ Test.ComplexDouble.Numeric.BLAS.Matrix.RowMajor.test+ Test.ComplexDouble.Numeric.BLAS.Vector.Slice.test+ Test.ComplexDouble.Numeric.BLAS.Vector.test
+ test/Test/ComplexDouble/Numeric/BLAS/Matrix/RowMajor.hs view
@@ -0,0 +1,254 @@+-- Do not edit! Automatically created with doctest-extract from src/Numeric/BLAS/Matrix/RowMajor.hs+{-# LINE 63 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}++module Test.ComplexDouble.Numeric.BLAS.Matrix.RowMajor where++import Test.DocTest.Base+import qualified Test.DocTest.Driver as DocTest++{-# LINE 64 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+import Test.ComplexDouble.Type (Number_)+import Test.ComplexDouble.Numeric.BLAS.Vector (forVector, genVector, number_)+import Test.Slice (ShapeInt, shapeInt)+import qualified Numeric.BLAS.Matrix.RowMajor as Matrix+import qualified Numeric.BLAS.Vector as Vector+import qualified Numeric.Netlib.Class as Class+import Numeric.BLAS.Scalar (RealOf)+import qualified Data.Array.Comfort.Storable as Array+import qualified Data.Array.Comfort.Shape as Shape+import qualified Test.QuickCheck as QC++type Matrix = Matrix.Matrix (Shape.ZeroBased Int) (Shape.ZeroBased Int)+type Real_ = RealOf Number_++maxDim :: Int+maxDim = 10++forMatrix ::+ (QC.Testable prop, QC.Arbitrary a, Class.Floating a, Show a) =>+ QC.Gen a -> (Matrix a -> prop) -> QC.Property+forMatrix genElem =+ QC.forAll+ (do height <- fmap shapeInt $ QC.choose (0,maxDim)+ width <- fmap shapeInt $ QC.choose (0,maxDim)+ genVector (height, width) genElem)++genIdentityTrans ::+ (Shape.C sh, Class.Floating a) =>+ sh -> QC.Gen (Matrix.Transposable sh sh a)+genIdentityTrans sh = do+ trans <- QC.arbitrary+ return $+ if trans+ then Matrix.transposed (Matrix.identity sh)+ else Matrix.nonTransposed (Matrix.identity sh)++transpose ::+ (Shape.C height, Eq height, Shape.C width, Class.Floating a) =>+ Matrix.Matrix height width a -> Matrix.Matrix width height a+transpose a =+ Matrix.multiplyTransposable+ (Matrix.transposed a)+ (Matrix.nonTransposed (Matrix.identity (Matrix.height a)))++test :: DocTest.T ()+test = do+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:129: "+{-# LINE 129 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 129 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.identity (Shape.ZeroBased 0) :: Matrix.Square (Shape.ZeroBased Int) Real_+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (ZeroBased {",WildCardChunk,LineChunk " 0},ZeroBased {",WildCardChunk,LineChunk " 0}) []"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:131: "+{-# LINE 131 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 131 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.identity (Shape.ZeroBased 3) :: Matrix.Square (Shape.ZeroBased Int) Real_+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (ZeroBased {",WildCardChunk,LineChunk " 3},ZeroBased {",WildCardChunk,LineChunk " 3}) [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:339: "+{-# LINE 339 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 339 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorLeft (Array.vectorFromList [3,1,4]) (Array.fromList (Shape.ZeroBased (3::Int), Shape.Range 'a' 'b') [0,1,0,0,1,0::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [4.0,3.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:342: "+{-# LINE 342 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 342 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forVector number_ $ \xs ->+ Matrix.multiplyVectorLeft xs (Matrix.identity (Array.shape xs)) == xs+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:353: "+{-# LINE 353 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 353 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorRight (Array.fromList (Shape.Range 'a' 'b', Shape.ZeroBased (3::Int)) [0,0,1,1,0,0]) (Array.vectorFromList [3,1,4::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [4.0,3.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:355: "+{-# LINE 355 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 355 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorRight (Array.fromList (Shape.Range 'a' 'b', Shape.ZeroBased (3::Int)) [2,7,1,8,2,8]) (Array.vectorFromList [3,1,4::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [17.0,58.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:358: "+{-# LINE 358 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 358 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forVector number_ $ \xs ->+ Matrix.multiplyVectorRight (Matrix.identity (Array.shape xs)) xs == xs+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:363: "+{-# LINE 363 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 363 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \x ->+ Matrix.singleColumn (Matrix.multiplyVectorRight a x)+ ==+ Matrix.multiply a (Matrix.singleColumn x)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:371: "+{-# LINE 371 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 371 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (fst $ Array.shape a) number_) $ \x ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \y ->+ Vector.dot x (Matrix.multiplyVectorRight a y)+ ==+ Vector.dot (Matrix.multiplyVectorLeft x a) y+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:380: "+{-# LINE 380 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 380 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \x ->+ Matrix.multiplyVectorRight a x+ ==+ Matrix.multiplyVectorLeft x (transpose a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:458: "+{-# LINE 458 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 458 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.multiply+ (Array.fromList (shapeInt 2, shapeInt 2) [1000,100,10,1])+ (Array.fromList (shapeInt 2, shapeInt 3) [0..5::Real_])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [300.0,1400.0,2500.0,3.0,14.0,25.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:465: "+{-# LINE 465 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 465 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ Matrix.multiply (Matrix.identity (Matrix.height a)) a == a+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:469: "+{-# LINE 469 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 469 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ Matrix.multiply a (Matrix.identity (Matrix.width a)) == a+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:473: "+{-# LINE 473 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 473 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ forMatrix number_ $ \c ->+ QC.forAll (genVector (Matrix.width a, Matrix.height c) number_) $ \b ->+ Matrix.multiply a (Matrix.multiply b c)+ ==+ Matrix.multiply (Matrix.multiply a b) c+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:488: "+{-# LINE 488 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 488 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.height a)) $ \eye ->+ a == Matrix.multiplyTransposable eye (Matrix.nonTransposed a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:493: "+{-# LINE 493 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 493 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.width a)) $ \eye ->+ a == Matrix.multiplyTransposable (Matrix.nonTransposed a) eye+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:498: "+{-# LINE 498 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 498 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.width a)) $ \leftEye ->+ QC.forAll (genIdentityTrans (Matrix.height a)) $ \rightEye ->+ Matrix.multiplyTransposable leftEye (Matrix.transposed a)+ ==+ Matrix.multiplyTransposable (Matrix.transposed a) rightEye+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:506: "+{-# LINE 506 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 506 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (QC.choose (0,maxDim)) $ \n ->+ QC.forAll (genVector (Matrix.width a, shapeInt n) number_) $ \b ->+ transpose (Matrix.multiply a b)+ ==+ Matrix.multiplyTransposable (Matrix.transposed b) (Matrix.transposed a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:564: "+{-# LINE 564 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 564 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.kronecker+ (Array.fromList (shapeInt 2, shapeInt 2) [0,1,-1,0::Real_])+ (Array.fromList (shapeInt 2, shapeInt 3) [1..6])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [0.0,0.0,0.0,1.0,2.0,3.0,0.0,0.0,0.0,4.0,5.0,6.0,-1.0,-2.0,-3.0,0.0,0.0,0.0,-4.0,-5.0,-6.0,0.0,0.0,0.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:571: "+{-# LINE 571 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 571 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.kronecker+ (Array.fromList (shapeInt 2, shapeInt 2) [1,2,3,4::Real_])+ (Array.fromList (shapeInt 2, shapeInt 3) [1,2,4,8,16,32])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [1.0,2.0,4.0,2.0,4.0,8.0,8.0,16.0,32.0,16.0,32.0,64.0,3.0,6.0,12.0,4.0,8.0,16.0,24.0,48.0,96.0,32.0,64.0,128.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:578: "+{-# LINE 578 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 578 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + QC.forAll (QC.choose (0,5)) $ \m ->+ QC.forAll (QC.choose (0,5)) $ \n ->+ Matrix.kronecker+ (Matrix.identity (shapeInt m))+ (Matrix.identity (shapeInt n))+ ==+ (Matrix.identity (shapeInt m, shapeInt n)+ :: Matrix.Square (ShapeInt, ShapeInt) Number_)+ )
test/Test/ComplexDouble/Numeric/BLAS/Vector.hs view
@@ -11,6 +11,7 @@ import Test.Generator (genNumber) import Test.Slice (shapeInt) import Test.Utility (approx)+import qualified Numeric.BLAS.Matrix.RowMajor as Matrix import qualified Numeric.BLAS.Vector as Vector import qualified Numeric.Netlib.Class as Class import qualified Data.Array.Comfort.Shape as Shape@@ -102,215 +103,285 @@ test :: DocTest.T () test = do- DocTest.printPrefix "Numeric.BLAS.Vector:239: "-{-# LINE 239 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:211: "+{-# LINE 211 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 239 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 211 "src/Numeric/BLAS/Vector.hs" #-}+ QC.forAll number_ $ \x -> Vector.constant () x == Vector.singleton x+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:213: "+{-# LINE 213 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 213 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ QC.forAll number_ $ \x ->+ Vector.sum (Vector.constant (shapeInt n) x) == fromIntegral n * x+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:225: "+{-# LINE 225 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 225 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ Vector.sum (Vector.zero (shapeInt n)) == (0 :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:234: "+{-# LINE 234 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 234 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ Vector.sum (Vector.one (shapeInt n)) == (fromIntegral n :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:243: "+{-# LINE 243 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 243 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (fmap shapeInt $ QC.choose (1,1000)) $ \sh ->+ QC.forAll (QC.elements $ Shape.indices sh) $ \k ->+ Vector.sum (Vector.unit sh k) == (1 :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:265: "+{-# LINE 265 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 265 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> forVector number_ $ \zs -> Vector.toList ((xs +++ ys) +++ zs) == Vector.toList (xs +++ (ys +++ zs)) )- DocTest.printPrefix "Numeric.BLAS.Vector:248: "-{-# LINE 248 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:274: "+{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 248 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [] == (Vector.reverse $ Vector.autoFromList [] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:249: "-{-# LINE 249 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:275: "+{-# LINE 275 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 249 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 275 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [1] == (Vector.reverse $ Vector.autoFromList [1] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:250: "-{-# LINE 250 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:276: "+{-# LINE 276 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 250 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 276 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [3,2,1] == (Vector.reverse $ Vector.autoFromList [1,2,3] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:252: "-{-# LINE 252 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:278: "+{-# LINE 278 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 252 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 278 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> reverse (Vector.toList xs) == Vector.toList (Vector.reverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:253: "-{-# LINE 253 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:279: "+{-# LINE 279 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 253 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 279 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> xs == Vector.reverse (Vector.reverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:254: "-{-# LINE 254 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:280: "+{-# LINE 280 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 254 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 280 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> Vector.reverse (xs <> ys) == Vector.reverse ys <> Vector.reverse xs )- DocTest.printPrefix "Numeric.BLAS.Vector:269: "-{-# LINE 269 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:295: "+{-# LINE 295 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 269 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 295 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [] == Vector.cyclicReverse (cyclicVectorFromList []) )- DocTest.printPrefix "Numeric.BLAS.Vector:270: "-{-# LINE 270 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:296: "+{-# LINE 296 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 270 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 296 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1] == Vector.cyclicReverse (cyclicVectorFromList [1]) )- DocTest.printPrefix "Numeric.BLAS.Vector:271: "-{-# LINE 271 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:297: "+{-# LINE 297 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 271 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 297 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1,3,2] == Vector.cyclicReverse (cyclicVectorFromList [1,2,3]) )- DocTest.printPrefix "Numeric.BLAS.Vector:272: "-{-# LINE 272 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:298: "+{-# LINE 298 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 272 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 298 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1,6,5,4,3,2] == Vector.cyclicReverse (cyclicVectorFromList [1,2,3,4,5,6]) )- DocTest.printPrefix "Numeric.BLAS.Vector:274: "-{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:300: "+{-# LINE 300 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 300 "src/Numeric/BLAS/Vector.hs" #-} forCyclicVector number_ $ \xs -> xs == Vector.cyclicReverse (Vector.cyclicReverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:291: "-{-# LINE 291 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:317: "+{-# LINE 317 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 291 "src/Numeric/BLAS/Vector.hs" #-}- QC.forAll (QC.choose (1,100)) $ \dim -> QC.forAll (QC.choose (0, dim-1)) $ \i -> QC.forAll (QC.choose (0, dim-1)) $ \j -> Vector.unit (Shape.ZeroBased dim) i == (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_)+{-# LINE 317 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (1,100)) $ \dim ->+ QC.forAll (QC.choose (0, dim-1)) $ \i ->+ QC.forAll (QC.choose (0, dim-1)) $ \j ->+ Vector.unit (Shape.ZeroBased dim) i+ ==+ (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:326: "-{-# LINE 326 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:344: "+{-# LINE 344 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 326 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 344 "src/Numeric/BLAS/Vector.hs" #-}+ + forVector2 number_ $ \xs ys ->+ Vector.dot xs ys+ ==+ Matrix.multiply (Matrix.singleRow xs) (Matrix.singleColumn ys) ! ((),())+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:351: "+{-# LINE 351 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 351 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (1,100)) $ \dim ->+ QC.forAll (QC.choose (0, dim-1)) $ \i ->+ QC.forAll (QC.choose (0, dim-1)) $ \j ->+ Vector.dot+ (Vector.unit (shapeInt dim) i)+ (Vector.unit (shapeInt dim) j)+ ==+ (fromIntegral (fromEnum (i==j)) :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:377: "+{-# LINE 377 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 377 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.inner xs ys == Vector.dot (Vector.conjugate xs) ys )- DocTest.printPrefix "Numeric.BLAS.Vector:379: "-{-# LINE 379 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:430: "+{-# LINE 430 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 379 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 430 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.sum xs == List.sum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:439: "-{-# LINE 439 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:490: "+{-# LINE 490 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 439 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 490 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.normInf xs == List.maximum (0 : List.map absolute (Vector.toList xs)) )- DocTest.printPrefix "Numeric.BLAS.Vector:463: "-{-# LINE 463 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:514: "+{-# LINE 514 "src/Numeric/BLAS/Vector.hs" #-} DocTest.example(-{-# LINE 463 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 514 "src/Numeric/BLAS/Vector.hs" #-} Vector.argAbsMaximum $ Vector.autoFromList [1:+2, 3:+4, 5, 6 :: Complex_] ) [ExpectedLine [LineChunk "(3,6.0 :+ 0.0)"]]- DocTest.printPrefix "Numeric.BLAS.Vector:466: "-{-# LINE 466 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:517: "+{-# LINE 517 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 466 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 517 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> isNonEmpty xs ==> let (xi,xm) = Vector.argAbsMaximum xs in xs!xi == xm )- DocTest.printPrefix "Numeric.BLAS.Vector:467: "-{-# LINE 467 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:518: "+{-# LINE 518 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 467 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 518 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> isNonEmpty xs ==> let (_xi,xm) = Vector.argAbsMaximum xs in List.all (\x -> absolute x <= absolute xm) $ Vector.toList xs )- DocTest.printPrefix "Numeric.BLAS.Vector:468: "-{-# LINE 468 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:519: "+{-# LINE 519 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 468 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 519 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> isNonEmpty xs && isNonEmpty ys ==> let (_xi,xm) = Vector.argAbsMaximum xs; (_yi,ym) = Vector.argAbsMaximum ys; (zi,zm) = Vector.argAbsMaximum (xs+++ys) in case zi of Left _ -> xm==zm && absolute xm >= absolute ym; Right _ -> ym==zm && absolute xm < absolute ym )- DocTest.printPrefix "Numeric.BLAS.Vector:512: "-{-# LINE 512 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:563: "+{-# LINE 563 "src/Numeric/BLAS/Vector.hs" #-} DocTest.example(-{-# LINE 512 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 563 "src/Numeric/BLAS/Vector.hs" #-} Vector.argAbs1Maximum $ Vector.autoFromList [1:+2, 3:+4, 5, 6 :: Complex_] ) [ExpectedLine [LineChunk "(1,3.0 :+ 4.0)"]]- DocTest.printPrefix "Numeric.BLAS.Vector:515: "-{-# LINE 515 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:566: "+{-# LINE 566 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 515 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 566 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.argAbsMaximum xs == Vector.argAbs1Maximum xs )- DocTest.printPrefix "Numeric.BLAS.Vector:548: "-{-# LINE 548 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:599: "+{-# LINE 599 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 548 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 599 "src/Numeric/BLAS/Vector.hs" #-} QC.forAll (QC.choose (0,10)) $ \dim -> QC.forAll (genVector (shapeInt dim) (genNumber 3)) $ \xs -> approx 1e-2 (Vector.product xs) (List.product (Vector.toList (xs :: Vector Number_))) )- DocTest.printPrefix "Numeric.BLAS.Vector:558: "-{-# LINE 558 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:609: "+{-# LINE 609 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 558 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 609 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.minimum xs == List.minimum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:559: "-{-# LINE 559 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:610: "+{-# LINE 610 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 559 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 610 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.maximum xs == List.maximum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:560: "-{-# LINE 560 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:611: "+{-# LINE 611 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 560 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 611 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> - Vector.maximum xs == Vector.minimum (Vector.negate xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:576: "-{-# LINE 576 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:627: "+{-# LINE 627 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 576 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 627 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.limits xs == Array.limits xs )- DocTest.printPrefix "Numeric.BLAS.Vector:606: "-{-# LINE 606 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:657: "+{-# LINE 657 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 606 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 657 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.negate xs == Vector.scale minusOne xs )- DocTest.printPrefix "Numeric.BLAS.Vector:607: "-{-# LINE 607 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:658: "+{-# LINE 658 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 607 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 658 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.scale 2 xs == xs |+| xs )- DocTest.printPrefix "Numeric.BLAS.Vector:676: "-{-# LINE 676 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:727: "+{-# LINE 727 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 676 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 727 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> xs |+| ys == ys |+| xs )- DocTest.printPrefix "Numeric.BLAS.Vector:677: "-{-# LINE 677 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:728: "+{-# LINE 728 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 677 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 728 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> xs == xs |-| ys |+| ys )- DocTest.printPrefix "Numeric.BLAS.Vector:707: "-{-# LINE 707 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:758: "+{-# LINE 758 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 707 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 758 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> xs == Vector.negate (Vector.negate xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:720: "-{-# LINE 720 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:771: "+{-# LINE 771 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 720 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 771 "src/Numeric/BLAS/Vector.hs" #-} QC.forAll (genNumber maxElem) $ \d -> forVector number_ $ \xs -> xs == Vector.raise (-d) (Vector.raise d xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:737: "-{-# LINE 737 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:788: "+{-# LINE 788 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 737 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 788 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.mul xs ys == Vector.mul ys xs )- DocTest.printPrefix "Numeric.BLAS.Vector:745: "-{-# LINE 745 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:796: "+{-# LINE 796 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 745 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 796 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.mulConj xs ys == Vector.mul (Vector.conjugate xs) ys )
+ test/Test/ComplexFloat/Main.hs view
@@ -0,0 +1,14 @@+-- Do not edit! Automatically created with doctest-extract.+module Test.ComplexFloat.Main where++import qualified Test.ComplexFloat.Numeric.BLAS.Matrix.RowMajor+import qualified Test.ComplexFloat.Numeric.BLAS.Vector.Slice+import qualified Test.ComplexFloat.Numeric.BLAS.Vector++import qualified Test.DocTest.Driver as DocTest++main :: DocTest.T ()+main = do+ Test.ComplexFloat.Numeric.BLAS.Matrix.RowMajor.test+ Test.ComplexFloat.Numeric.BLAS.Vector.Slice.test+ Test.ComplexFloat.Numeric.BLAS.Vector.test
+ test/Test/ComplexFloat/Numeric/BLAS/Matrix/RowMajor.hs view
@@ -0,0 +1,254 @@+-- Do not edit! Automatically created with doctest-extract from src/Numeric/BLAS/Matrix/RowMajor.hs+{-# LINE 63 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}++module Test.ComplexFloat.Numeric.BLAS.Matrix.RowMajor where++import Test.DocTest.Base+import qualified Test.DocTest.Driver as DocTest++{-# LINE 64 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+import Test.ComplexFloat.Type (Number_)+import Test.ComplexFloat.Numeric.BLAS.Vector (forVector, genVector, number_)+import Test.Slice (ShapeInt, shapeInt)+import qualified Numeric.BLAS.Matrix.RowMajor as Matrix+import qualified Numeric.BLAS.Vector as Vector+import qualified Numeric.Netlib.Class as Class+import Numeric.BLAS.Scalar (RealOf)+import qualified Data.Array.Comfort.Storable as Array+import qualified Data.Array.Comfort.Shape as Shape+import qualified Test.QuickCheck as QC++type Matrix = Matrix.Matrix (Shape.ZeroBased Int) (Shape.ZeroBased Int)+type Real_ = RealOf Number_++maxDim :: Int+maxDim = 10++forMatrix ::+ (QC.Testable prop, QC.Arbitrary a, Class.Floating a, Show a) =>+ QC.Gen a -> (Matrix a -> prop) -> QC.Property+forMatrix genElem =+ QC.forAll+ (do height <- fmap shapeInt $ QC.choose (0,maxDim)+ width <- fmap shapeInt $ QC.choose (0,maxDim)+ genVector (height, width) genElem)++genIdentityTrans ::+ (Shape.C sh, Class.Floating a) =>+ sh -> QC.Gen (Matrix.Transposable sh sh a)+genIdentityTrans sh = do+ trans <- QC.arbitrary+ return $+ if trans+ then Matrix.transposed (Matrix.identity sh)+ else Matrix.nonTransposed (Matrix.identity sh)++transpose ::+ (Shape.C height, Eq height, Shape.C width, Class.Floating a) =>+ Matrix.Matrix height width a -> Matrix.Matrix width height a+transpose a =+ Matrix.multiplyTransposable+ (Matrix.transposed a)+ (Matrix.nonTransposed (Matrix.identity (Matrix.height a)))++test :: DocTest.T ()+test = do+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:129: "+{-# LINE 129 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 129 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.identity (Shape.ZeroBased 0) :: Matrix.Square (Shape.ZeroBased Int) Real_+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (ZeroBased {",WildCardChunk,LineChunk " 0},ZeroBased {",WildCardChunk,LineChunk " 0}) []"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:131: "+{-# LINE 131 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 131 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.identity (Shape.ZeroBased 3) :: Matrix.Square (Shape.ZeroBased Int) Real_+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (ZeroBased {",WildCardChunk,LineChunk " 3},ZeroBased {",WildCardChunk,LineChunk " 3}) [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:339: "+{-# LINE 339 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 339 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorLeft (Array.vectorFromList [3,1,4]) (Array.fromList (Shape.ZeroBased (3::Int), Shape.Range 'a' 'b') [0,1,0,0,1,0::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [4.0,3.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:342: "+{-# LINE 342 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 342 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forVector number_ $ \xs ->+ Matrix.multiplyVectorLeft xs (Matrix.identity (Array.shape xs)) == xs+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:353: "+{-# LINE 353 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 353 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorRight (Array.fromList (Shape.Range 'a' 'b', Shape.ZeroBased (3::Int)) [0,0,1,1,0,0]) (Array.vectorFromList [3,1,4::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [4.0,3.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:355: "+{-# LINE 355 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 355 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorRight (Array.fromList (Shape.Range 'a' 'b', Shape.ZeroBased (3::Int)) [2,7,1,8,2,8]) (Array.vectorFromList [3,1,4::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [17.0,58.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:358: "+{-# LINE 358 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 358 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forVector number_ $ \xs ->+ Matrix.multiplyVectorRight (Matrix.identity (Array.shape xs)) xs == xs+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:363: "+{-# LINE 363 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 363 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \x ->+ Matrix.singleColumn (Matrix.multiplyVectorRight a x)+ ==+ Matrix.multiply a (Matrix.singleColumn x)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:371: "+{-# LINE 371 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 371 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (fst $ Array.shape a) number_) $ \x ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \y ->+ Vector.dot x (Matrix.multiplyVectorRight a y)+ ==+ Vector.dot (Matrix.multiplyVectorLeft x a) y+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:380: "+{-# LINE 380 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 380 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \x ->+ Matrix.multiplyVectorRight a x+ ==+ Matrix.multiplyVectorLeft x (transpose a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:458: "+{-# LINE 458 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 458 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.multiply+ (Array.fromList (shapeInt 2, shapeInt 2) [1000,100,10,1])+ (Array.fromList (shapeInt 2, shapeInt 3) [0..5::Real_])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [300.0,1400.0,2500.0,3.0,14.0,25.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:465: "+{-# LINE 465 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 465 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ Matrix.multiply (Matrix.identity (Matrix.height a)) a == a+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:469: "+{-# LINE 469 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 469 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ Matrix.multiply a (Matrix.identity (Matrix.width a)) == a+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:473: "+{-# LINE 473 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 473 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ forMatrix number_ $ \c ->+ QC.forAll (genVector (Matrix.width a, Matrix.height c) number_) $ \b ->+ Matrix.multiply a (Matrix.multiply b c)+ ==+ Matrix.multiply (Matrix.multiply a b) c+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:488: "+{-# LINE 488 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 488 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.height a)) $ \eye ->+ a == Matrix.multiplyTransposable eye (Matrix.nonTransposed a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:493: "+{-# LINE 493 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 493 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.width a)) $ \eye ->+ a == Matrix.multiplyTransposable (Matrix.nonTransposed a) eye+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:498: "+{-# LINE 498 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 498 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.width a)) $ \leftEye ->+ QC.forAll (genIdentityTrans (Matrix.height a)) $ \rightEye ->+ Matrix.multiplyTransposable leftEye (Matrix.transposed a)+ ==+ Matrix.multiplyTransposable (Matrix.transposed a) rightEye+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:506: "+{-# LINE 506 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 506 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (QC.choose (0,maxDim)) $ \n ->+ QC.forAll (genVector (Matrix.width a, shapeInt n) number_) $ \b ->+ transpose (Matrix.multiply a b)+ ==+ Matrix.multiplyTransposable (Matrix.transposed b) (Matrix.transposed a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:564: "+{-# LINE 564 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 564 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.kronecker+ (Array.fromList (shapeInt 2, shapeInt 2) [0,1,-1,0::Real_])+ (Array.fromList (shapeInt 2, shapeInt 3) [1..6])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [0.0,0.0,0.0,1.0,2.0,3.0,0.0,0.0,0.0,4.0,5.0,6.0,-1.0,-2.0,-3.0,0.0,0.0,0.0,-4.0,-5.0,-6.0,0.0,0.0,0.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:571: "+{-# LINE 571 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 571 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.kronecker+ (Array.fromList (shapeInt 2, shapeInt 2) [1,2,3,4::Real_])+ (Array.fromList (shapeInt 2, shapeInt 3) [1,2,4,8,16,32])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [1.0,2.0,4.0,2.0,4.0,8.0,8.0,16.0,32.0,16.0,32.0,64.0,3.0,6.0,12.0,4.0,8.0,16.0,24.0,48.0,96.0,32.0,64.0,128.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:578: "+{-# LINE 578 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 578 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + QC.forAll (QC.choose (0,5)) $ \m ->+ QC.forAll (QC.choose (0,5)) $ \n ->+ Matrix.kronecker+ (Matrix.identity (shapeInt m))+ (Matrix.identity (shapeInt n))+ ==+ (Matrix.identity (shapeInt m, shapeInt n)+ :: Matrix.Square (ShapeInt, ShapeInt) Number_)+ )
test/Test/ComplexFloat/Numeric/BLAS/Vector.hs view
@@ -11,6 +11,7 @@ import Test.Generator (genNumber) import Test.Slice (shapeInt) import Test.Utility (approx)+import qualified Numeric.BLAS.Matrix.RowMajor as Matrix import qualified Numeric.BLAS.Vector as Vector import qualified Numeric.Netlib.Class as Class import qualified Data.Array.Comfort.Shape as Shape@@ -102,215 +103,285 @@ test :: DocTest.T () test = do- DocTest.printPrefix "Numeric.BLAS.Vector:239: "-{-# LINE 239 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:211: "+{-# LINE 211 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 239 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 211 "src/Numeric/BLAS/Vector.hs" #-}+ QC.forAll number_ $ \x -> Vector.constant () x == Vector.singleton x+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:213: "+{-# LINE 213 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 213 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ QC.forAll number_ $ \x ->+ Vector.sum (Vector.constant (shapeInt n) x) == fromIntegral n * x+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:225: "+{-# LINE 225 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 225 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ Vector.sum (Vector.zero (shapeInt n)) == (0 :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:234: "+{-# LINE 234 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 234 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ Vector.sum (Vector.one (shapeInt n)) == (fromIntegral n :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:243: "+{-# LINE 243 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 243 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (fmap shapeInt $ QC.choose (1,1000)) $ \sh ->+ QC.forAll (QC.elements $ Shape.indices sh) $ \k ->+ Vector.sum (Vector.unit sh k) == (1 :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:265: "+{-# LINE 265 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 265 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> forVector number_ $ \zs -> Vector.toList ((xs +++ ys) +++ zs) == Vector.toList (xs +++ (ys +++ zs)) )- DocTest.printPrefix "Numeric.BLAS.Vector:248: "-{-# LINE 248 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:274: "+{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 248 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [] == (Vector.reverse $ Vector.autoFromList [] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:249: "-{-# LINE 249 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:275: "+{-# LINE 275 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 249 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 275 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [1] == (Vector.reverse $ Vector.autoFromList [1] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:250: "-{-# LINE 250 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:276: "+{-# LINE 276 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 250 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 276 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [3,2,1] == (Vector.reverse $ Vector.autoFromList [1,2,3] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:252: "-{-# LINE 252 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:278: "+{-# LINE 278 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 252 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 278 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> reverse (Vector.toList xs) == Vector.toList (Vector.reverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:253: "-{-# LINE 253 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:279: "+{-# LINE 279 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 253 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 279 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> xs == Vector.reverse (Vector.reverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:254: "-{-# LINE 254 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:280: "+{-# LINE 280 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 254 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 280 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> Vector.reverse (xs <> ys) == Vector.reverse ys <> Vector.reverse xs )- DocTest.printPrefix "Numeric.BLAS.Vector:269: "-{-# LINE 269 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:295: "+{-# LINE 295 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 269 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 295 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [] == Vector.cyclicReverse (cyclicVectorFromList []) )- DocTest.printPrefix "Numeric.BLAS.Vector:270: "-{-# LINE 270 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:296: "+{-# LINE 296 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 270 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 296 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1] == Vector.cyclicReverse (cyclicVectorFromList [1]) )- DocTest.printPrefix "Numeric.BLAS.Vector:271: "-{-# LINE 271 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:297: "+{-# LINE 297 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 271 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 297 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1,3,2] == Vector.cyclicReverse (cyclicVectorFromList [1,2,3]) )- DocTest.printPrefix "Numeric.BLAS.Vector:272: "-{-# LINE 272 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:298: "+{-# LINE 298 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 272 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 298 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1,6,5,4,3,2] == Vector.cyclicReverse (cyclicVectorFromList [1,2,3,4,5,6]) )- DocTest.printPrefix "Numeric.BLAS.Vector:274: "-{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:300: "+{-# LINE 300 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 300 "src/Numeric/BLAS/Vector.hs" #-} forCyclicVector number_ $ \xs -> xs == Vector.cyclicReverse (Vector.cyclicReverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:291: "-{-# LINE 291 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:317: "+{-# LINE 317 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 291 "src/Numeric/BLAS/Vector.hs" #-}- QC.forAll (QC.choose (1,100)) $ \dim -> QC.forAll (QC.choose (0, dim-1)) $ \i -> QC.forAll (QC.choose (0, dim-1)) $ \j -> Vector.unit (Shape.ZeroBased dim) i == (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_)+{-# LINE 317 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (1,100)) $ \dim ->+ QC.forAll (QC.choose (0, dim-1)) $ \i ->+ QC.forAll (QC.choose (0, dim-1)) $ \j ->+ Vector.unit (Shape.ZeroBased dim) i+ ==+ (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:326: "-{-# LINE 326 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:344: "+{-# LINE 344 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 326 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 344 "src/Numeric/BLAS/Vector.hs" #-}+ + forVector2 number_ $ \xs ys ->+ Vector.dot xs ys+ ==+ Matrix.multiply (Matrix.singleRow xs) (Matrix.singleColumn ys) ! ((),())+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:351: "+{-# LINE 351 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 351 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (1,100)) $ \dim ->+ QC.forAll (QC.choose (0, dim-1)) $ \i ->+ QC.forAll (QC.choose (0, dim-1)) $ \j ->+ Vector.dot+ (Vector.unit (shapeInt dim) i)+ (Vector.unit (shapeInt dim) j)+ ==+ (fromIntegral (fromEnum (i==j)) :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:377: "+{-# LINE 377 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 377 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.inner xs ys == Vector.dot (Vector.conjugate xs) ys )- DocTest.printPrefix "Numeric.BLAS.Vector:379: "-{-# LINE 379 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:430: "+{-# LINE 430 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 379 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 430 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.sum xs == List.sum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:439: "-{-# LINE 439 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:490: "+{-# LINE 490 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 439 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 490 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.normInf xs == List.maximum (0 : List.map absolute (Vector.toList xs)) )- DocTest.printPrefix "Numeric.BLAS.Vector:463: "-{-# LINE 463 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:514: "+{-# LINE 514 "src/Numeric/BLAS/Vector.hs" #-} DocTest.example(-{-# LINE 463 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 514 "src/Numeric/BLAS/Vector.hs" #-} Vector.argAbsMaximum $ Vector.autoFromList [1:+2, 3:+4, 5, 6 :: Complex_] ) [ExpectedLine [LineChunk "(3,6.0 :+ 0.0)"]]- DocTest.printPrefix "Numeric.BLAS.Vector:466: "-{-# LINE 466 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:517: "+{-# LINE 517 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 466 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 517 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> isNonEmpty xs ==> let (xi,xm) = Vector.argAbsMaximum xs in xs!xi == xm )- DocTest.printPrefix "Numeric.BLAS.Vector:467: "-{-# LINE 467 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:518: "+{-# LINE 518 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 467 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 518 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> isNonEmpty xs ==> let (_xi,xm) = Vector.argAbsMaximum xs in List.all (\x -> absolute x <= absolute xm) $ Vector.toList xs )- DocTest.printPrefix "Numeric.BLAS.Vector:468: "-{-# LINE 468 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:519: "+{-# LINE 519 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 468 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 519 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> isNonEmpty xs && isNonEmpty ys ==> let (_xi,xm) = Vector.argAbsMaximum xs; (_yi,ym) = Vector.argAbsMaximum ys; (zi,zm) = Vector.argAbsMaximum (xs+++ys) in case zi of Left _ -> xm==zm && absolute xm >= absolute ym; Right _ -> ym==zm && absolute xm < absolute ym )- DocTest.printPrefix "Numeric.BLAS.Vector:512: "-{-# LINE 512 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:563: "+{-# LINE 563 "src/Numeric/BLAS/Vector.hs" #-} DocTest.example(-{-# LINE 512 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 563 "src/Numeric/BLAS/Vector.hs" #-} Vector.argAbs1Maximum $ Vector.autoFromList [1:+2, 3:+4, 5, 6 :: Complex_] ) [ExpectedLine [LineChunk "(1,3.0 :+ 4.0)"]]- DocTest.printPrefix "Numeric.BLAS.Vector:515: "-{-# LINE 515 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:566: "+{-# LINE 566 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 515 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 566 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.argAbsMaximum xs == Vector.argAbs1Maximum xs )- DocTest.printPrefix "Numeric.BLAS.Vector:548: "-{-# LINE 548 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:599: "+{-# LINE 599 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 548 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 599 "src/Numeric/BLAS/Vector.hs" #-} QC.forAll (QC.choose (0,10)) $ \dim -> QC.forAll (genVector (shapeInt dim) (genNumber 3)) $ \xs -> approx 1e-2 (Vector.product xs) (List.product (Vector.toList (xs :: Vector Number_))) )- DocTest.printPrefix "Numeric.BLAS.Vector:558: "-{-# LINE 558 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:609: "+{-# LINE 609 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 558 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 609 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.minimum xs == List.minimum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:559: "-{-# LINE 559 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:610: "+{-# LINE 610 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 559 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 610 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.maximum xs == List.maximum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:560: "-{-# LINE 560 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:611: "+{-# LINE 611 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 560 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 611 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> - Vector.maximum xs == Vector.minimum (Vector.negate xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:576: "-{-# LINE 576 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:627: "+{-# LINE 627 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 576 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 627 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.limits xs == Array.limits xs )- DocTest.printPrefix "Numeric.BLAS.Vector:606: "-{-# LINE 606 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:657: "+{-# LINE 657 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 606 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 657 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.negate xs == Vector.scale minusOne xs )- DocTest.printPrefix "Numeric.BLAS.Vector:607: "-{-# LINE 607 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:658: "+{-# LINE 658 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 607 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 658 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.scale 2 xs == xs |+| xs )- DocTest.printPrefix "Numeric.BLAS.Vector:676: "-{-# LINE 676 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:727: "+{-# LINE 727 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 676 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 727 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> xs |+| ys == ys |+| xs )- DocTest.printPrefix "Numeric.BLAS.Vector:677: "-{-# LINE 677 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:728: "+{-# LINE 728 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 677 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 728 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> xs == xs |-| ys |+| ys )- DocTest.printPrefix "Numeric.BLAS.Vector:707: "-{-# LINE 707 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:758: "+{-# LINE 758 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 707 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 758 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> xs == Vector.negate (Vector.negate xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:720: "-{-# LINE 720 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:771: "+{-# LINE 771 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 720 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 771 "src/Numeric/BLAS/Vector.hs" #-} QC.forAll (genNumber maxElem) $ \d -> forVector number_ $ \xs -> xs == Vector.raise (-d) (Vector.raise d xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:737: "-{-# LINE 737 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:788: "+{-# LINE 788 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 737 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 788 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.mul xs ys == Vector.mul ys xs )- DocTest.printPrefix "Numeric.BLAS.Vector:745: "-{-# LINE 745 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:796: "+{-# LINE 796 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 745 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 796 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.mulConj xs ys == Vector.mul (Vector.conjugate xs) ys )
+ test/Test/Double/Main.hs view
@@ -0,0 +1,14 @@+-- Do not edit! Automatically created with doctest-extract.+module Test.Double.Main where++import qualified Test.Double.Numeric.BLAS.Matrix.RowMajor+import qualified Test.Double.Numeric.BLAS.Vector.Slice+import qualified Test.Double.Numeric.BLAS.Vector++import qualified Test.DocTest.Driver as DocTest++main :: DocTest.T ()+main = do+ Test.Double.Numeric.BLAS.Matrix.RowMajor.test+ Test.Double.Numeric.BLAS.Vector.Slice.test+ Test.Double.Numeric.BLAS.Vector.test
+ test/Test/Double/Numeric/BLAS/Matrix/RowMajor.hs view
@@ -0,0 +1,254 @@+-- Do not edit! Automatically created with doctest-extract from src/Numeric/BLAS/Matrix/RowMajor.hs+{-# LINE 63 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}++module Test.Double.Numeric.BLAS.Matrix.RowMajor where++import Test.DocTest.Base+import qualified Test.DocTest.Driver as DocTest++{-# LINE 64 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+import Test.Double.Type (Number_)+import Test.Double.Numeric.BLAS.Vector (forVector, genVector, number_)+import Test.Slice (ShapeInt, shapeInt)+import qualified Numeric.BLAS.Matrix.RowMajor as Matrix+import qualified Numeric.BLAS.Vector as Vector+import qualified Numeric.Netlib.Class as Class+import Numeric.BLAS.Scalar (RealOf)+import qualified Data.Array.Comfort.Storable as Array+import qualified Data.Array.Comfort.Shape as Shape+import qualified Test.QuickCheck as QC++type Matrix = Matrix.Matrix (Shape.ZeroBased Int) (Shape.ZeroBased Int)+type Real_ = RealOf Number_++maxDim :: Int+maxDim = 10++forMatrix ::+ (QC.Testable prop, QC.Arbitrary a, Class.Floating a, Show a) =>+ QC.Gen a -> (Matrix a -> prop) -> QC.Property+forMatrix genElem =+ QC.forAll+ (do height <- fmap shapeInt $ QC.choose (0,maxDim)+ width <- fmap shapeInt $ QC.choose (0,maxDim)+ genVector (height, width) genElem)++genIdentityTrans ::+ (Shape.C sh, Class.Floating a) =>+ sh -> QC.Gen (Matrix.Transposable sh sh a)+genIdentityTrans sh = do+ trans <- QC.arbitrary+ return $+ if trans+ then Matrix.transposed (Matrix.identity sh)+ else Matrix.nonTransposed (Matrix.identity sh)++transpose ::+ (Shape.C height, Eq height, Shape.C width, Class.Floating a) =>+ Matrix.Matrix height width a -> Matrix.Matrix width height a+transpose a =+ Matrix.multiplyTransposable+ (Matrix.transposed a)+ (Matrix.nonTransposed (Matrix.identity (Matrix.height a)))++test :: DocTest.T ()+test = do+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:129: "+{-# LINE 129 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 129 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.identity (Shape.ZeroBased 0) :: Matrix.Square (Shape.ZeroBased Int) Real_+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (ZeroBased {",WildCardChunk,LineChunk " 0},ZeroBased {",WildCardChunk,LineChunk " 0}) []"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:131: "+{-# LINE 131 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 131 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.identity (Shape.ZeroBased 3) :: Matrix.Square (Shape.ZeroBased Int) Real_+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (ZeroBased {",WildCardChunk,LineChunk " 3},ZeroBased {",WildCardChunk,LineChunk " 3}) [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:339: "+{-# LINE 339 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 339 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorLeft (Array.vectorFromList [3,1,4]) (Array.fromList (Shape.ZeroBased (3::Int), Shape.Range 'a' 'b') [0,1,0,0,1,0::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [4.0,3.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:342: "+{-# LINE 342 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 342 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forVector number_ $ \xs ->+ Matrix.multiplyVectorLeft xs (Matrix.identity (Array.shape xs)) == xs+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:353: "+{-# LINE 353 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 353 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorRight (Array.fromList (Shape.Range 'a' 'b', Shape.ZeroBased (3::Int)) [0,0,1,1,0,0]) (Array.vectorFromList [3,1,4::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [4.0,3.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:355: "+{-# LINE 355 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 355 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorRight (Array.fromList (Shape.Range 'a' 'b', Shape.ZeroBased (3::Int)) [2,7,1,8,2,8]) (Array.vectorFromList [3,1,4::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [17.0,58.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:358: "+{-# LINE 358 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 358 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forVector number_ $ \xs ->+ Matrix.multiplyVectorRight (Matrix.identity (Array.shape xs)) xs == xs+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:363: "+{-# LINE 363 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 363 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \x ->+ Matrix.singleColumn (Matrix.multiplyVectorRight a x)+ ==+ Matrix.multiply a (Matrix.singleColumn x)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:371: "+{-# LINE 371 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 371 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (fst $ Array.shape a) number_) $ \x ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \y ->+ Vector.dot x (Matrix.multiplyVectorRight a y)+ ==+ Vector.dot (Matrix.multiplyVectorLeft x a) y+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:380: "+{-# LINE 380 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 380 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \x ->+ Matrix.multiplyVectorRight a x+ ==+ Matrix.multiplyVectorLeft x (transpose a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:458: "+{-# LINE 458 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 458 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.multiply+ (Array.fromList (shapeInt 2, shapeInt 2) [1000,100,10,1])+ (Array.fromList (shapeInt 2, shapeInt 3) [0..5::Real_])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [300.0,1400.0,2500.0,3.0,14.0,25.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:465: "+{-# LINE 465 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 465 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ Matrix.multiply (Matrix.identity (Matrix.height a)) a == a+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:469: "+{-# LINE 469 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 469 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ Matrix.multiply a (Matrix.identity (Matrix.width a)) == a+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:473: "+{-# LINE 473 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 473 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ forMatrix number_ $ \c ->+ QC.forAll (genVector (Matrix.width a, Matrix.height c) number_) $ \b ->+ Matrix.multiply a (Matrix.multiply b c)+ ==+ Matrix.multiply (Matrix.multiply a b) c+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:488: "+{-# LINE 488 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 488 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.height a)) $ \eye ->+ a == Matrix.multiplyTransposable eye (Matrix.nonTransposed a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:493: "+{-# LINE 493 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 493 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.width a)) $ \eye ->+ a == Matrix.multiplyTransposable (Matrix.nonTransposed a) eye+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:498: "+{-# LINE 498 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 498 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.width a)) $ \leftEye ->+ QC.forAll (genIdentityTrans (Matrix.height a)) $ \rightEye ->+ Matrix.multiplyTransposable leftEye (Matrix.transposed a)+ ==+ Matrix.multiplyTransposable (Matrix.transposed a) rightEye+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:506: "+{-# LINE 506 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 506 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (QC.choose (0,maxDim)) $ \n ->+ QC.forAll (genVector (Matrix.width a, shapeInt n) number_) $ \b ->+ transpose (Matrix.multiply a b)+ ==+ Matrix.multiplyTransposable (Matrix.transposed b) (Matrix.transposed a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:564: "+{-# LINE 564 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 564 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.kronecker+ (Array.fromList (shapeInt 2, shapeInt 2) [0,1,-1,0::Real_])+ (Array.fromList (shapeInt 2, shapeInt 3) [1..6])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [0.0,0.0,0.0,1.0,2.0,3.0,0.0,0.0,0.0,4.0,5.0,6.0,-1.0,-2.0,-3.0,0.0,0.0,0.0,-4.0,-5.0,-6.0,0.0,0.0,0.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:571: "+{-# LINE 571 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 571 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.kronecker+ (Array.fromList (shapeInt 2, shapeInt 2) [1,2,3,4::Real_])+ (Array.fromList (shapeInt 2, shapeInt 3) [1,2,4,8,16,32])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [1.0,2.0,4.0,2.0,4.0,8.0,8.0,16.0,32.0,16.0,32.0,64.0,3.0,6.0,12.0,4.0,8.0,16.0,24.0,48.0,96.0,32.0,64.0,128.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:578: "+{-# LINE 578 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 578 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + QC.forAll (QC.choose (0,5)) $ \m ->+ QC.forAll (QC.choose (0,5)) $ \n ->+ Matrix.kronecker+ (Matrix.identity (shapeInt m))+ (Matrix.identity (shapeInt n))+ ==+ (Matrix.identity (shapeInt m, shapeInt n)+ :: Matrix.Square (ShapeInt, ShapeInt) Number_)+ )
test/Test/Double/Numeric/BLAS/Vector.hs view
@@ -11,6 +11,7 @@ import Test.Generator (genNumber) import Test.Slice (shapeInt) import Test.Utility (approx)+import qualified Numeric.BLAS.Matrix.RowMajor as Matrix import qualified Numeric.BLAS.Vector as Vector import qualified Numeric.Netlib.Class as Class import qualified Data.Array.Comfort.Shape as Shape@@ -102,215 +103,285 @@ test :: DocTest.T () test = do- DocTest.printPrefix "Numeric.BLAS.Vector:239: "-{-# LINE 239 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:211: "+{-# LINE 211 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 239 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 211 "src/Numeric/BLAS/Vector.hs" #-}+ QC.forAll number_ $ \x -> Vector.constant () x == Vector.singleton x+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:213: "+{-# LINE 213 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 213 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ QC.forAll number_ $ \x ->+ Vector.sum (Vector.constant (shapeInt n) x) == fromIntegral n * x+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:225: "+{-# LINE 225 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 225 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ Vector.sum (Vector.zero (shapeInt n)) == (0 :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:234: "+{-# LINE 234 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 234 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ Vector.sum (Vector.one (shapeInt n)) == (fromIntegral n :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:243: "+{-# LINE 243 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 243 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (fmap shapeInt $ QC.choose (1,1000)) $ \sh ->+ QC.forAll (QC.elements $ Shape.indices sh) $ \k ->+ Vector.sum (Vector.unit sh k) == (1 :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:265: "+{-# LINE 265 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 265 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> forVector number_ $ \zs -> Vector.toList ((xs +++ ys) +++ zs) == Vector.toList (xs +++ (ys +++ zs)) )- DocTest.printPrefix "Numeric.BLAS.Vector:248: "-{-# LINE 248 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:274: "+{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 248 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [] == (Vector.reverse $ Vector.autoFromList [] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:249: "-{-# LINE 249 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:275: "+{-# LINE 275 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 249 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 275 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [1] == (Vector.reverse $ Vector.autoFromList [1] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:250: "-{-# LINE 250 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:276: "+{-# LINE 276 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 250 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 276 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [3,2,1] == (Vector.reverse $ Vector.autoFromList [1,2,3] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:252: "-{-# LINE 252 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:278: "+{-# LINE 278 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 252 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 278 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> reverse (Vector.toList xs) == Vector.toList (Vector.reverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:253: "-{-# LINE 253 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:279: "+{-# LINE 279 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 253 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 279 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> xs == Vector.reverse (Vector.reverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:254: "-{-# LINE 254 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:280: "+{-# LINE 280 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 254 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 280 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> Vector.reverse (xs <> ys) == Vector.reverse ys <> Vector.reverse xs )- DocTest.printPrefix "Numeric.BLAS.Vector:269: "-{-# LINE 269 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:295: "+{-# LINE 295 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 269 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 295 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [] == Vector.cyclicReverse (cyclicVectorFromList []) )- DocTest.printPrefix "Numeric.BLAS.Vector:270: "-{-# LINE 270 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:296: "+{-# LINE 296 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 270 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 296 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1] == Vector.cyclicReverse (cyclicVectorFromList [1]) )- DocTest.printPrefix "Numeric.BLAS.Vector:271: "-{-# LINE 271 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:297: "+{-# LINE 297 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 271 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 297 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1,3,2] == Vector.cyclicReverse (cyclicVectorFromList [1,2,3]) )- DocTest.printPrefix "Numeric.BLAS.Vector:272: "-{-# LINE 272 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:298: "+{-# LINE 298 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 272 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 298 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1,6,5,4,3,2] == Vector.cyclicReverse (cyclicVectorFromList [1,2,3,4,5,6]) )- DocTest.printPrefix "Numeric.BLAS.Vector:274: "-{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:300: "+{-# LINE 300 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 300 "src/Numeric/BLAS/Vector.hs" #-} forCyclicVector number_ $ \xs -> xs == Vector.cyclicReverse (Vector.cyclicReverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:291: "-{-# LINE 291 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:317: "+{-# LINE 317 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 291 "src/Numeric/BLAS/Vector.hs" #-}- QC.forAll (QC.choose (1,100)) $ \dim -> QC.forAll (QC.choose (0, dim-1)) $ \i -> QC.forAll (QC.choose (0, dim-1)) $ \j -> Vector.unit (Shape.ZeroBased dim) i == (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_)+{-# LINE 317 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (1,100)) $ \dim ->+ QC.forAll (QC.choose (0, dim-1)) $ \i ->+ QC.forAll (QC.choose (0, dim-1)) $ \j ->+ Vector.unit (Shape.ZeroBased dim) i+ ==+ (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:326: "-{-# LINE 326 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:344: "+{-# LINE 344 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 326 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 344 "src/Numeric/BLAS/Vector.hs" #-}+ + forVector2 number_ $ \xs ys ->+ Vector.dot xs ys+ ==+ Matrix.multiply (Matrix.singleRow xs) (Matrix.singleColumn ys) ! ((),())+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:351: "+{-# LINE 351 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 351 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (1,100)) $ \dim ->+ QC.forAll (QC.choose (0, dim-1)) $ \i ->+ QC.forAll (QC.choose (0, dim-1)) $ \j ->+ Vector.dot+ (Vector.unit (shapeInt dim) i)+ (Vector.unit (shapeInt dim) j)+ ==+ (fromIntegral (fromEnum (i==j)) :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:377: "+{-# LINE 377 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 377 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.inner xs ys == Vector.dot (Vector.conjugate xs) ys )- DocTest.printPrefix "Numeric.BLAS.Vector:379: "-{-# LINE 379 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:430: "+{-# LINE 430 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 379 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 430 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.sum xs == List.sum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:439: "-{-# LINE 439 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:490: "+{-# LINE 490 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 439 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 490 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.normInf xs == List.maximum (0 : List.map absolute (Vector.toList xs)) )- DocTest.printPrefix "Numeric.BLAS.Vector:463: "-{-# LINE 463 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:514: "+{-# LINE 514 "src/Numeric/BLAS/Vector.hs" #-} DocTest.example(-{-# LINE 463 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 514 "src/Numeric/BLAS/Vector.hs" #-} Vector.argAbsMaximum $ Vector.autoFromList [1:+2, 3:+4, 5, 6 :: Complex_] ) [ExpectedLine [LineChunk "(3,6.0 :+ 0.0)"]]- DocTest.printPrefix "Numeric.BLAS.Vector:466: "-{-# LINE 466 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:517: "+{-# LINE 517 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 466 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 517 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> isNonEmpty xs ==> let (xi,xm) = Vector.argAbsMaximum xs in xs!xi == xm )- DocTest.printPrefix "Numeric.BLAS.Vector:467: "-{-# LINE 467 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:518: "+{-# LINE 518 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 467 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 518 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> isNonEmpty xs ==> let (_xi,xm) = Vector.argAbsMaximum xs in List.all (\x -> absolute x <= absolute xm) $ Vector.toList xs )- DocTest.printPrefix "Numeric.BLAS.Vector:468: "-{-# LINE 468 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:519: "+{-# LINE 519 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 468 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 519 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> isNonEmpty xs && isNonEmpty ys ==> let (_xi,xm) = Vector.argAbsMaximum xs; (_yi,ym) = Vector.argAbsMaximum ys; (zi,zm) = Vector.argAbsMaximum (xs+++ys) in case zi of Left _ -> xm==zm && absolute xm >= absolute ym; Right _ -> ym==zm && absolute xm < absolute ym )- DocTest.printPrefix "Numeric.BLAS.Vector:512: "-{-# LINE 512 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:563: "+{-# LINE 563 "src/Numeric/BLAS/Vector.hs" #-} DocTest.example(-{-# LINE 512 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 563 "src/Numeric/BLAS/Vector.hs" #-} Vector.argAbs1Maximum $ Vector.autoFromList [1:+2, 3:+4, 5, 6 :: Complex_] ) [ExpectedLine [LineChunk "(1,3.0 :+ 4.0)"]]- DocTest.printPrefix "Numeric.BLAS.Vector:515: "-{-# LINE 515 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:566: "+{-# LINE 566 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 515 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 566 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.argAbsMaximum xs == Vector.argAbs1Maximum xs )- DocTest.printPrefix "Numeric.BLAS.Vector:548: "-{-# LINE 548 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:599: "+{-# LINE 599 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 548 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 599 "src/Numeric/BLAS/Vector.hs" #-} QC.forAll (QC.choose (0,10)) $ \dim -> QC.forAll (genVector (shapeInt dim) (genNumber 3)) $ \xs -> approx 1e-2 (Vector.product xs) (List.product (Vector.toList (xs :: Vector Number_))) )- DocTest.printPrefix "Numeric.BLAS.Vector:558: "-{-# LINE 558 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:609: "+{-# LINE 609 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 558 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 609 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.minimum xs == List.minimum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:559: "-{-# LINE 559 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:610: "+{-# LINE 610 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 559 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 610 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.maximum xs == List.maximum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:560: "-{-# LINE 560 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:611: "+{-# LINE 611 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 560 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 611 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> - Vector.maximum xs == Vector.minimum (Vector.negate xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:576: "-{-# LINE 576 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:627: "+{-# LINE 627 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 576 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 627 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.limits xs == Array.limits xs )- DocTest.printPrefix "Numeric.BLAS.Vector:606: "-{-# LINE 606 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:657: "+{-# LINE 657 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 606 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 657 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.negate xs == Vector.scale minusOne xs )- DocTest.printPrefix "Numeric.BLAS.Vector:607: "-{-# LINE 607 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:658: "+{-# LINE 658 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 607 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 658 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.scale 2 xs == xs |+| xs )- DocTest.printPrefix "Numeric.BLAS.Vector:676: "-{-# LINE 676 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:727: "+{-# LINE 727 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 676 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 727 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> xs |+| ys == ys |+| xs )- DocTest.printPrefix "Numeric.BLAS.Vector:677: "-{-# LINE 677 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:728: "+{-# LINE 728 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 677 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 728 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> xs == xs |-| ys |+| ys )- DocTest.printPrefix "Numeric.BLAS.Vector:707: "-{-# LINE 707 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:758: "+{-# LINE 758 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 707 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 758 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> xs == Vector.negate (Vector.negate xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:720: "-{-# LINE 720 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:771: "+{-# LINE 771 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 720 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 771 "src/Numeric/BLAS/Vector.hs" #-} QC.forAll (genNumber maxElem) $ \d -> forVector number_ $ \xs -> xs == Vector.raise (-d) (Vector.raise d xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:737: "-{-# LINE 737 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:788: "+{-# LINE 788 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 737 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 788 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.mul xs ys == Vector.mul ys xs )- DocTest.printPrefix "Numeric.BLAS.Vector:745: "-{-# LINE 745 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:796: "+{-# LINE 796 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 745 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 796 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.mulConj xs ys == Vector.mul (Vector.conjugate xs) ys )
+ test/Test/Float/Main.hs view
@@ -0,0 +1,14 @@+-- Do not edit! Automatically created with doctest-extract.+module Test.Float.Main where++import qualified Test.Float.Numeric.BLAS.Matrix.RowMajor+import qualified Test.Float.Numeric.BLAS.Vector.Slice+import qualified Test.Float.Numeric.BLAS.Vector++import qualified Test.DocTest.Driver as DocTest++main :: DocTest.T ()+main = do+ Test.Float.Numeric.BLAS.Matrix.RowMajor.test+ Test.Float.Numeric.BLAS.Vector.Slice.test+ Test.Float.Numeric.BLAS.Vector.test
+ test/Test/Float/Numeric/BLAS/Matrix/RowMajor.hs view
@@ -0,0 +1,254 @@+-- Do not edit! Automatically created with doctest-extract from src/Numeric/BLAS/Matrix/RowMajor.hs+{-# LINE 63 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}++module Test.Float.Numeric.BLAS.Matrix.RowMajor where++import Test.DocTest.Base+import qualified Test.DocTest.Driver as DocTest++{-# LINE 64 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+import Test.Float.Type (Number_)+import Test.Float.Numeric.BLAS.Vector (forVector, genVector, number_)+import Test.Slice (ShapeInt, shapeInt)+import qualified Numeric.BLAS.Matrix.RowMajor as Matrix+import qualified Numeric.BLAS.Vector as Vector+import qualified Numeric.Netlib.Class as Class+import Numeric.BLAS.Scalar (RealOf)+import qualified Data.Array.Comfort.Storable as Array+import qualified Data.Array.Comfort.Shape as Shape+import qualified Test.QuickCheck as QC++type Matrix = Matrix.Matrix (Shape.ZeroBased Int) (Shape.ZeroBased Int)+type Real_ = RealOf Number_++maxDim :: Int+maxDim = 10++forMatrix ::+ (QC.Testable prop, QC.Arbitrary a, Class.Floating a, Show a) =>+ QC.Gen a -> (Matrix a -> prop) -> QC.Property+forMatrix genElem =+ QC.forAll+ (do height <- fmap shapeInt $ QC.choose (0,maxDim)+ width <- fmap shapeInt $ QC.choose (0,maxDim)+ genVector (height, width) genElem)++genIdentityTrans ::+ (Shape.C sh, Class.Floating a) =>+ sh -> QC.Gen (Matrix.Transposable sh sh a)+genIdentityTrans sh = do+ trans <- QC.arbitrary+ return $+ if trans+ then Matrix.transposed (Matrix.identity sh)+ else Matrix.nonTransposed (Matrix.identity sh)++transpose ::+ (Shape.C height, Eq height, Shape.C width, Class.Floating a) =>+ Matrix.Matrix height width a -> Matrix.Matrix width height a+transpose a =+ Matrix.multiplyTransposable+ (Matrix.transposed a)+ (Matrix.nonTransposed (Matrix.identity (Matrix.height a)))++test :: DocTest.T ()+test = do+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:129: "+{-# LINE 129 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 129 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.identity (Shape.ZeroBased 0) :: Matrix.Square (Shape.ZeroBased Int) Real_+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (ZeroBased {",WildCardChunk,LineChunk " 0},ZeroBased {",WildCardChunk,LineChunk " 0}) []"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:131: "+{-# LINE 131 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 131 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.identity (Shape.ZeroBased 3) :: Matrix.Square (Shape.ZeroBased Int) Real_+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (ZeroBased {",WildCardChunk,LineChunk " 3},ZeroBased {",WildCardChunk,LineChunk " 3}) [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:339: "+{-# LINE 339 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 339 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorLeft (Array.vectorFromList [3,1,4]) (Array.fromList (Shape.ZeroBased (3::Int), Shape.Range 'a' 'b') [0,1,0,0,1,0::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [4.0,3.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:342: "+{-# LINE 342 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 342 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forVector number_ $ \xs ->+ Matrix.multiplyVectorLeft xs (Matrix.identity (Array.shape xs)) == xs+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:353: "+{-# LINE 353 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 353 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorRight (Array.fromList (Shape.Range 'a' 'b', Shape.ZeroBased (3::Int)) [0,0,1,1,0,0]) (Array.vectorFromList [3,1,4::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [4.0,3.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:355: "+{-# LINE 355 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 355 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ Matrix.multiplyVectorRight (Array.fromList (Shape.Range 'a' 'b', Shape.ZeroBased (3::Int)) [2,7,1,8,2,8]) (Array.vectorFromList [3,1,4::Real_])+ )+ [ExpectedLine [LineChunk "StorableArray.fromList (Range {rangeFrom = 'a', rangeTo = 'b'}) [17.0,58.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:358: "+{-# LINE 358 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 358 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forVector number_ $ \xs ->+ Matrix.multiplyVectorRight (Matrix.identity (Array.shape xs)) xs == xs+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:363: "+{-# LINE 363 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 363 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \x ->+ Matrix.singleColumn (Matrix.multiplyVectorRight a x)+ ==+ Matrix.multiply a (Matrix.singleColumn x)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:371: "+{-# LINE 371 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 371 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (fst $ Array.shape a) number_) $ \x ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \y ->+ Vector.dot x (Matrix.multiplyVectorRight a y)+ ==+ Vector.dot (Matrix.multiplyVectorLeft x a) y+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:380: "+{-# LINE 380 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 380 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genVector (snd $ Array.shape a) number_) $ \x ->+ Matrix.multiplyVectorRight a x+ ==+ Matrix.multiplyVectorLeft x (transpose a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:458: "+{-# LINE 458 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 458 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.multiply+ (Array.fromList (shapeInt 2, shapeInt 2) [1000,100,10,1])+ (Array.fromList (shapeInt 2, shapeInt 3) [0..5::Real_])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [300.0,1400.0,2500.0,3.0,14.0,25.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:465: "+{-# LINE 465 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 465 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ Matrix.multiply (Matrix.identity (Matrix.height a)) a == a+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:469: "+{-# LINE 469 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 469 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ Matrix.multiply a (Matrix.identity (Matrix.width a)) == a+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:473: "+{-# LINE 473 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 473 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ forMatrix number_ $ \c ->+ QC.forAll (genVector (Matrix.width a, Matrix.height c) number_) $ \b ->+ Matrix.multiply a (Matrix.multiply b c)+ ==+ Matrix.multiply (Matrix.multiply a b) c+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:488: "+{-# LINE 488 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 488 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.height a)) $ \eye ->+ a == Matrix.multiplyTransposable eye (Matrix.nonTransposed a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:493: "+{-# LINE 493 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 493 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.width a)) $ \eye ->+ a == Matrix.multiplyTransposable (Matrix.nonTransposed a) eye+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:498: "+{-# LINE 498 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 498 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (genIdentityTrans (Matrix.width a)) $ \leftEye ->+ QC.forAll (genIdentityTrans (Matrix.height a)) $ \rightEye ->+ Matrix.multiplyTransposable leftEye (Matrix.transposed a)+ ==+ Matrix.multiplyTransposable (Matrix.transposed a) rightEye+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:506: "+{-# LINE 506 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 506 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + forMatrix number_ $ \a ->+ QC.forAll (QC.choose (0,maxDim)) $ \n ->+ QC.forAll (genVector (Matrix.width a, shapeInt n) number_) $ \b ->+ transpose (Matrix.multiply a b)+ ==+ Matrix.multiplyTransposable (Matrix.transposed b) (Matrix.transposed a)+ )+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:564: "+{-# LINE 564 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 564 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.kronecker+ (Array.fromList (shapeInt 2, shapeInt 2) [0,1,-1,0::Real_])+ (Array.fromList (shapeInt 2, shapeInt 3) [1..6])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [0.0,0.0,0.0,1.0,2.0,3.0,0.0,0.0,0.0,4.0,5.0,6.0,-1.0,-2.0,-3.0,0.0,0.0,0.0,-4.0,-5.0,-6.0,0.0,0.0,0.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:571: "+{-# LINE 571 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.example(+{-# LINE 571 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + Matrix.kronecker+ (Array.fromList (shapeInt 2, shapeInt 2) [1,2,3,4::Real_])+ (Array.fromList (shapeInt 2, shapeInt 3) [1,2,4,8,16,32])+ )+ [ExpectedLine [WildCardChunk,LineChunk " [1.0,2.0,4.0,2.0,4.0,8.0,8.0,16.0,32.0,16.0,32.0,64.0,3.0,6.0,12.0,4.0,8.0,16.0,24.0,48.0,96.0,32.0,64.0,128.0]"]]+ DocTest.printPrefix "Numeric.BLAS.Matrix.RowMajor:578: "+{-# LINE 578 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ DocTest.property(+{-# LINE 578 "src/Numeric/BLAS/Matrix/RowMajor.hs" #-}+ + QC.forAll (QC.choose (0,5)) $ \m ->+ QC.forAll (QC.choose (0,5)) $ \n ->+ Matrix.kronecker+ (Matrix.identity (shapeInt m))+ (Matrix.identity (shapeInt n))+ ==+ (Matrix.identity (shapeInt m, shapeInt n)+ :: Matrix.Square (ShapeInt, ShapeInt) Number_)+ )
test/Test/Float/Numeric/BLAS/Vector.hs view
@@ -11,6 +11,7 @@ import Test.Generator (genNumber) import Test.Slice (shapeInt) import Test.Utility (approx)+import qualified Numeric.BLAS.Matrix.RowMajor as Matrix import qualified Numeric.BLAS.Vector as Vector import qualified Numeric.Netlib.Class as Class import qualified Data.Array.Comfort.Shape as Shape@@ -102,215 +103,285 @@ test :: DocTest.T () test = do- DocTest.printPrefix "Numeric.BLAS.Vector:239: "-{-# LINE 239 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:211: "+{-# LINE 211 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 239 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 211 "src/Numeric/BLAS/Vector.hs" #-}+ QC.forAll number_ $ \x -> Vector.constant () x == Vector.singleton x+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:213: "+{-# LINE 213 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 213 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ QC.forAll number_ $ \x ->+ Vector.sum (Vector.constant (shapeInt n) x) == fromIntegral n * x+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:225: "+{-# LINE 225 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 225 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ Vector.sum (Vector.zero (shapeInt n)) == (0 :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:234: "+{-# LINE 234 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 234 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (0,1000)) $ \n ->+ Vector.sum (Vector.one (shapeInt n)) == (fromIntegral n :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:243: "+{-# LINE 243 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 243 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (fmap shapeInt $ QC.choose (1,1000)) $ \sh ->+ QC.forAll (QC.elements $ Shape.indices sh) $ \k ->+ Vector.sum (Vector.unit sh k) == (1 :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:265: "+{-# LINE 265 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 265 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> forVector number_ $ \zs -> Vector.toList ((xs +++ ys) +++ zs) == Vector.toList (xs +++ (ys +++ zs)) )- DocTest.printPrefix "Numeric.BLAS.Vector:248: "-{-# LINE 248 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:274: "+{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 248 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [] == (Vector.reverse $ Vector.autoFromList [] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:249: "-{-# LINE 249 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:275: "+{-# LINE 275 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 249 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 275 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [1] == (Vector.reverse $ Vector.autoFromList [1] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:250: "-{-# LINE 250 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:276: "+{-# LINE 276 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 250 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 276 "src/Numeric/BLAS/Vector.hs" #-} Vector.autoFromList [3,2,1] == (Vector.reverse $ Vector.autoFromList [1,2,3] :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:252: "-{-# LINE 252 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:278: "+{-# LINE 278 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 252 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 278 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> reverse (Vector.toList xs) == Vector.toList (Vector.reverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:253: "-{-# LINE 253 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:279: "+{-# LINE 279 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 253 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 279 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> xs == Vector.reverse (Vector.reverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:254: "-{-# LINE 254 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:280: "+{-# LINE 280 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 254 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 280 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> Vector.reverse (xs <> ys) == Vector.reverse ys <> Vector.reverse xs )- DocTest.printPrefix "Numeric.BLAS.Vector:269: "-{-# LINE 269 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:295: "+{-# LINE 295 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 269 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 295 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [] == Vector.cyclicReverse (cyclicVectorFromList []) )- DocTest.printPrefix "Numeric.BLAS.Vector:270: "-{-# LINE 270 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:296: "+{-# LINE 296 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 270 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 296 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1] == Vector.cyclicReverse (cyclicVectorFromList [1]) )- DocTest.printPrefix "Numeric.BLAS.Vector:271: "-{-# LINE 271 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:297: "+{-# LINE 297 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 271 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 297 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1,3,2] == Vector.cyclicReverse (cyclicVectorFromList [1,2,3]) )- DocTest.printPrefix "Numeric.BLAS.Vector:272: "-{-# LINE 272 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:298: "+{-# LINE 298 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 272 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 298 "src/Numeric/BLAS/Vector.hs" #-} cyclicVectorFromList [1,6,5,4,3,2] == Vector.cyclicReverse (cyclicVectorFromList [1,2,3,4,5,6]) )- DocTest.printPrefix "Numeric.BLAS.Vector:274: "-{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:300: "+{-# LINE 300 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 274 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 300 "src/Numeric/BLAS/Vector.hs" #-} forCyclicVector number_ $ \xs -> xs == Vector.cyclicReverse (Vector.cyclicReverse xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:291: "-{-# LINE 291 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:317: "+{-# LINE 317 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 291 "src/Numeric/BLAS/Vector.hs" #-}- QC.forAll (QC.choose (1,100)) $ \dim -> QC.forAll (QC.choose (0, dim-1)) $ \i -> QC.forAll (QC.choose (0, dim-1)) $ \j -> Vector.unit (Shape.ZeroBased dim) i == (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_)+{-# LINE 317 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (1,100)) $ \dim ->+ QC.forAll (QC.choose (0, dim-1)) $ \i ->+ QC.forAll (QC.choose (0, dim-1)) $ \j ->+ Vector.unit (Shape.ZeroBased dim) i+ ==+ (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_) )- DocTest.printPrefix "Numeric.BLAS.Vector:326: "-{-# LINE 326 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:344: "+{-# LINE 344 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 326 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 344 "src/Numeric/BLAS/Vector.hs" #-}+ + forVector2 number_ $ \xs ys ->+ Vector.dot xs ys+ ==+ Matrix.multiply (Matrix.singleRow xs) (Matrix.singleColumn ys) ! ((),())+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:351: "+{-# LINE 351 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 351 "src/Numeric/BLAS/Vector.hs" #-}+ + QC.forAll (QC.choose (1,100)) $ \dim ->+ QC.forAll (QC.choose (0, dim-1)) $ \i ->+ QC.forAll (QC.choose (0, dim-1)) $ \j ->+ Vector.dot+ (Vector.unit (shapeInt dim) i)+ (Vector.unit (shapeInt dim) j)+ ==+ (fromIntegral (fromEnum (i==j)) :: Number_)+ )+ DocTest.printPrefix "Numeric.BLAS.Vector:377: "+{-# LINE 377 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.property(+{-# LINE 377 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.inner xs ys == Vector.dot (Vector.conjugate xs) ys )- DocTest.printPrefix "Numeric.BLAS.Vector:379: "-{-# LINE 379 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:430: "+{-# LINE 430 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 379 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 430 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.sum xs == List.sum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:439: "-{-# LINE 439 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:490: "+{-# LINE 490 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 439 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 490 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.normInf xs == List.maximum (0 : List.map absolute (Vector.toList xs)) )- DocTest.printPrefix "Numeric.BLAS.Vector:463: "-{-# LINE 463 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:514: "+{-# LINE 514 "src/Numeric/BLAS/Vector.hs" #-} DocTest.example(-{-# LINE 463 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 514 "src/Numeric/BLAS/Vector.hs" #-} Vector.argAbsMaximum $ Vector.autoFromList [1:+2, 3:+4, 5, 6 :: Complex_] ) [ExpectedLine [LineChunk "(3,6.0 :+ 0.0)"]]- DocTest.printPrefix "Numeric.BLAS.Vector:466: "-{-# LINE 466 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:517: "+{-# LINE 517 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 466 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 517 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> isNonEmpty xs ==> let (xi,xm) = Vector.argAbsMaximum xs in xs!xi == xm )- DocTest.printPrefix "Numeric.BLAS.Vector:467: "-{-# LINE 467 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:518: "+{-# LINE 518 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 467 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 518 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> isNonEmpty xs ==> let (_xi,xm) = Vector.argAbsMaximum xs in List.all (\x -> absolute x <= absolute xm) $ Vector.toList xs )- DocTest.printPrefix "Numeric.BLAS.Vector:468: "-{-# LINE 468 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:519: "+{-# LINE 519 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 468 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 519 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> forVector number_ $ \ys -> isNonEmpty xs && isNonEmpty ys ==> let (_xi,xm) = Vector.argAbsMaximum xs; (_yi,ym) = Vector.argAbsMaximum ys; (zi,zm) = Vector.argAbsMaximum (xs+++ys) in case zi of Left _ -> xm==zm && absolute xm >= absolute ym; Right _ -> ym==zm && absolute xm < absolute ym )- DocTest.printPrefix "Numeric.BLAS.Vector:512: "-{-# LINE 512 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:563: "+{-# LINE 563 "src/Numeric/BLAS/Vector.hs" #-} DocTest.example(-{-# LINE 512 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 563 "src/Numeric/BLAS/Vector.hs" #-} Vector.argAbs1Maximum $ Vector.autoFromList [1:+2, 3:+4, 5, 6 :: Complex_] ) [ExpectedLine [LineChunk "(1,3.0 :+ 4.0)"]]- DocTest.printPrefix "Numeric.BLAS.Vector:515: "-{-# LINE 515 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:566: "+{-# LINE 566 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 515 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 566 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.argAbsMaximum xs == Vector.argAbs1Maximum xs )- DocTest.printPrefix "Numeric.BLAS.Vector:548: "-{-# LINE 548 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:599: "+{-# LINE 599 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 548 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 599 "src/Numeric/BLAS/Vector.hs" #-} QC.forAll (QC.choose (0,10)) $ \dim -> QC.forAll (genVector (shapeInt dim) (genNumber 3)) $ \xs -> approx 1e-2 (Vector.product xs) (List.product (Vector.toList (xs :: Vector Number_))) )- DocTest.printPrefix "Numeric.BLAS.Vector:558: "-{-# LINE 558 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:609: "+{-# LINE 609 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 558 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 609 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.minimum xs == List.minimum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:559: "-{-# LINE 559 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:610: "+{-# LINE 610 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 559 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 610 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.maximum xs == List.maximum (Vector.toList xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:560: "-{-# LINE 560 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:611: "+{-# LINE 611 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 560 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 611 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> - Vector.maximum xs == Vector.minimum (Vector.negate xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:576: "-{-# LINE 576 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:627: "+{-# LINE 627 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 576 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 627 "src/Numeric/BLAS/Vector.hs" #-} forVector real_ $ \xs -> isNonEmpty xs ==> Vector.limits xs == Array.limits xs )- DocTest.printPrefix "Numeric.BLAS.Vector:606: "-{-# LINE 606 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:657: "+{-# LINE 657 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 606 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 657 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.negate xs == Vector.scale minusOne xs )- DocTest.printPrefix "Numeric.BLAS.Vector:607: "-{-# LINE 607 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:658: "+{-# LINE 658 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 607 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 658 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> Vector.scale 2 xs == xs |+| xs )- DocTest.printPrefix "Numeric.BLAS.Vector:676: "-{-# LINE 676 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:727: "+{-# LINE 727 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 676 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 727 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> xs |+| ys == ys |+| xs )- DocTest.printPrefix "Numeric.BLAS.Vector:677: "-{-# LINE 677 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:728: "+{-# LINE 728 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 677 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 728 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> xs == xs |-| ys |+| ys )- DocTest.printPrefix "Numeric.BLAS.Vector:707: "-{-# LINE 707 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:758: "+{-# LINE 758 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 707 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 758 "src/Numeric/BLAS/Vector.hs" #-} forVector number_ $ \xs -> xs == Vector.negate (Vector.negate xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:720: "-{-# LINE 720 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:771: "+{-# LINE 771 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 720 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 771 "src/Numeric/BLAS/Vector.hs" #-} QC.forAll (genNumber maxElem) $ \d -> forVector number_ $ \xs -> xs == Vector.raise (-d) (Vector.raise d xs) )- DocTest.printPrefix "Numeric.BLAS.Vector:737: "-{-# LINE 737 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:788: "+{-# LINE 788 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 737 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 788 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.mul xs ys == Vector.mul ys xs )- DocTest.printPrefix "Numeric.BLAS.Vector:745: "-{-# LINE 745 "src/Numeric/BLAS/Vector.hs" #-}+ DocTest.printPrefix "Numeric.BLAS.Vector:796: "+{-# LINE 796 "src/Numeric/BLAS/Vector.hs" #-} DocTest.property(-{-# LINE 745 "src/Numeric/BLAS/Vector.hs" #-}+{-# LINE 796 "src/Numeric/BLAS/Vector.hs" #-} forVector2 number_ $ \xs ys -> Vector.mulConj xs ys == Vector.mul (Vector.conjugate xs) ys )