@@ -3,6 +3,7 @@ package optim_test
33import (
44 "fmt"
55 "github.com/MatProGo-dev/MatProInterface.go/optim"
6+ "github.com/MatProGo-dev/SymbolicMath.go/symbolic"
67 "gonum.org/v1/gonum/mat"
78 "strings"
89 "testing"
@@ -14,6 +15,23 @@ Description:
1415 Tests the new type KVectorTranspose which represents a constant vector.
1516*/
1617
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+
1735/*
1836TestKVectorTranspose_At1
1937Description:
@@ -1187,3 +1205,28 @@ func TestKVectorTranspose_Transpose1(t *testing.T) {
11871205 )
11881206 }
11891207}
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