on master help sign in
Main with mmm benchmark
commitc0b17cc07d202edff5a8da7182b50fd8bd777e00 authorArmando Santos <armandoifsantos@gmail.com> dateSun 29 Dec 2019, 17:10 (7 years ago) parentb3fbc73
1 file changed+25−10
app/Main.hs+25−10
app/Main.hs+25−10
@@ -1,3 +1,4 @@
1+{-# LANGUAGE BangPatterns #-}
12{-# LANGUAGE FlexibleContexts #-}
23{-# LANGUAGE TypeApplications #-}
34{-# LANGUAGE DataKinds #-}
@@ -9,6 +10,7 @@ import Utils
910import Dist
1011import GHC.TypeLits
1112import Data.Coerce
13+import System.CPUTime
1214
1315-- Monty Hall Problem
1416data Outcome = Win | Lose
@@ -56,16 +58,29 @@ grass_wet = row [0,1] `comp` kp1 @Double @2 @4
5658
5759rainning = row [0,1] `comp` kp2 @Double @2 @2 `comp` kp2 @Double @2 @4
5860
61+-- Random Matrix multiplication
62+
63+a :: Matrix Double 1000 1000
64+a = identity
65+
66+b :: Matrix Double 1000 1000
67+b = identity
68+
5969main :: IO ()
6070main = do
61− putStrLn "Monty Hall Problem solution:"
62− prettyPrint (p1 @Double @1 `comp` secondChoice `comp` firstChoice)
63− putStrLn "\n Sum of dices probability:"
64− prettyPrint (sumSSM `comp` khatri die die)
65− putStrLn "\n Checking that the last result is indeed a distribution: "
66− prettyPrint (bang `comp` sumSSM `comp` khatri die die)
67− putStrLn "\n Probability of grass being wet:"
68− prettyPrint (grass_wet `comp` state)
69− putStrLn "\n Probability of rain:"
70− prettyPrint (rainning `comp` state)
71+ -- putStrLn "Monty Hall Problem solution:"
72+ -- prettyPrint (p1 @Double @1 `comp` secondChoice `comp` firstChoice)
73+ -- putStrLn "\n Sum of dices probability:"
74+ -- prettyPrint (sumSSM `comp` khatri die die)
75+ -- putStrLn "\n Checking that the last result is indeed a distribution: "
76+ -- prettyPrint (bang `comp` sumSSM `comp` khatri die die)
77+ -- putStrLn "\n Probability of grass being wet:"
78+ -- prettyPrint (grass_wet `comp` state)
79+ -- putStrLn "\n Probability of rain:"
80+ -- prettyPrint (rainning `comp` state)
81+
82+ start <- getCPUTime
83+ let !r = a `comp` b
84+ end <- getCPUTime
85+ print (end - start)
7186