Subversion Repositories gelsvn

Rev

Rev 306 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 306 Rev 417
Line 27... Line 27...
27
namespace
27
namespace
28
{
28
{
29
  // To find a pseudo-random number in the interval [0,1[
29
  // To find a pseudo-random number in the interval [0,1[
30
  double my_random()
30
  double my_random()
31
  {
31
  {
32
    return rand()/(static_cast<double>(RAND_MAX) + 1.0);
32
    return gel_rand()/(static_cast<double>(GEL_RAND_MAX) + 1.0);
33
  }
33
  }
34
}
34
}
35
 
35
 
36
/* This is a non-exhaustive test program for CGLA */
36
/* This is a non-exhaustive test program for CGLA */
37
int main()
37
int main()
38
{
38
{
39
  int success = 0;
39
  int success = 0;
40
  Timer t;
40
  Timer t;
41
 
41
 
42
  srand(time(0));
42
  gel_srand(time(0));
43
 
43
 
44
  t.start();
44
  t.start();
45
 
45
 
46
  ////////////////////////////////////////////////
46
  ////////////////////////////////////////////////
47
  //                V e c 2 d
47
  //                V e c 2 d
48
  ////////////////////////////////////////////////
48
  ////////////////////////////////////////////////
49
 
49
 
50
  // Constructors
50
  // Constructors
51
 
51
 
52
  {
52
  {
-
 
53
  // TODO: The following should be done for all constructors in the remainder of the file
-
 
54
#ifndef NDEBUG
53
    Vec2d x1;
55
    Vec2d x1;
54
    success += CGLA::isnan(x1[0]) && CGLA::isnan(x1[1]);
56
    success += CGLA::isnan(x1[0]) && CGLA::isnan(x1[1]);
-
 
57
#else
-
 
58
    success += 1;
-
 
59
#endif
55
 
60
 
56
    double xi1 = my_random(), xi2 = my_random();
61
    double xi1 = my_random(), xi2 = my_random();
57
    Vec2d x2(xi1, xi2);
62
    Vec2d x2(xi1, xi2);
58
    success += x2[0] == xi1 && x2[1] == xi2;
63
    success += x2[0] == xi1 && x2[1] == xi2;
59
 
64
 
60
    int xii1 = rand(), xii2 = rand();
65
    int xii1 = gel_rand(), xii2 = gel_rand();
61
    Vec2i i1(xii1, xii2);
66
    Vec2i i1(xii1, xii2);
62
    Vec2d x3(i1);
67
    Vec2d x3(i1);
63
    success += x3[0] == xii1 && x3[1] == xii2;
68
    success += x3[0] == xii1 && x3[1] == xii2;
64
 
69
 
65
    float xiii1 = my_random(), xiii2 = my_random();
70
    float xiii1 = my_random(), xiii2 = my_random();
Line 92... Line 97...
92
    success += x1.get() == &x1[0];
97
    success += x1.get() == &x1[0];
93
 
98
 
94
    double temp = BIG;
99
    double temp = BIG;
95
    for(unsigned int i = 0; i < x1.get_dim(); ++i)
100
    for(unsigned int i = 0; i < x1.get_dim(); ++i)
96
      if(x1[i] < temp)
101
      if(x1[i] < temp)
97
	temp = x1[i];
102
	      temp = x1[i];
98
    success += temp == x1.min_coord();
103
    success += temp == x1.min_coord();
99
 
104
 
100
    temp = -BIG;
105
    temp = -BIG;
101
    for(unsigned int i = 0; i < x1.get_dim(); ++i)
106
    for(unsigned int i = 0; i < x1.get_dim(); ++i)
102
      if(x1[i] > temp)
107
      if(x1[i] > temp)
103
	temp = x1[i];
108
	      temp = x1[i];
104
    success += temp == x1.max_coord();
109
    success += temp == x1.max_coord();
105
  }
110
  }
106
  if(success != 5)
111
  if(success != 5)
107
  {
112
  {
108
    cout << "Failure in test of Vec2d Data manipulation";
113
    cout << "Failure in test of Vec2d Data manipulation";
Line 260... Line 265...
260
    success += x3[0] == xi1*xi4 && x3[1] == xi2*xi4;
265
    success += x3[0] == xi1*xi4 && x3[1] == xi2*xi4;
261
    
266
    
262
    x3 = x1*xi4;
267
    x3 = x1*xi4;
263
    success += x3[0] == xi1*xi4 && x3[1] == xi2*xi4;
268
    success += x3[0] == xi1*xi4 && x3[1] == xi2*xi4;
264
 
269
 
265
    int xi5 = rand();
270
    int xi5 = gel_rand();
266
    x3 = xi5*x1;
271
    x3 = xi5*x1;
267
    success += x3[0] == xi1*xi5 && x3[1] == xi2*xi5;
272
    success += x3[0] == xi1*xi5 && x3[1] == xi2*xi5;
268
    
273
    
269
    x3 = x1*xi5;
274
    x3 = x1*xi5;
270
    success += x3[0] == xi1*xi5 && x3[1] == xi2*xi5;
275
    success += x3[0] == xi1*xi5 && x3[1] == xi2*xi5;
Line 360... Line 365...
360
 
365
 
361
    float xi1 = my_random(), xi2 = my_random();
366
    float xi1 = my_random(), xi2 = my_random();
362
    Vec2f x2(xi1, xi2);
367
    Vec2f x2(xi1, xi2);
363
    success += x2[0] == xi1 && x2[1] == xi2;
368
    success += x2[0] == xi1 && x2[1] == xi2;
364
 
369
 
365
    int xii1 = rand(), xii2 = rand();
370
    int xii1 = gel_rand(), xii2 = gel_rand();
366
    Vec2i i1(xii1, xii2);
371
    Vec2i i1(xii1, xii2);
367
    Vec2f x3(i1);
372
    Vec2f x3(i1);
368
    success += x3[0] == xii1 && x3[1] == xii2;
373
    success += x3[0] == xii1 && x3[1] == xii2;
369
 
374
 
370
    double xiii1 = my_random(), xiii2 = my_random();
375
    double xiii1 = my_random(), xiii2 = my_random();
Line 565... Line 570...
565
    success += abs(x3[0] - xi1*xi4) < 1-0e-15 && abs(x3[1] - xi2*xi4) < 1.0e-15;
570
    success += abs(x3[0] - xi1*xi4) < 1-0e-15 && abs(x3[1] - xi2*xi4) < 1.0e-15;
566
    
571
    
567
    x3 = x1*xi4;
572
    x3 = x1*xi4;
568
    success += abs(x3[0] - xi1*xi4) < 1-0e-15 && abs(x3[1] - xi2*xi4) < 1.0e-15;
573
    success += abs(x3[0] - xi1*xi4) < 1-0e-15 && abs(x3[1] - xi2*xi4) < 1.0e-15;
569
 
574
 
570
    int xi5 = rand();
575
    int xi5 = gel_rand();
571
    x3 = xi5*x1;
576
    x3 = xi5*x1;
572
    success += abs(x3[0] - xi1*xi5) < 1.0e-15 && abs(x3[1] - xi2*xi5) < 1.0e-15;
577
    success += abs(x3[0] - xi1*xi5) < 1.0e-15 && abs(x3[1] - xi2*xi5) < 1.0e-15;
573
 
578
 
574
    x3 = x1*xi5;
579
    x3 = x1*xi5;
575
    success += abs(x3[0] - xi1*xi5) < 1.0e-15 && abs(x3[1] - xi2*xi5) < 1.0e-15;
580
    success += abs(x3[0] - xi1*xi5) < 1.0e-15 && abs(x3[1] - xi2*xi5) < 1.0e-15;
Line 664... Line 669...
664
 *
669
 *
665
    Vec2i x1;
670
    Vec2i x1;
666
    success += CGLA::isnan(x1[0]) && CGLA::isnan(x1[1]);
671
    success += CGLA::isnan(x1[0]) && CGLA::isnan(x1[1]);
667
*/
672
*/
668
 
673
 
669
    int xi1 = rand(), xi2 = rand();
674
    int xi1 = gel_rand(), xi2 = gel_rand();
670
    Vec2i x2(xi1, xi2);
675
    Vec2i x2(xi1, xi2);
671
    success += x2[0] == xi1 && x2[1] == xi2;
676
    success += x2[0] == xi1 && x2[1] == xi2;
672
 
677
 
673
/* Constuctor non-existent !
678
/* Constuctor non-existent !
674
 *
679
 *
Line 683... Line 688...
683
    Vec2i x4(f1);
688
    Vec2i x4(f1);
684
    success += x4[0] == static_cast<int>(xiii1) && x4[1] == static_cast<int>(xiii2);
689
    success += x4[0] == static_cast<int>(xiii1) && x4[1] == static_cast<int>(xiii2);
685
 
690
 
686
/* Constuctor non-existent !
691
/* Constuctor non-existent !
687
 *
692
 *
688
    int xiiii = rand();
693
    int xiiii = gel_rand();
689
    Vec2i x5(xiiii);
694
    Vec2i x5(xiiii);
690
    success += x5[0] == xiiii && x5[1] == xiiii;
695
    success += x5[0] == xiiii && x5[1] == xiiii;
691
*/
696
*/
692
  }
697
  }
693
  if(success != 2)
698
  if(success != 2)
Line 702... Line 707...
702
  {
707
  {
703
    Vec2i x1;    
708
    Vec2i x1;    
704
 
709
 
705
    success += x1.get_dim() == 2;
710
    success += x1.get_dim() == 2;
706
 
711
 
707
    int xi1 = rand(), xi2 = rand();
712
    int xi1 = gel_rand(), xi2 = gel_rand();
708
    x1.set(xi1, xi2);
713
    x1.set(xi1, xi2);
709
    success += x1[0] == xi1 && x1[1] == xi2;
714
    success += x1[0] == xi1 && x1[1] == xi2;
710
 
715
 
711
    success += x1.get() == &x1[0];
716
    success += x1.get() == &x1[0];
712
 
717
 
Line 730... Line 735...
730
  success = 0;
735
  success = 0;
731
 
736
 
732
  // Comparison operators
737
  // Comparison operators
733
 
738
 
734
  {
739
  {
735
    int xi1 = rand(), xi2 = rand();
740
    int xi1 = gel_rand(), xi2 = gel_rand();
736
    while(xi1 == xi2)
741
    while(xi1 == xi2)
737
    {
742
    {
738
      xi1 = rand();
743
      xi1 = gel_rand();
739
      xi2 = rand();
744
      xi2 = gel_rand();
740
    }
745
    }
741
 
746
 
742
    Vec2i x1(xi1, xi2), x2(xi1, xi2), x3(xi1, xi1), x4(xi2, xi2);    
747
    Vec2i x1(xi1, xi2), x2(xi1, xi2), x3(xi1, xi1), x4(xi2, xi2);    
743
    success += x1 == x2;
748
    success += x1 == x2;
744
    success += !(x1 == x3);
749
    success += !(x1 == x3);
Line 778... Line 783...
778
  success = 0;
783
  success = 0;
779
  
784
  
780
  // Assignment operators
785
  // Assignment operators
781
 
786
 
782
  {
787
  {
783
    int xi1 = rand(), xi2 = rand();
788
    int xi1 = gel_rand(), xi2 = gel_rand();
784
    Vec2i x1(xi1, xi2);
789
    Vec2i x1(xi1, xi2);
785
    int xi3 = rand();
790
    int xi3 = gel_rand();
786
    x1 *= xi3;
791
    x1 *= xi3;
787
    success += x1[0] == xi1*xi3 && x1[1] == xi2*xi3;
792
    success += x1[0] == xi1*xi3 && x1[1] == xi2*xi3;
788
 
793
 
789
    while(xi3 == 0)
794
    while(xi3 == 0)
790
      xi3 = rand();
795
      xi3 = gel_rand();
791
    x1 = Vec2i(xi1, xi2);
796
    x1 = Vec2i(xi1, xi2);
792
    x1 /= xi3;
797
    x1 /= xi3;
793
    success += x1[0] == xi1/xi3 && x1[1] == xi2/xi3;
798
    success += x1[0] == xi1/xi3 && x1[1] == xi2/xi3;
794
 
799
 
795
    x1 = Vec2i(xi1, xi2);
800
    x1 = Vec2i(xi1, xi2);
Line 798... Line 803...
798
 
803
 
799
    x1 = Vec2i(xi1, xi2);
804
    x1 = Vec2i(xi1, xi2);
800
    x1 -= xi3;
805
    x1 -= xi3;
801
    success += x1[0] == xi1 - xi3 && x1[1] == xi2 - xi3;
806
    success += x1[0] == xi1 - xi3 && x1[1] == xi2 - xi3;
802
 
807
 
803
    int xii1 = rand(), xii2 = rand();
808
    int xii1 = gel_rand(), xii2 = gel_rand();
804
    Vec2i x2(xii1, xii2);
809
    Vec2i x2(xii1, xii2);
805
    x1 = Vec2i(xi1, xi2);
810
    x1 = Vec2i(xi1, xi2);
806
    x2 *= x1;
811
    x2 *= x1;
807
    success += x2[0] == xi1*xii1 && x2[1] == xi2*xii2;
812
    success += x2[0] == xi1*xii1 && x2[1] == xi2*xii2;
808
 
813
 
809
    while(xi1 == 0)
814
    while(xi1 == 0)
810
      xi1 = rand();
815
      xi1 = gel_rand();
811
    while(xi2 == 0)
816
    while(xi2 == 0)
812
      xi2 = rand();
817
      xi2 = gel_rand();
813
    x1 = Vec2i(xi1, xi2);
818
    x1 = Vec2i(xi1, xi2);
814
    x2 = Vec2i(xii1, xii2);
819
    x2 = Vec2i(xii1, xii2);
815
    x2 /= x1;
820
    x2 /= x1;
816
    success += x2[0] == xii1/xi1 && x2[1] == xii2/xi2;
821
    success += x2[0] == xii1/xi1 && x2[1] == xii2/xi2;
817
 
822
 
Line 831... Line 836...
831
  success = 0;
836
  success = 0;
832
 
837
 
833
  // Unary operators
838
  // Unary operators
834
 
839
 
835
  {
840
  {
836
    int xi1 = rand(), xi2 = rand();
841
    int xi1 = gel_rand(), xi2 = gel_rand();
837
    Vec2i x1 = -Vec2i(xi1, xi2);    
842
    Vec2i x1 = -Vec2i(xi1, xi2);    
838
    success += x1[0] == -xi1 && x1[1] == -xi2;
843
    success += x1[0] == -xi1 && x1[1] == -xi2;
839
  }
844
  }
840
  if(success != 1)
845
  if(success != 1)
841
  {
846
  {
Line 845... Line 850...
845
  success = 0;
850
  success = 0;
846
 
851
 
847
  // Binary operators
852
  // Binary operators
848
 
853
 
849
  {
854
  {
850
    int xi1 = rand(), xi2 = rand();
855
    int xi1 = gel_rand(), xi2 = gel_rand();
851
    Vec2i x1(xi1, xi2);
856
    Vec2i x1(xi1, xi2);
852
    int xii1 = rand(), xii2 = rand();
857
    int xii1 = gel_rand(), xii2 = gel_rand();
853
    while(xii1 == 0)
858
    while(xii1 == 0)
854
      xii1 = rand();
859
      xii1 = gel_rand();
855
    while(xii2 == 0)
860
    while(xii2 == 0)
856
      xii2 = rand();
861
      xii2 = gel_rand();
857
    Vec2i x2(xii1, xii2);
862
    Vec2i x2(xii1, xii2);
858
    Vec2i x3 = x1*x2;
863
    Vec2i x3 = x1*x2;
859
    success += x3[0] == xi1*xii1 && x3[1] == xi2*xii2;
864
    success += x3[0] == xi1*xii1 && x3[1] == xi2*xii2;
860
    
865
    
861
    x3 = x1 + x2;
866
    x3 = x1 + x2;
Line 865... Line 870...
865
    success += x3[0] == xi1 - xii1 && x3[1] == xi2 - xii2;
870
    success += x3[0] == xi1 - xii1 && x3[1] == xi2 - xii2;
866
    
871
    
867
    x3 = x1/x2;
872
    x3 = x1/x2;
868
    success += x3[0] == xi1/xii1 && x3[1] == xi2/xii2;
873
    success += x3[0] == xi1/xii1 && x3[1] == xi2/xii2;
869
 
874
 
870
    int xi3 = rand();
875
    int xi3 = gel_rand();
871
    x3 = x1*xi3;
876
    x3 = x1*xi3;
872
    success += x3[0] == xi1*xi3 && x3[1] == xi2*xi3;
877
    success += x3[0] == xi1*xi3 && x3[1] == xi2*xi3;
873
    
878
    
874
    x3 = xi3*x1;
879
    x3 = xi3*x1;
875
    success += x3[0] == xi1*xi3 && x3[1] == xi2*xi3;
880
    success += x3[0] == xi1*xi3 && x3[1] == xi2*xi3;
Line 887... Line 892...
887
    
892
    
888
    x3 = x1*xi5;
893
    x3 = x1*xi5;
889
    success += x3[0] == xi1*static_cast<int>(xi5) && x3[1] == xi2*static_cast<int>(xi5);
894
    success += x3[0] == xi1*static_cast<int>(xi5) && x3[1] == xi2*static_cast<int>(xi5);
890
 
895
 
891
    while(xi3 == 0)
896
    while(xi3 == 0)
892
      xi3 = rand();
897
      xi3 = gel_rand();
893
    x3 = x1/xi3;
898
    x3 = x1/xi3;
894
    success += x3[0] == xi1/xi3 && x3[1] == xi2/xi3;
899
    success += x3[0] == xi1/xi3 && x3[1] == xi2/xi3;
895
  } 
900
  } 
896
  if(success != 11)
901
  if(success != 11)
897
  {
902
  {
Line 901... Line 906...
901
  success = 0;
906
  success = 0;
902
 
907
 
903
  // Vector operations
908
  // Vector operations
904
 
909
 
905
  {
910
  {
906
    int xi1 = rand(), xi2 = rand();
911
    int xi1 = gel_rand(), xi2 = gel_rand();
907
    Vec2i x1(xi1, xi2);
912
    Vec2i x1(xi1, xi2);
908
    int xii1 = rand(), xii2 = rand();
913
    int xii1 = gel_rand(), xii2 = gel_rand();
909
    Vec2i x2(xii1, xii2);
914
    Vec2i x2(xii1, xii2);
910
    int x = dot(x1, x2);
915
    int x = dot(x1, x2);
911
    success += x == xi1*xii1 + xi2*xii2;
916
    success += x == xi1*xii1 + xi2*xii2;
912
 
917
 
913
    x = sqr_length(x1);
918
    x = sqr_length(x1);
Line 937... Line 942...
937
 *
942
 *
938
    Vec3i x1;
943
    Vec3i x1;
939
    success += CGLA::isnan(x1[0]) && CGLA::isnan(x1[1]) && CGLA::isnan(x1[2]);
944
    success += CGLA::isnan(x1[0]) && CGLA::isnan(x1[1]) && CGLA::isnan(x1[2]);
940
*/
945
*/
941
 
946
 
942
    int xi1 = rand(), xi2 = rand(), xi3 = rand();
947
    int xi1 = gel_rand(), xi2 = gel_rand(), xi3 = gel_rand();
943
    Vec3i x2(xi1, xi2, xi3);
948
    Vec3i x2(xi1, xi2, xi3);
944
    success += x2[0] == xi1 && x2[1] == xi2 && x2[2] == xi3;
949
    success += x2[0] == xi1 && x2[1] == xi2 && x2[2] == xi3;
945
 
950
 
946
    int xiiii = rand();
951
    int xiiii = gel_rand();
947
    Vec3i x3(xiiii);
952
    Vec3i x3(xiiii);
948
    success += x3[0] == xiiii && x3[1] == xiiii && x3[2] == xiiii;
953
    success += x3[0] == xiiii && x3[1] == xiiii && x3[2] == xiiii;
949
 
954
 
950
/* Constuctor non-existent !
955
/* Constuctor non-existent !
951
 *
956
 *
Line 988... Line 993...
988
  {
993
  {
989
    Vec3i x1;    
994
    Vec3i x1;    
990
 
995
 
991
    success += x1.get_dim() == 3;
996
    success += x1.get_dim() == 3;
992
 
997
 
993
    int xi1 = rand(), xi2 = rand(), xi3 = rand();
998
    int xi1 = gel_rand(), xi2 = gel_rand(), xi3 = gel_rand();
994
    x1.set(xi1, xi2, xi3);
999
    x1.set(xi1, xi2, xi3);
995
    success += x1[0] == xi1 && x1[1] == xi2 && x1[2] == xi3;
1000
    success += x1[0] == xi1 && x1[1] == xi2 && x1[2] == xi3;
996
 
1001
 
997
    success += x1.get() == &x1[0];
1002
    success += x1.get() == &x1[0];
998
 
1003
 
Line 1016... Line 1021...
1016
  success = 0;
1021
  success = 0;
1017
 
1022
 
1018
  // Comparison operators
1023
  // Comparison operators
1019
 
1024
 
1020
  {
1025
  {
1021
    int xi1 = rand(), xi2 = rand(), xi3 = rand();
1026
    int xi1 = gel_rand(), xi2 = gel_rand(), xi3 = gel_rand();
1022
    while(xi1 >= xi2)
1027
    while(xi1 >= xi2)
1023
    {
1028
    {
1024
      xi1 = rand();
1029
      xi1 = gel_rand();
1025
      xi2 = rand();
1030
      xi2 = gel_rand();
1026
    }
1031
    }
1027
    while(xi3 <= xi2)
1032
    while(xi3 <= xi2)
1028
      xi3 = rand();
1033
      xi3 = gel_rand();
1029
 
1034
 
1030
    Vec3i x1(xi1, xi2, xi3), x2(xi1, xi2, xi3), 
1035
    Vec3i x1(xi1, xi2, xi3), x2(xi1, xi2, xi3), 
1031
          x3(xi1, xi1, xi1), x4(xi2, xi2, xi2), x5(xi3, xi3, xi3);    
1036
          x3(xi1, xi1, xi1), x4(xi2, xi2, xi2), x5(xi3, xi3, xi3);    
1032
    success += x1 == x2;
1037
    success += x1 == x2;
1033
    success += !(x1 == x3);
1038
    success += !(x1 == x3);
Line 1052... Line 1057...
1052
  success = 0;
1057
  success = 0;
1053
  
1058
  
1054
  // Assignment operators
1059
  // Assignment operators
1055
 
1060
 
1056
  {
1061
  {
1057
    int xi1 = rand(), xi2 = rand(), xi3 = rand();
1062
    int xi1 = gel_rand(), xi2 = gel_rand(), xi3 = gel_rand();
1058
    Vec3i x1(xi1, xi2, xi3);
1063
    Vec3i x1(xi1, xi2, xi3);
1059
    int xii = rand();
1064
    int xii = gel_rand();
1060
    x1 *= xii;
1065
    x1 *= xii;
1061
    success += x1[0] == xi1*xii && x1[1] == xi2*xii && x1[2] == xi3*xii;
1066
    success += x1[0] == xi1*xii && x1[1] == xi2*xii && x1[2] == xi3*xii;
1062
 
1067
 
1063
    while(xii == 0)
1068
    while(xii == 0)
1064
      xii = rand();
1069
      xii = gel_rand();
1065
    x1 = Vec3i(xi1, xi2, xi3);
1070
    x1 = Vec3i(xi1, xi2, xi3);
1066
    x1 /= xii;
1071
    x1 /= xii;
1067
    success += x1[0] == xi1/xii && x1[1] == xi2/xii && x1[2] == xi3/xii;
1072
    success += x1[0] == xi1/xii && x1[1] == xi2/xii && x1[2] == xi3/xii;
1068
 
1073
 
1069
    x1 = Vec3i(xi1, xi2, xi3);
1074
    x1 = Vec3i(xi1, xi2, xi3);
Line 1072... Line 1077...
1072
 
1077
 
1073
    x1 = Vec3i(xi1, xi2, xi3);
1078
    x1 = Vec3i(xi1, xi2, xi3);
1074
    x1 -= xii;
1079
    x1 -= xii;
1075
    success += x1[0] == xi1 - xii && x1[1] == xi2 - xii && x1[2] == xi3 - xii;
1080
    success += x1[0] == xi1 - xii && x1[1] == xi2 - xii && x1[2] == xi3 - xii;
1076
 
1081
 
1077
    int xii1 = rand(), xii2 = rand(), xii3 = rand();
1082
    int xii1 = gel_rand(), xii2 = gel_rand(), xii3 = gel_rand();
1078
    Vec3i x2(xii1, xii2, xii3);
1083
    Vec3i x2(xii1, xii2, xii3);
1079
    x1 = Vec3i(xi1, xi2, xi3);
1084
    x1 = Vec3i(xi1, xi2, xi3);
1080
    x2 *= x1;
1085
    x2 *= x1;
1081
    success += x2[0] == xi1*xii1 && x2[1] == xi2*xii2 && x2[2] == xi3*xii3;
1086
    success += x2[0] == xi1*xii1 && x2[1] == xi2*xii2 && x2[2] == xi3*xii3;
1082
 
1087
 
1083
    while(xi1 == 0)
1088
    while(xi1 == 0)
1084
      xi1 = rand();
1089
      xi1 = gel_rand();
1085
    while(xi2 == 0)
1090
    while(xi2 == 0)
1086
      xi2 = rand();
1091
      xi2 = gel_rand();
1087
    while(xi3 == 0)
1092
    while(xi3 == 0)
1088
      xi3 = rand();
1093
      xi3 = gel_rand();
1089
    x1 = Vec3i(xi1, xi2, xi3);
1094
    x1 = Vec3i(xi1, xi2, xi3);
1090
    x2 = Vec3i(xii1, xii2, xii3);
1095
    x2 = Vec3i(xii1, xii2, xii3);
1091
    x2 /= x1;
1096
    x2 /= x1;
1092
    success += x2[0] == xii1/xi1 && x2[1] == xii2/xi2 && x2[2] == xii3/xi3;
1097
    success += x2[0] == xii1/xi1 && x2[1] == xii2/xi2 && x2[2] == xii3/xi3;
1093
 
1098
 
Line 1107... Line 1112...
1107
  success = 0;
1112
  success = 0;
1108
 
1113
 
1109
  // Unary operators
1114
  // Unary operators
1110
 
1115
 
1111
  {
1116
  {
1112
    int xi1 = rand(), xi2 = rand(), xi3 = rand();
1117
    int xi1 = gel_rand(), xi2 = gel_rand(), xi3 = gel_rand();
1113
    Vec3i x1 = -Vec3i(xi1, xi2, xi3);    
1118
    Vec3i x1 = -Vec3i(xi1, xi2, xi3);    
1114
    success += x1[0] == -xi1 && x1[1] == -xi2 && x1[2] == -xi3;
1119
    success += x1[0] == -xi1 && x1[1] == -xi2 && x1[2] == -xi3;
1115
  }
1120
  }
1116
  if(success != 1)
1121
  if(success != 1)
1117
  {
1122
  {
Line 1121... Line 1126...
1121
  success = 0;
1126
  success = 0;
1122
 
1127
 
1123
  // Binary operators
1128
  // Binary operators
1124
 
1129
 
1125
  {
1130
  {
1126
    int xi1 = rand(), xi2 = rand(), xi3 = rand();
1131
    int xi1 = gel_rand(), xi2 = gel_rand(), xi3 = gel_rand();
1127
    Vec3i x1(xi1, xi2, xi3);
1132
    Vec3i x1(xi1, xi2, xi3);
1128
    int xii1 = rand(), xii2 = rand(), xii3 = rand();
1133
    int xii1 = gel_rand(), xii2 = gel_rand(), xii3 = gel_rand();
1129
    while(xii1 == 0)
1134
    while(xii1 == 0)
1130
      xii1 = rand();
1135
      xii1 = gel_rand();
1131
    while(xii2 == 0)
1136
    while(xii2 == 0)
1132
      xii2 = rand();
1137
      xii2 = gel_rand();
1133
    while(xii3 == 0)
1138
    while(xii3 == 0)
1134
      xii3 = rand();
1139
      xii3 = gel_rand();
1135
    Vec3i x2(xii1, xii2, xii3);
1140
    Vec3i x2(xii1, xii2, xii3);
1136
    Vec3i x3 = x1*x2;
1141
    Vec3i x3 = x1*x2;
1137
    success += x3[0] == xi1*xii1 && x3[1] == xi2*xii2 && x3[2] == xi3*xii3;
1142
    success += x3[0] == xi1*xii1 && x3[1] == xi2*xii2 && x3[2] == xi3*xii3;
1138
    
1143
    
1139
    x3 = x1 + x2;
1144
    x3 = x1 + x2;
Line 1143... Line 1148...
1143
    success += x3[0] == xi1 - xii1 && x3[1] == xi2 - xii2 && x3[2] == xi3 - xii3;
1148
    success += x3[0] == xi1 - xii1 && x3[1] == xi2 - xii2 && x3[2] == xi3 - xii3;
1144
    
1149
    
1145
    x3 = x1/x2;
1150
    x3 = x1/x2;
1146
    success += x3[0] == xi1/xii1 && x3[1] == xi2/xii2 && x3[2] == xi3/xii3;
1151
    success += x3[0] == xi1/xii1 && x3[1] == xi2/xii2 && x3[2] == xi3/xii3;
1147
 
1152
 
1148
    int xii = rand();
1153
    int xii = gel_rand();
1149
    x3 = x1*xii;
1154
    x3 = x1*xii;
1150
    success += x3[0] == xi1*xii && x3[1] == xi2*xii && x3[2] == xi3*xii;
1155
    success += x3[0] == xi1*xii && x3[1] == xi2*xii && x3[2] == xi3*xii;
1151
    
1156
    
1152
    x3 = xii*x1;
1157
    x3 = xii*x1;
1153
    success += x3[0] == xi1*xii && x3[1] == xi2*xii && x3[2] == xi3*xii;
1158
    success += x3[0] == xi1*xii && x3[1] == xi2*xii && x3[2] == xi3*xii;
Line 1173... Line 1178...
1173
    success += x3[0] == xi1*static_cast<int>(xi5) 
1178
    success += x3[0] == xi1*static_cast<int>(xi5) 
1174
               && x3[1] == xi2*static_cast<int>(xi5) 
1179
               && x3[1] == xi2*static_cast<int>(xi5) 
1175
               && x3[2] == xi3*static_cast<int>(xi5);
1180
               && x3[2] == xi3*static_cast<int>(xi5);
1176
 
1181
 
1177
    while(xii == 0)
1182
    while(xii == 0)
1178
      xii = rand();
1183
      xii = gel_rand();
1179
    x3 = x1/xii;
1184
    x3 = x1/xii;
1180
    success += x3[0] == xi1/xii && x3[1] == xi2/xii && x3[2] == xi3/xii;
1185
    success += x3[0] == xi1/xii && x3[1] == xi2/xii && x3[2] == xi3/xii;
1181
  } 
1186
  } 
1182
  if(success != 11)
1187
  if(success != 11)
1183
  {
1188
  {
Line 1187... Line 1192...
1187
  success = 0;
1192
  success = 0;
1188
 
1193
 
1189
  // Vector operations
1194
  // Vector operations
1190
 
1195
 
1191
  {
1196
  {
1192
    int xi1 = rand(), xi2 = rand(), xi3 = rand();
1197
    int xi1 = gel_rand(), xi2 = gel_rand(), xi3 = gel_rand();
1193
    Vec3i x1(xi1, xi2, xi3);
1198
    Vec3i x1(xi1, xi2, xi3);
1194
    int xii1 = rand(), xii2 = rand(), xii3 = rand();
1199
    int xii1 = gel_rand(), xii2 = gel_rand(), xii3 = gel_rand();
1195
    Vec3i x2(xii1, xii2, xii3);
1200
    Vec3i x2(xii1, xii2, xii3);
1196
    int x = dot(x1, x2);
1201
    int x = dot(x1, x2);
1197
    success += x == xi1*xii1 + xi2*xii2 + xi3*xii3;
1202
    success += x == xi1*xii1 + xi2*xii2 + xi3*xii3;
1198
 
1203
 
1199
    x = sqr_length(x1);
1204
    x = sqr_length(x1);
Line 1242... Line 1247...
1242
    double xii1 = my_random(), xii2 = my_random(), xii3 = my_random();
1247
    double xii1 = my_random(), xii2 = my_random(), xii3 = my_random();
1243
    Vec3d d1(xii1, xii2, xii3);
1248
    Vec3d d1(xii1, xii2, xii3);
1244
    Vec3f x4(d1);
1249
    Vec3f x4(d1);
1245
    success += x4[0] == xii1 && x4[1] == xii2 && x4[2] == xii3;
1250
    success += x4[0] == xii1 && x4[1] == xii2 && x4[2] == xii3;
1246
 
1251
 
1247
    int xiii1 = rand(), xiii2 = rand(), xiii3 = rand();
1252
    int xiii1 = gel_rand(), xiii2 = gel_rand(), xiii3 = gel_rand();
1248
    Vec3i i1(xiii1, xiii2, xiii3);
1253
    Vec3i i1(xiii1, xiii2, xiii3);
1249
    Vec3f x5(i1);
1254
    Vec3f x5(i1);
1250
    success += x5[0] == xiii1 && x5[1] == xiii2 && x5[2] == xiii3;
1255
    success += x5[0] == xiii1 && x5[1] == xiii2 && x5[2] == xiii3;
1251
 
1256
 
1252
    float xiiii1 = my_random(), xiiii2 = my_random(), xiiii3 = my_random();
1257
    float xiiii1 = my_random(), xiiii2 = my_random(), xiiii3 = my_random();
Line 1451... Line 1456...
1451
    x3 = xii*x1;
1456
    x3 = xii*x1;
1452
    success += abs(x3[0] - xi1*xii) < 1.0e-15 
1457
    success += abs(x3[0] - xi1*xii) < 1.0e-15 
1453
               && abs(x3[1] - xi2*xii) < 1.0e-15 
1458
               && abs(x3[1] - xi2*xii) < 1.0e-15 
1454
               && abs(x3[2] - xi3*xii) < 1.0e-15;
1459
               && abs(x3[2] - xi3*xii) < 1.0e-15;
1455
 
1460
 
1456
    int xi4 = rand();
1461
    int xi4 = gel_rand();
1457
    x3 = xi4*x1;
1462
    x3 = xi4*x1;
1458
    success += abs(x3[0] - xi1*xi4) < 1.0e-15 
1463
    success += abs(x3[0] - xi1*xi4) < 1.0e-15 
1459
               && abs(x3[1] - xi2*xi4) < 1.0e-15 
1464
               && abs(x3[1] - xi2*xi4) < 1.0e-15 
1460
               && abs(x3[2] - xi3*xi4) < 1.0e-15;
1465
               && abs(x3[2] - xi3*xi4) < 1.0e-15;
1461
    
1466
    
Line 1560... Line 1565...
1560
    float xii1 = my_random(), xii2 = my_random(), xii3 = my_random();
1565
    float xii1 = my_random(), xii2 = my_random(), xii3 = my_random();
1561
    Vec3f f1(xii1, xii2, xii3);
1566
    Vec3f f1(xii1, xii2, xii3);
1562
    Vec3d x4(f1);
1567
    Vec3d x4(f1);
1563
    success += x4[0] == xii1 && x4[1] == xii2 && x4[2] == xii3;
1568
    success += x4[0] == xii1 && x4[1] == xii2 && x4[2] == xii3;
1564
 
1569
 
1565
    int xiii1 = rand(), xiii2 = rand(), xiii3 = rand();
1570
    int xiii1 = gel_rand(), xiii2 = gel_rand(), xiii3 = gel_rand();
1566
    Vec3i i1(xiii1, xiii2, xiii3);
1571
    Vec3i i1(xiii1, xiii2, xiii3);
1567
    Vec3d x5(i1);
1572
    Vec3d x5(i1);
1568
    success += x5[0] == xiii1 && x5[1] == xiii2 && x5[2] == xiii3;
1573
    success += x5[0] == xiii1 && x5[1] == xiii2 && x5[2] == xiii3;
1569
 
1574
 
1570
 
1575
 
Line 1771... Line 1776...
1771
    x3 = xii*x1;
1776
    x3 = xii*x1;
1772
    success += abs(x3[0] - xi1*xii) < 1.0e-15 
1777
    success += abs(x3[0] - xi1*xii) < 1.0e-15 
1773
               && abs(x3[1] - xi2*xii) < 1.0e-15 
1778
               && abs(x3[1] - xi2*xii) < 1.0e-15 
1774
               && abs(x3[2] - xi3*xii) < 1.0e-15;
1779
               && abs(x3[2] - xi3*xii) < 1.0e-15;
1775
 
1780
 
1776
    int xi4 = rand();
1781
    int xi4 = gel_rand();
1777
    x3 = xi4*x1;
1782
    x3 = xi4*x1;
1778
    success += abs(x3[0] - xi1*xi4) < 1.0e-15 
1783
    success += abs(x3[0] - xi1*xi4) < 1.0e-15 
1779
               && abs(x3[1] - xi2*xi4) < 1.0e-15 
1784
               && abs(x3[1] - xi2*xi4) < 1.0e-15 
1780
               && abs(x3[2] - xi3*xi4) < 1.0e-15;
1785
               && abs(x3[2] - xi3*xi4) < 1.0e-15;
1781
    
1786