📄 syscomplexdiagnose.h
字号:
Error::TEST, __FILE__, __LINE__); } // test operator == // c3 = 5; if (!(c3 == 5)) { return Error::handle(name(), L"operator<", Error::TEST, __FILE__, __LINE__); } // test operator != // c3 = 5; if (c3 != 5) { return Error::handle(name(), L"operator<", Error::TEST, __FILE__, __LINE__); } // test operator < // if (r1 < c2) { return Error::handle(name(), L"operator<", Error::TEST, __FILE__, __LINE__); } // test operator > // if (!(r1 > c2)) { return Error::handle(name(), L"operator>", Error::TEST, __FILE__, __LINE__); } // test operator <= // if (!(c0 <= r1)) { return Error::handle(name(), L"operator<=", Error::TEST, __FILE__, __LINE__); } // test operator >= // if (!(r1 >= c2)) { return Error::handle(name(), L"operator>=", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------------- // // class-specific public methods: // arithmetic functions with two complex arguments // //--------------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put (L"testing class-specific public methods: two complex arguments...\n"); Console::increaseIndention(); } // test operator + // if (!Integral::almostEqual((c0 + c2), SysComplex<float>(4, 5.3))) { return Error::handle(name(), L"operator +", Error::TEST, __FILE__, __LINE__); } // test operator - // if (!Integral::almostEqual((c0 - c2) , SysComplex<float>(4, -1.3))) { return Error::handle(name(), L"operator -", Error::TEST, __FILE__, __LINE__); } // test operator * // if (!Integral::almostEqual((c0 * c2) , SysComplex<float>(-6.6, 13.2))) { return Error::handle(name(), L"operator *", Error::TEST, __FILE__, __LINE__); } // test operator / // if (!Integral::almostEqual(c0 / c2, SysComplex<float>(0.6061, -1.2121))) { return Error::handle(name(), L"operator /", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------------- // // class-specific public methods: // arithmetic functions with one complex and one real arg. since the // complex arg is to the left this can be a member function. // //--------------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put (L"testing class-specific public methods: complex to the left...\n"); Console::increaseIndention(); } // test operator + // if (!Integral::almostEqual((c0 + r1), SysComplex<float>(9, 2))) { return Error::handle(name(), L"operator +=", Error::TEST, __FILE__, __LINE__); } // test operator - // if (!Integral::almostEqual((c0 - r1) , SysComplex<float>(-1, 2))) { return Error::handle(name(), L"operator -", Error::TEST, __FILE__, __LINE__); } // test operator * // if (!Integral::almostEqual((c0 * r1) , SysComplex<float>(20, 10))) { return Error::handle(name(), L"operator *", Error::TEST, __FILE__, __LINE__); } // test operator / // if (!Integral::almostEqual((c0 / c1), SysComplex<float>(0.8, 0.4))) { return Error::handle(name(), L"operator /", Error::TEST, __FILE__, __LINE__); } // test inverse // if (!Integral::almostEqual(c0.inverse(), SysComplex<float>(0.2, -0.1))) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------------- // // class-specific public methods: // miscellaneous complex methods // //-------------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing class-specific public methods: miscellaneous...\n"); Console::increaseIndention(); } // test conjugate // if (!Integral::almostEqual(c0.conjugate(), SysComplex<float>(4, -2))) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // test polar // if (!Integral::almostEqual(c0.polar(4.472, 0.436) , SysComplex<float>(4.05, 1.887))) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------------- // // class-specific *public methods*: // arithmetic functions with one complex and one real arg. since the // complex arg is to the right these cannot be member functions. // //--------------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put (L"testing class-specific public methods: complex to the right...\n"); Console::increaseIndention(); } // test operator + // if (!Integral::almostEqual((r1 + c2), SysComplex<float>(5, 3.3))) { return Error::handle(name(), L"operator +=", Error::TEST, __FILE__, __LINE__); } // test operator - // if (!Integral::almostEqual((r1 - c2) , SysComplex<float>(5, -3.3))) { return Error::handle(name(), L"operator -", Error::TEST, __FILE__, __LINE__); } // test operator * // if (!Integral::almostEqual((r1 * c2) , SysComplex<float>(0, 16.5))) { return Error::handle(name(), L"operator *", Error::TEST, __FILE__, __LINE__); } // test operator / // if (!Integral::almostEqual(r1 / c2, SysComplex<float>(0, -1.5152))) { return Error::handle(name(), L"operator /", Error::TEST, __FILE__, __LINE__); } // test operator - (negation) // if (!Integral::almostEqual(-c2, SysComplex<float>(0, -3.3))) { return Error::handle(name(), L"operator -", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------------- // // class-specific *public methods*: // relational functions with TIntegral and complex types. since the // complex arg is to the right these cannot be member functions. // //--------------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::increaseIndention(); } // test operator > // if (!(r1 > c2)) { return Error::handle(name(), L"operator>", Error::TEST, __FILE__, __LINE__); } // test operator < // if (r1 < c2) { return Error::handle(name(), L"operator<", Error::TEST, __FILE__, __LINE__); } // test operator >= // if (!(r1 >= c2)) { return Error::handle(name(), L"operator>=", Error::TEST, __FILE__, __LINE__); } // test operator <= // if (r1 <= c2) { return Error::handle(name(), L"operator<=", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); Console::decreaseIndention(); } // exit gracefully // return true;}// method: diagnose1//// arguments:// Integral::DEBUG level: (input) debug level for diagnostics//// return: a boolean value indicating status//// this method performs diagnostics for the type "double"//template<class TObject>boolean SysComplexDiagnose<TObject>::diagnose1(Integral::DEBUG level_a) { //---------------------------------------------------------------------- // // preliminaries // //---------------------------------------------------------------------- // output the class name // if (level_a > Integral::NONE) { SysString output(L"diagnosing class "); output.concat(CLASS_NAME); output.concat(L" for the type double: "); Console::put(output); Console::increaseIndention(); } //--------------------------------------------------------------------- // // required public methods: // //--------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put (L"testing class-specific public methods: required methods...\n"); Console::increaseIndention(); } // test constructor // const SysComplex<double> c8(4.0, 2.0); const SysComplex<double> c9(5); const SysComplex<double> c10(0, 3.3); SysComplex<double> t(9.9,11.0); double r1 = 5; // test copy constructor // SysComplex<double> c11(c8); if (!Integral::almostEqual(c11, c8)) { return Error::handle(name(), L"copy constructor", Error::TEST, __FILE__, __LINE__); } // test operator = (assignment) // c11 = c10; if (!Integral::almostEqual(c11, c10)) { return Error::handle(name(), L"operator =", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------- // // class-specific public methods:other constructors, assignment, // casting, and component extraction methods // //--------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put (L"testing class-specific public methods: assignment, casting...\n"); Console::increaseIndention(); } // test assign // c11.assign(5, 6); if (!Integral::almostEqual(c11, SysComplex<double>(5, 6))) { return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__); } // test operator = (assignment) // c11 = t; if (!Integral::almostEqual(c11, t)) { return Error::handle(name(), L"operator=", Error::TEST, __FILE__, __LINE__); } // test cast operator // if (!Integral::almostEqual(SysComplex<long>(c8) , SysComplex<long>(4, 2))) { return Error::handle(name(), L"cast operator", Error::TEST, __FILE__, __LINE__); } // test real // if (!Integral::almostEqual(c11.real(), t.real())) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // test imag // if (!Integral::almostEqual(c10.imag(), 3.3)) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // test mag // if (!Integral::almostEqual(c8.mag(), 4.4721)) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // test angle // if (!Integral::almostEqual(c8.angle(), 0.4636)) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------------- // // class-specific public methods: // accumulative arithmetic functions with SysComplex and TIntegral types // //--------------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing class-specific public methods: accumulative...\n"); Console::increaseIndention(); } // test operator += // c11 = c10; c11 += c8; if (!Integral::almostEqual(c11 , SysComplex<double>(4, 5.3))) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // test operator -= // c11 = c10; c11 -= c8; if (!Integral::almostEqual(c11 , SysComplex<double>(-4, 1.3))) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // test operator *= // c11 = c10; c11 *= c8; if (!Integral::almostEqual(c11 , SysComplex<double>(-6.6, 13.2))) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // test operator /= // if (!Integral::almostEqual(c8 / c10, SysComplex<double>(0.6061, -1.2121))) { return Error::handle(name(), L"operator /", Error::TEST, __FILE__, __LINE__); } // test operator += // c11 = c10; c11 += 2; if (!Integral::almostEqual(c11 , SysComplex<double>(2, 3.3))) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // test operator -= // c11 = c10; c11 -= 2; if (!Integral::almostEqual(c11 , SysComplex<double>(-2, 3.3))) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // test operator *= // c11 = c10; c11 *= 2; if (!Integral::almostEqual(c11 , SysComplex<double>(0, 6.6))) { return Error::handle(name(), L"almostEqual", Error::TEST, __FILE__, __LINE__); } // test operator /= // c11 = c10;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -