@@ -720,6 +720,154 @@ func TestConstantVector_Comparison1(t *testing.T) {
720720 kv1 .Comparison (input , symbolic .SenseEqual )
721721}
722722
723+ /*
724+ TestConstantVector_Comparison2
725+ Description:
726+
727+ Verifies that the Comparison method produces a proper
728+ constraint when the left-hand side is a KVector and
729+ the right-hand side is a float64.
730+ The resulting compmarison should have a right hand
731+ side which is a KVector.
732+ */
733+ func TestConstantVector_Comparison2 (t * testing.T ) {
734+ // Constants
735+ kv1 := symbolic .VecDenseToKVector (symbolic .OnesVector (3 ))
736+ var input float64 = 3.14
737+
738+ // Test
739+ constraint := kv1 .Comparison (input , symbolic .SenseEqual )
740+
741+ // Verify that the left hand side is of type KVector
742+ if _ , tf := constraint .Left ().(symbolic.KVector ); ! tf {
743+ t .Errorf (
744+ "Expected constraint.LeftHandSide to be of type KVector; received %v" ,
745+ constraint .Left (),
746+ )
747+ }
748+
749+ // Verify that the right hand side is of type KVector
750+ if _ , tf := constraint .Right ().(symbolic.KVector ); ! tf {
751+ t .Errorf (
752+ "Expected constraint.RightHandSide to be of type KVector; received %v" ,
753+ constraint .Right (),
754+ )
755+ }
756+
757+ // Verify that the sense of the constraint is Equal
758+ if constraint .ConstrSense () != symbolic .SenseEqual {
759+ t .Errorf (
760+ "Expected constraint.Sense to be Equal; received %v" ,
761+ constraint .ConstrSense (),
762+ )
763+ }
764+ }
765+
766+ /*
767+ TestConstantVector_Comparison3
768+ Description:
769+
770+ Verifies that the Comparison method produces a proper
771+ constraint when the left-hand side is a KVector and
772+ the right-hand side is a int.
773+ The resulting compmarison should have a right hand
774+ side which is a KVector.
775+ */
776+ func TestConstantVector_Comparison3 (t * testing.T ) {
777+ // Constants
778+ N := 3
779+ kv1 := symbolic .VecDenseToKVector (symbolic .OnesVector (N ))
780+ var input int = 3
781+
782+ // Test
783+ constraint := kv1 .Comparison (input , symbolic .SenseEqual )
784+
785+ // Verify that the left hand side is of type KVector
786+ if _ , tf := constraint .Left ().(symbolic.KVector ); ! tf {
787+ t .Errorf (
788+ "Expected constraint.LeftHandSide to be of type KVector; received %v" ,
789+ constraint .Left (),
790+ )
791+ }
792+
793+ // Verify that the right hand side is of type KVector
794+ kv , tf := constraint .Right ().(symbolic.KVector )
795+ if ! tf {
796+ t .Errorf (
797+ "Expected constraint.RightHandSide to be of type KVector; received %v" ,
798+ constraint .Right (),
799+ )
800+ }
801+
802+ // Verify that the length of the right hand side is N
803+ if kv .Len () != N {
804+ t .Errorf (
805+ "Expected constraint.RightHandSide to have length %d; received %d" ,
806+ N , kv .Len (),
807+ )
808+ }
809+
810+ // Verify that the sense of the constraint is Equal
811+ if constraint .ConstrSense () != symbolic .SenseEqual {
812+ t .Errorf (
813+ "Expected constraint.Sense to be Equal; received %v" ,
814+ constraint .ConstrSense (),
815+ )
816+ }
817+ }
818+
819+ /*
820+ TestConstantVector_Comparison4
821+ Description:
822+
823+ Verifies that the Comparison method produces a proper
824+ constraint when the left-hand side is a KVector and
825+ the right-hand side is a symbolic.K.
826+ The resulting compmarison should have a right hand
827+ side which is a KVector.
828+ */
829+ func TestConstantVector_Comparison4 (t * testing.T ) {
830+ // Constants
831+ N := 3
832+ kv1 := symbolic .VecDenseToKVector (symbolic .OnesVector (N ))
833+ var input symbolic.K = symbolic .K (3.0 )
834+
835+ // Test
836+ constraint := kv1 .Comparison (input , symbolic .SenseEqual )
837+
838+ // Verify that the left hand side is of type KVector
839+ if _ , tf := constraint .Left ().(symbolic.KVector ); ! tf {
840+ t .Errorf (
841+ "Expected constraint.LeftHandSide to be of type KVector; received %v" ,
842+ constraint .Left (),
843+ )
844+ }
845+
846+ // Verify that the right hand side is of type KVector and has length N
847+ kv , tf := constraint .Right ().(symbolic.KVector )
848+ if ! tf {
849+ t .Errorf (
850+ "Expected constraint.RightHandSide to be of type KVector; received %v" ,
851+ constraint .Right (),
852+ )
853+ }
854+
855+ if kv .Len () != N {
856+ t .Errorf (
857+ "Expected constraint.RightHandSide to have length %d; received %d" ,
858+ N , kv .Len (),
859+ )
860+ }
861+
862+ // Verify that the sense of the constraint is Equal
863+ if constraint .ConstrSense () != symbolic .SenseEqual {
864+ t .Errorf (
865+ "Expected constraint.Sense to be Equal; received %v" ,
866+ constraint .ConstrSense (),
867+ )
868+ }
869+ }
870+
723871/*
724872TestConstantVector_Multiply1
725873Description:
0 commit comments