@@ -1,15 +1,15 @@
1module Test.LinearAlgebra.Matrix (testMatrix) where
1module Test.LinearAlgebra.Matrix (testMatrix) where
3import Prelude
3import Prelude
4−import Control.Monad.Eff (Eff)
4+import Effect (Effect)
5−import Control.Monad.Eff.Console (log, CONSOLE)
5+import Effect.Class.Console (log)
6import Data.Maybe (Maybe(..), fromMaybe, isJust, isNothing)
6import Data.Maybe (Maybe(..), fromMaybe, isJust, isNothing)
7−import Test.Assert (assert, ASSERT)
7+import Test.Assert (assert)
9import LinearAlgebra.Matrix as M
9import LinearAlgebra.Matrix as M
12−testMatrix :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
12+testMatrix :: Effect Unit
13testMatrix = do
13testMatrix = do
14 log "\n# Test Matrix"
14 log "\n# Test Matrix"
15 testCreate
15 testCreate
@@ -28,7 +28,7 @@ testMatrix = do
28 testIdentity
28 testIdentity
31−testCreate :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
31+testCreate :: Effect Unit
32testCreate = do
32testCreate = do
33 log " * Create matrix"
33 log " * Create matrix"
34 let z1 = M.zeros 5 4
34 let z1 = M.zeros 5 4
@@ -36,49 +36,49 @@ testCreate = do
36 assert $ M.ncols z1 == 4
36 assert $ M.ncols z1 == 4
39−testFromArray :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
39+testFromArray :: Effect Unit
40testFromArray = do
40testFromArray = do
41 log " * From Array"
41 log " * From Array"
42 assert $ isNothing (M.fromArray 2 3 [1.0])
42 assert $ isNothing (M.fromArray 2 3 [1.0])
43 assert $ isJust (M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
43 assert $ isJust (M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
46−testGetRow :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
46+testGetRow :: Effect Unit
47testGetRow = do
47testGetRow = do
48 log " * Get specific row"
48 log " * Get specific row"
49 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
49 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
50 assert $ M.row 0 mat == [1.0, 2.0, 3.0]
50 assert $ M.row 0 mat == [1.0, 2.0, 3.0]
53−testGetCol :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
53+testGetCol :: Effect Unit
54testGetCol = do
54testGetCol = do
55 log " * Get specific column"
55 log " * Get specific column"
56 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
56 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
57 assert $ M.column 1 mat == [2.0, 5.0]
57 assert $ M.column 1 mat == [2.0, 5.0]
60−testGetValue :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
60+testGetValue :: Effect Unit
61testGetValue = do
61testGetValue = do
62 log " * Get specific value"
62 log " * Get specific value"
63 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
63 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
64 assert $ M.element 1 2 mat == Just 6.0
64 assert $ M.element 1 2 mat == Just 6.0
67−testRows :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
67+testRows :: Effect Unit
68testRows = do
68testRows = do
69 log " * Get list of rows"
69 log " * Get list of rows"
70 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
70 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
71 assert $ M.rows mat == [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]
71 assert $ M.rows mat == [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]
74−testColumns :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
74+testColumns :: Effect Unit
75testColumns = do
75testColumns = do
76 log " * Get list of columns"
76 log " * Get list of columns"
77 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
77 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
78 assert $ M.columns mat == [[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]]
78 assert $ M.columns mat == [[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]]
81−testSliceColumns :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
81+testSliceColumns :: Effect Unit
82testSliceColumns = do
82testSliceColumns = do
83 log " * Slice columns"
83 log " * Slice columns"
84 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
84 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
@@ -86,7 +86,7 @@ testSliceColumns = do
86 assert $ M.sliceCols 0 1 mat == expected
86 assert $ M.sliceCols 0 1 mat == expected
89−testSliceRows :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
89+testSliceRows :: Effect Unit
90testSliceRows = do
90testSliceRows = do
91 log " * Slice rows"
91 log " * Slice rows"
92 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 3 2 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
92 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 3 2 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
@@ -94,7 +94,7 @@ testSliceRows = do
94 assert $ M.sliceRows 0 1 mat == expected
94 assert $ M.sliceRows 0 1 mat == expected
97−testInsertColumn :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
97+testInsertColumn :: Effect Unit
98testInsertColumn = do
98testInsertColumn = do
99 log " * Insert column"
99 log " * Insert column"
100 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 2 [1.0, 2.0, 4.0, 5.0]
100 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 2 [1.0, 2.0, 4.0, 5.0]
@@ -104,7 +104,7 @@ testInsertColumn = do
104 assert $ M.insertCol 0 [3.0, 6.0] mat == expected2
104 assert $ M.insertCol 0 [3.0, 6.0] mat == expected2
107−testAdd :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
107+testAdd :: Effect Unit
108testAdd = do
108testAdd = do
109 log " * Multiply matrices"
109 log " * Multiply matrices"
110 let m1 = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
110 let m1 = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
@@ -112,7 +112,7 @@ testAdd = do
112 assert $ M.add m1 m1 == expected
112 assert $ M.add m1 m1 == expected
115−testMultiply :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
115+testMultiply :: Effect Unit
116testMultiply = do
116testMultiply = do
117 log " * Multiply matrices"
117 log " * Multiply matrices"
118 let m1 = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
118 let m1 = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
@@ -121,7 +121,7 @@ testMultiply = do
121 assert $ M.multiply m1 m2 == expected
121 assert $ M.multiply m1 m2 == expected
124−testTranspose :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
124+testTranspose :: Effect Unit
125testTranspose = do
125testTranspose = do
126 log " * Transpose matrix"
126 log " * Transpose matrix"
127 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
127 let mat = fromMaybe (M.zeros 1 1) $ M.fromArray 2 3 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
@@ -129,7 +129,7 @@ testTranspose = do
129 assert $ M.transpose mat == expected
129 assert $ M.transpose mat == expected
132−testIdentity :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT | eff) Unit
132+testIdentity :: Effect Unit
133testIdentity = do
133testIdentity = do
134 log " * Identity matrix"
134 log " * Identity matrix"
135 let expected = fromMaybe (M.zeros 1 1) $ M.fromArray 3 3 [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
135 let expected = fromMaybe (M.zeros 1 1) $ M.fromArray 3 3 [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]