@@ -353,6 +353,86 @@ func TestKVectorTranspose_Comparison5(t *testing.T) {
353
353
}
354
354
}
355
355
356
+ /*
357
+ TestKVectorTranspose_LessEq1
358
+ Description:
359
+
360
+ This function tests that the LessEq() method is properly working for KVector inputs.
361
+ */
362
+ func TestKVectorTranspose_LessEq1 (t * testing.T ) {
363
+ // Constants
364
+ desLength := 10
365
+ var vec1 = optim .KVectorTranspose (optim .OnesVector (desLength ))
366
+ var vec2 = optim .KVector (optim .ZerosVector (desLength ))
367
+
368
+ // Create Constraint
369
+ _ , err := vec1 .LessEq (vec2 )
370
+ if ! strings .Contains (
371
+ err .Error (),
372
+ fmt .Sprintf (
373
+ "Cannot compare KVectorTranspose with a normal vector %T; Try transposing one or the other!" ,
374
+ vec2 ,
375
+ ),
376
+ ) {
377
+ t .Errorf ("There was an unexpected error when doing improper LessEq: %v" , err )
378
+ }
379
+ }
380
+
381
+ /*
382
+ TestKVectorTranspose_GreaterEq1
383
+ Description:
384
+
385
+ This function tests that the GreaterEq() method is properly working for
386
+ KVectorTranspose inputs of improper length.
387
+ */
388
+ func TestKVectorTranspose_GreaterEq1 (t * testing.T ) {
389
+ // Constants
390
+ desLength := 10
391
+ var vec1 = optim .KVectorTranspose (optim .OnesVector (desLength ))
392
+ var vec2 = optim .KVectorTranspose (optim .ZerosVector (desLength - 1 ))
393
+
394
+ // Create Constraint
395
+ _ , err := vec1 .GreaterEq (vec2 )
396
+ if ! strings .Contains (
397
+ err .Error (),
398
+ fmt .Sprintf (
399
+ "The left hand side's dimension (%v) and the left hand side's dimension (%v) do not match!" ,
400
+ vec1 .Len (),
401
+ vec2 .Len (),
402
+ ),
403
+ ) {
404
+ t .Errorf ("There was an unexpected error computing GreaterEq(): %v" , err )
405
+ }
406
+ }
407
+
408
+ /*
409
+ TestKVectorTranspose_Eq1
410
+ Description:
411
+
412
+ This function tests that the Eq() method is properly working for
413
+ when given an unexpected type input.
414
+ */
415
+ func TestKVectorTranspose_Eq1 (t * testing.T ) {
416
+ // Constants
417
+ desLength := 10
418
+ var vec1 = optim .KVectorTranspose (optim .OnesVector (desLength ))
419
+ b2 := false
420
+
421
+ // Create Constraint
422
+ _ , err := vec1 .Eq (b2 )
423
+ if ! strings .Contains (
424
+ err .Error (),
425
+ fmt .Sprintf (
426
+ "The input to KVectorTranspose's '%v' comparison (%v) has unexpected type: %T" ,
427
+ optim .SenseEqual ,
428
+ b2 ,
429
+ b2 ,
430
+ ),
431
+ ) {
432
+ t .Errorf ("There was an unexpected error computing Eq(): %v" , err )
433
+ }
434
+ }
435
+
356
436
/*
357
437
TestKVectorTranspose_Plus1
358
438
Description:
@@ -863,3 +943,51 @@ func TestKVectorTranspose_Mult1(t *testing.T) {
863
943
}
864
944
}
865
945
}
946
+
947
+ /*
948
+ TestKVectorTranspose_Multiply1
949
+ Description:
950
+
951
+ Tests that the scalar multiplication function works as expected.
952
+ */
953
+ func TestKVectorTranspose_Multiply1 (t * testing.T ) {
954
+ // Constants
955
+ desLength := 10
956
+ var vec1 = optim .KVectorTranspose (optim .OnesVector (desLength ))
957
+
958
+ // Algorithm
959
+ _ , err := vec1 .Multiply (30.0 )
960
+ if ! strings .Contains (
961
+ err .Error (),
962
+ fmt .Sprintf ("The Multiply() method for KVectorTranspose has not been implemented yet!" ),
963
+ ) {
964
+ t .Errorf ("There was an unexpected error when computing multiply: %v" , err )
965
+ }
966
+ }
967
+
968
+ /*
969
+ TestKVectorTranspose_Transpose1
970
+ Description:
971
+
972
+ Tests that the transpose function works as expected.
973
+ */
974
+ func TestKVectorTranspose_Transpose1 (t * testing.T ) {
975
+ // Constants
976
+ desLength := 10
977
+ var vec1 = optim .KVectorTranspose (optim .OnesVector (desLength ))
978
+
979
+ // Algorithm
980
+ vec1T := vec1 .Transpose ()
981
+ _ , ok := vec1T .(optim.KVector )
982
+ if ! ok {
983
+ t .Errorf ("The transposed KVectorTranspose is of type %T; not KVector" , vec1T )
984
+ }
985
+
986
+ if vec1 .Len () != vec1T .Len () {
987
+ t .Errorf (
988
+ "The length of vec1 is %v, but the transposed vector has length %v. They should be the same!" ,
989
+ vec1 .Len (),
990
+ vec1T .Len (),
991
+ )
992
+ }
993
+ }
0 commit comments