-- Do not edit! Automatically created with doctest-extract from src/Numeric/BLAS/Matrix/TransposablePrivate.hs {-# LINE 36 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} {-# OPTIONS_GHC -XTypeOperators #-} module Test.ComplexDouble.Numeric.BLAS.Matrix.TransposablePrivate where import qualified Test.DocTest.Driver as DocTest {-# LINE 38 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} import Test.ComplexDouble.Numeric.BLAS.Matrix.RowMajor (forMatrix) import Test.ComplexDouble.Numeric.BLAS.Vector (genVector, number_) import Test.Slice (ShapeInt, shapeInt) import qualified Numeric.BLAS.Matrix.Transposable as Transp import qualified Numeric.BLAS.Matrix.RowMajor.Square as Square 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.Matrix.Transposable (Transposable, transposed, nonTransposed) -- import Numeric.BLAS.Vector (Vector) -- import Numeric.Netlib.Modifier (Conjugation(NonConjugated, Conjugated)) import qualified Numeric.Netlib.Modifier as Modi import qualified Data.Array.Comfort.Boxed as BoxedArray import qualified Data.Array.Comfort.Storable as Array import qualified Data.Array.Comfort.Shape as Shape import Data.Tuple.HT (swap) import qualified Test.QuickCheck as QC import Test.QuickCheck ((===)) maxDim :: Int maxDim = 10 genIdentityTrans :: (Shape.C sh, Class.Floating a) => sh -> QC.Gen (Transp.Transposable sh sh a) genIdentityTrans sh = do trans <- QC.arbitrary return $ case trans of Modi.Transposed -> transposed (Matrix.identity sh) Modi.NonTransposed -> nonTransposed (Matrix.identity sh) forTransposable :: (QC.Testable prop, QC.Arbitrary a, Class.Floating a, Show a) => QC.Gen a -> (Transposable ShapeInt ShapeInt a -> prop) -> QC.Property forTransposable genElem prop = forMatrix genElem $ \a trans -> prop $ case trans of Modi.Transposed -> transposed a Modi.NonTransposed -> nonTransposed a genTransposable :: (Shape.C height, Shape.C width, Class.Floating a) => (height,width) -> QC.Gen a -> QC.Gen (Transposable height width a) genTransposable shape genElem = QC.oneof [fmap nonTransposed $ genVector shape genElem, fmap transposed $ genVector (swap shape) genElem] test :: DocTest.T () test = do DocTest.printPrefix "Numeric.BLAS.Matrix.TransposablePrivate:172: " {-# LINE 172 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} DocTest.property( {-# LINE 172 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} forMatrix number_ $ \a -> QC.forAll (genIdentityTrans (Matrix.height a)) $ \eye -> a === Transp.multiply eye (nonTransposed a) ) DocTest.printPrefix "Numeric.BLAS.Matrix.TransposablePrivate:177: " {-# LINE 177 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} DocTest.property( {-# LINE 177 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} forMatrix number_ $ \a -> QC.forAll (genIdentityTrans (Matrix.width a)) $ \eye -> a === Transp.multiply (nonTransposed a) eye ) DocTest.printPrefix "Numeric.BLAS.Matrix.TransposablePrivate:182: " {-# LINE 182 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} DocTest.property( {-# LINE 182 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} forMatrix number_ $ \a -> QC.forAll (genIdentityTrans (Matrix.width a)) $ \leftEye -> QC.forAll (genIdentityTrans (Matrix.height a)) $ \rightEye -> Transp.multiply leftEye (transposed a) === Transp.multiply (transposed a) rightEye ) DocTest.printPrefix "Numeric.BLAS.Matrix.TransposablePrivate:190: " {-# LINE 190 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} DocTest.property( {-# LINE 190 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} forMatrix number_ $ \a -> QC.forAll (QC.choose (0,maxDim)) $ \n -> QC.forAll (genVector (Matrix.width a, shapeInt n) number_) $ \b -> Matrix.transpose (Matrix.multiply a b) === Transp.multiply (transposed b) (transposed a) ) DocTest.printPrefix "Numeric.BLAS.Matrix.TransposablePrivate:252: " {-# LINE 252 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} DocTest.property( {-# LINE 252 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} forTransposable number_ $ \a -> QC.forAll (genTransposable (Transp.shape a) number_) $ \b -> Array.toBoxed (Transp.dotRowwise a b) === BoxedArray.zipWith Vector.dot (Matrix.toRowArray $ Transp.toMatrix a) (Matrix.toRowArray $ Transp.toMatrix b) ) DocTest.printPrefix "Numeric.BLAS.Matrix.TransposablePrivate:263: " {-# LINE 263 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} DocTest.property( {-# LINE 263 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} forTransposable number_ $ \a -> QC.forAll (genTransposable (Transp.shape a) number_) $ \b -> Square.takeDiagonal (Array.mapShape (Shape.Square . fst) (Transp.multiply a (Transp.transpose b))) === Transp.dotRowwise a b ) DocTest.printPrefix "Numeric.BLAS.Matrix.TransposablePrivate:274: " {-# LINE 274 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} DocTest.property( {-# LINE 274 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} forMatrix number_ $ \a -> QC.forAll (genVector (Array.shape a) number_) $ \b -> Vector.dot a b === Vector.sum (Transp.dotRowwise (transposed a) (transposed b)) ) DocTest.printPrefix "Numeric.BLAS.Matrix.TransposablePrivate:283: " {-# LINE 283 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} DocTest.property( {-# LINE 283 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} forTransposable number_ $ \a -> QC.forAll (genTransposable (Transp.shape a) number_) $ \b -> Transp.dotRowwise a b === Transp.dotRowwise b a ) DocTest.printPrefix "Numeric.BLAS.Matrix.TransposablePrivate:308: " {-# LINE 308 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} DocTest.property( {-# LINE 308 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} forTransposable number_ $ \a -> QC.forAll (genTransposable (Transp.shape a) number_) $ \b -> Transp.innerRowwise a b === Transp.dotRowwise (Transp.conjugate a) b ) DocTest.printPrefix "Numeric.BLAS.Matrix.TransposablePrivate:317: " {-# LINE 317 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} DocTest.property( {-# LINE 317 "src/Numeric/BLAS/Matrix/TransposablePrivate.hs" #-} forMatrix number_ $ \a -> QC.forAll (genVector (Array.shape a) number_) $ \b -> Vector.inner a b === Vector.sum (Transp.innerRowwise (transposed a) (transposed b)) )