@@ -3,6 +3,7 @@ package optim_test
3
3
import (
4
4
"fmt"
5
5
"github.com/MatProGo-dev/MatProInterface.go/optim"
6
+ "github.com/MatProGo-dev/SymbolicMath.go/symbolic"
6
7
"gonum.org/v1/gonum/mat"
7
8
"strings"
8
9
"testing"
@@ -14,6 +15,23 @@ Description:
14
15
Tests the new type KVectorTranspose which represents a constant vector.
15
16
*/
16
17
18
+ /*
19
+ TestKVectorTranspose_Check1
20
+ Description:
21
+
22
+ Tests that the Check() method returns nil.
23
+ */
24
+ func TestKVectorTranspose_Check1 (t * testing.T ) {
25
+ // Create a KVectorTranspose
26
+ desLength := 4
27
+ var vec1 = optim .KVectorTranspose (optim .OnesVector (desLength ))
28
+
29
+ // Check
30
+ if vec1 .Check () != nil {
31
+ t .Errorf ("The Check() method should return nil; received %v" , vec1 .Check ())
32
+ }
33
+ }
34
+
17
35
/*
18
36
TestKVectorTranspose_At1
19
37
Description:
@@ -1187,3 +1205,28 @@ func TestKVectorTranspose_Transpose1(t *testing.T) {
1187
1205
)
1188
1206
}
1189
1207
}
1208
+
1209
+ /*
1210
+ TestKVectorTranspose_ToSymbolic1
1211
+ Description:
1212
+
1213
+ Tests that the ToSymbolic function works as expected.
1214
+ Expects for the error to be nil and for the result to be a symbolic.KMatrix
1215
+ */
1216
+ func TestKVectorTranspose_ToSymbolic1 (t * testing.T ) {
1217
+ // Constants
1218
+ desLength := 10
1219
+
1220
+ // Algorithm
1221
+ vec1 := optim .KVectorTranspose (optim .OnesVector (desLength ))
1222
+ symVec , err := vec1 .ToSymbolic ()
1223
+ if err != nil {
1224
+ t .Errorf ("Unexpected error in ToSymbolic: %v" , err )
1225
+ }
1226
+
1227
+ // Check type
1228
+ _ , ok := symVec .(symbolic.KMatrix )
1229
+ if ! ok {
1230
+ t .Errorf ("Expected symVec to be of type symbolic.KVector; received %T" , symVec )
1231
+ }
1232
+ }
0 commit comments