int main() { Rat a(2,5); Rat b(10/5); Interval X(a,b); Interval Degen(2,2); Interval A(1,2); Interval B(-5,90); Interval C(-4,-3); //=============================================================================== std::cout << "Check for associativity and commutativity" << std::endl; std::cout << "A = " << A << " B = " << B << " C = " << C << std::endl; std::cout << "A + B = " << A + B << std::endl; std::cout << "(A + B) - B = " << (A + B) - B << std::endl; std::cout << "A + (B - B) = " << A + (B - B) << std::endl; std::cout << "A + B - B = " << A + B - B << std::endl; std::cout << "A * B = " << A * B << std::endl; std::cout << "B * A = " << B * A << std::endl; std::cout << "(A * B) * C = " << (A * B) * C << std::endl; std::cout << "A * (B * C) = " << A * (B * C) << std::endl; std::cout << "The test interval X: " << X << std::endl << std::endl; //=============================================================================== std::cout << "Degenerate interval test" << std::endl; std::cout << "The degenerate interval [2,2]: " << Degen << std::endl << std::endl; //=============================================================================== std::cout << "Left and Right endpoint test" << std::endl; std::cout << "Left endpoint of X is: " << X.lower() << std::endl; std::cout << "Right endpoint of X is: " << X.upper() << std::endl; //=============================================================================== std::cout << "Interval positive/negative test" << std::endl; if(X >= 0) std::cout << "X is positive" << std::endl; else std::cout << "X is not positive" << std::endl; if(X > 0) std::cout << "X is strictly positive" << std::endl; else std::cout << "X is not strictly positive" << std::endl; if(X <= 0) std::cout << "X is negative" << std::endl; else std::cout << "X is not negative" << std::endl; if(X < 0) std::cout << "X is strictly negative" << std::endl; else std::cout << "X is not strictly negative" << std::endl << std::endl; //============================================================================= std::cout << "Interval comparison test" << std::endl; Interval Y(3,5); if(X < Y) std::cout << X << " is less than " << Y << std::endl; else std::cout << X << " is not less than " << Y << std::endl; Y.assign(8,10); if(X <= Y) std::cout << X << " is less than or equal to " << Y << std::endl; else std::cout << X << " is not less than or equal to " << Y << std::endl; if(X > Y) std::cout << X << " is greater than " << Y << std::endl; else std::cout << X << " is not greater than " << Y << std::endl; if(X >= Y) std::cout << X << " is greater than or equal to " << Y << std::endl; else std::cout << X << " is not greater than or equal to " << Y << std::endl << std::endl; //============================================================================ std::cout << "Arithmetic test" << std::endl; std::cout << X << " + " << Y << " = " << X + Y << std::endl << std::endl; std::cout << X << " - " << Y << " = " << X - Y << std::endl << std::endl; X.assign(2,3); Y.assign(5,6); std::cout << X << " * " << Y << " = " << X * Y << std::endl; X.assign(a,b); Y.assign(-3,5); std::cout << X << " * " << Y << " = " << X * Y << std::endl; Y.assign(-3,-2); std::cout << X << " * " << Y << " = " << X * Y << std::endl; X.assign(-a,b); Y.assign(3,5); std::cout << X << " * " << Y << " = " << X * Y << std::endl << std::endl; X.assign(a,b); std::cout << "X = " << X << " 1/X = " << 1/X << std::endl; std::cout << X << "/" << Y << " = " << X/Y << std::endl << std::endl; std::cout << "X = " << X << " X^0 = " << boost::numeric::pow(X,0) << std::endl; std::cout << "X = " << X << " X^2 = " << boost::numeric::pow(X,2) << std::endl; X.assign(-5,3); std::cout << "X = " << X << " X^(3) = " << boost::numeric::pow(X,3) << std::endl; X.assign(-5,-3); std::cout << "X = " << X << " X^4 = " << boost::numeric::pow(X,4) << std::endl; X.assign(-8,9); std::cout << "X = " << X << " X^2 = " << boost::numeric::pow(X,2) << std::endl << std::endl; X.assign(-5,-2); Y.assign(-4,0); std::cout << X << "/" << Y << " = " << X/Y << std::endl; X.assign(-10,4); std::cout << X << "/" << Y << " = " << X/Y << std::endl; std::cout << "Y = " << Y << " 1/Y = " << 1/Y << std::endl << std::endl; //======================================================================== std::cout << "Interval Functions test" << std::endl; X.assign(2,100); std::cout << "X = " << X << std::endl; std::cout << "Midpoint of X, m(X) = " << boost::numeric::median(X) << std::endl; std::cout << "Width of X, w(X) = " << boost::numeric::width(X) << std::endl; std::cout << "The absolute value of X, |X| = " << boost::numeric::norm(X) << std::endl; std::cout << "The mignitude of X, mig(X) = " << mig(X) << std::endl; Interval test(-11,11); Interval test1(0,5); Interval ans; ans = test1/test; std::cout << ans << std::endl; return 0; }
CTV CTM::Degen() { CBV bvX((BYTE)1, GetCountC()), bvY((BYTE)1, GetCountR()); return Degen(bvX, bvY); }