29 #include <Base/Math/Matrix.hh>
30 #include <Base/Math/Random.hh>
31 #include <Base/Common/CompareFloatingPoint.hh>
43 int main(
int argc,
char *argv[])
45 const bool verbose =
false;
47 const int num_sizes = 100;
48 for (
int t=0; t<num_sizes; t++){
55 const int num_tries = 1000;
56 for (
int i=0; i<num_tries; i++){
57 GenerateRandomMatrix(A);
61 if (verbose) cout <<
"\nrref(A): "<<A;
62 if (!TestForReducedRowEchelonForm(A)){
64 BIASERR(
"error: matrix is not in reduced row echelon form: "<<A);
66 cout <<
"\nA: "<<Aorig;
68 cout <<
" !!FAILED!!\n";
71 if (verbose) cout <<
"passed!\n";
80 static int num_calls = 0;
81 const double range=1.;
83 for (
int r=0; r<numr; r++){
84 for (
int c=0; c<numc; c++){
88 if ((num_calls%2)==0 && abs(A[r][c])<0.5) A[r][c] = 0.;
98 for (r=0; r<numr; r++){
100 for (c=0; c<numc &&
Equal(A[r][c], 0.0); c++){ }
102 if (c<=lead && lead<numc){ cout <<
"lead pos\n";
return false; }
105 if (lead==numc)
continue;
107 if (!
Equal(A[r][lead], 1.0)) { cout <<
"lead == 1.\n";
return false; }
109 for (
int rr=0; rr<numr; rr++){
111 if (!
Equal(A[rr][lead], 0.0)) { cout <<
"top == 0.\n";
return false; }
Subscript num_cols() const
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
int GetUniformDistributedInt(const int min, const int max)
get uniform distributed random variable including min/max
void GaussJordan()
use the Gauss Jordan Algrithm to transform the matrix to reduced row echelon form.
bool Equal(const T left, const T right, const T eps)
comparison function for floating point values See http://www.boost.org/libs/test/doc/components/test_...
Subscript num_rows() const
class for producing random numbers from different distributions