int _tmain(int argc, _TCHAR* argv[]) { //Create Matrices of different types and print them cv::Mat m1(4, 5, CV_8UC1, cv::Scalar(23)); printMat1D(m1); cv::Mat m2(3, 2, CV_8SC1, cv::Scalar(-27)); printMat1D(m2); cv::Mat m3(5, 3, CV_16UC1, cv::Scalar(1939)); printMat1D(m3); cv::Mat m4(2, 4, CV_16SC1, cv::Scalar(-1961)); printMat1D(m4); cv::Mat m5(5, 3, CV_32SC1, cv::Scalar(23985)); printMat1D(m5); cv::Mat m6(2, 4, CV_32FC1, cv::Scalar(2011.02)); printMat1D(m6); cv::Mat m7(2, 4, CV_64FC1, cv::Scalar(242012.36)); printMat1D(m7); std::getchar(); return 0; }
TEST(Matrix, shouldCompare) { Matrix m1(1,1,1); Matrix m2(1,1,1); Matrix m3(2,1,1); Matrix m4(1,2,1); Matrix m5(1,1,2); CHECK(m1 == m1); CHECK(m1 == m2); CHECK(m2 == m1); CHECK(!(m1 == m3)); CHECK(!(m1 == m4)); CHECK(!(m5 == m1)); CHECK(m5 != m1); float v6[] = { 1, 1, 1, 1 }; Matrix m6(2,2); m6.setAll(v6); float v7[] = { 1, 1, 1, 1 }; Matrix m7(2,2); m7.setAll(v7); float v8[] = { 1, 1, 1, 2 }; Matrix m8(2,2); m8.setAll(v8); CHECK(m7 == m6); CHECK(!(m8 == m6)); CHECK(m6 != m8); CHECK(m1 != m6); CHECK(m6 != m1); }
void testIMat4Vector4Product() { glam::Matrix<int, 4, 4> m6(std::make_pair(M6, &M6[16])); glam::Vector<int, 4> v6(std::make_pair(V6, &V6[4])); glam::Vector<int, 4> p6 = m6 * v6; TS_ASSERT_EQUALS(p6[0], P6[0]); TS_ASSERT_EQUALS(p6[1], P6[1]); TS_ASSERT_EQUALS(p6[2], P6[2]); TS_ASSERT_EQUALS(p6[3], P6[3]); }
void funclike(void) { #define stringify(x) #x expect_string("5", stringify(5)); expect_string("x", stringify(x)); expect_string("x y", stringify(x y)); expect_string("x y", stringify( x y )); expect_string("x + y", stringify( x + y )); expect_string("x + y", stringify(/**/x/**/+/**//**/ /**/y/**/)); expect_string("x+y", stringify( x+y )); expect_string("'a'", stringify('a')); expect_string("'\\''", stringify('\'')); expect_string("\"abc\"", stringify("abc")); expect_string("ZERO", stringify(ZERO)); #define m1(x) x expect(5, m1(5)); expect(7, m1((5 + 2))); expect(8, m1(plus(5, 3))); expect(10, m1() 10); expect(14, m1(2 + 2 +) 10); #define m2(x) x + x expect(10, m2(5)); #define m3(x, y) x * y expect(50, m3(5, 10)); expect(11, m3(2 + 2, 3 + 3)); #define m4(x, y) x + y + TWO expect(17, m4(5, 10)); #define m6(x, ...) x + __VA_ARGS__ expect(20, m6(2, 18)); expect(25, plus(m6(2, 18, 5))); #define plus(x, y) x * y + plus(x, y) expect(11, plus(2, 3)); #undef plus #define plus(x, y) minus(x, y) #define minus(x, y) plus(x, y) expect(31, plus(30, 1)); expect(29, minus(30, 1)); // This is not a function-like macro. #define m7 (0) + 1 expect(1, m7); #define m8(x, y) x ## y expect(2, m8(TW, O)); expect(0, m8(ZERO,)); #define m9(x, y, z) x y + z expect(8, m9(1,, 7)); #define m10(x) x ## x expect_string("a", "a" m10()); #define hash_hash # ## # #define mkstr(a) # a #define in_between(a) mkstr(a) #define join(c, d) in_between(c hash_hash d) expect_string("x ## y", join(x, y)); int m14 = 67; #define m14(x) x expect(67, m14); expect(67, m14(m14)); int a = 68; #define glue(x, y) x ## y glue(a+, +); expect(69, a); #define identity(x) stringify(x) expect_string("aa A B aa C", identity(m10(a) A B m10(a) C)); #define identity2(x) stringify(z ## x) expect_string("zA aa A B aa C", identity2(A m10(a) A B m10(a) C)); #define m15(x) x x expect_string("a a", identity(m15(a))); #define m16(x) (x,x) expect_string("(a,a)", identity(m16(a))); }
/*int testMat3Implementation() { int nrOfErrors = 0; std::cout << "Testing mat3 class" << std::endl; float a1[] = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f}; float a2[] = {3.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 1.0f}; float a3[] = {4.0f, 0.0f, 0.0f, 0.0f, 4.0f, 0.0f, 1.0f, 1.0f, 2.0f}; egc::mat3 m1(a1), m2(a2), m3(a3), m4; m4 = m1 + m2; if(m4 == m3) std::cout << "\tCorrect + operation" << std::endl; else { std::cout << "\tIncorrect + operation" << std::endl; nrOfErrors++; } float a5[] = {3.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 3.0f, 3.0f, 3.0f}; egc::mat3 m5(a5); m4 = m1 * 3.0f; if(m4 == m5) std::cout << "\tCorrect * (with scalar value) operation" << std::endl; else { std::cout << "\tIncorrect * (with scalar value) operation" << std::endl; nrOfErrors++; } float a6[] = {3.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 1.0f, 1.0f, 1.0f}; egc::mat3 m6(a6); m4 = m1 * m2; if(m4 == m6) std::cout << "\tCorrect * (with another matrix) operation" << std::endl; else { std::cout << "\tIncorrect * (with another matrix) operation" << std::endl; nrOfErrors++; } egc::vec3 v1(1.0f, 1.0f, 1.0f); egc::vec3 v2(4.0f, 4.0f, 1.0f); egc::vec3 v3; v3 = m4 * v1; if(v3 == v2) std::cout << "\tCorrect * (with a vec3) operation" << std::endl; else { std::cout << "\tIncorrect * (with a vec3) operation" << std::endl; nrOfErrors++; } float a7[] = {-4.0f, 0.0f, 1.0f, -3.0f, 2.0f, 4.0f, 3.0f, -2.0f, -1.0f}; egc::mat3 m7(a7); if(std::abs(m7.determinant() + 24.0f) < std::numeric_limits<float>::epsilon()) std::cout << "\tCorrect determinant operation" << std::endl; else { std::cout << "\tIncorrect determinant operation" << std::endl; nrOfErrors++; } float a8[] = {-4.0f, -3.0f, 3.0f, 0.0f, 2.0f, -2.0f, 1.0f, 4.0f, -1.0f}; egc::mat3 m8(a8); if(m7.transpose() == m8) std::cout << "\tCorrect transpose operation" << std::endl; else { std::cout << "\tIncorrect transpose operation" << std::endl; nrOfErrors++; } float a9[] = {-1.0f/4.0f, 1.0f/12.0f, 1.0f/12.0f, -3.0f/8.0f, -1.0f/24.0f, -13.00f/24.0f, 0.0f, 1.0f/3.0f, 1.0f/3.0f}; egc::mat3 m9(a9); if(m7.inverse() == m9) std::cout << "\tCorrect inverse operation" << std::endl; else { std::cout << "\tIncorrect inverse operation" << std::endl; nrOfErrors++; } return nrOfErrors; } */ int testMat4Implementation() { int nrOfErrors = 0; std::cout << "Testing mat4 class" << std::endl; float a1[] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f}; float a2[] = {3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; float a3[] = {4.0f, 0.0f, 0.0f, 0.0f, 0.0f, 4.0f, 0.0f, 0.0f, 0.0f, 0.0f, 4.0f, 0.0f, 1.0f, 1.0f, 1.0f, 2.0f}; egc::mat4 m1(a1), m2(a2), m3(a3), m4; m4 = m1 + m2; if(m4 == m3) std::cout << "\tCorrect + operation" << std::endl; else { std::cout << "\tIncorrect + operation" << std::endl; nrOfErrors++; } float a5[] = {3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 3.0f, 3.0f, 3.0f, 3.0f}; egc::mat4 m5(a5); m4 = m1 * 3.0f; if(m4 == m5) std::cout << "\tCorrect * (with scalar value) operation" << std::endl; else { std::cout << "\tIncorrect * (with scalar value) operation" << std::endl; nrOfErrors++; } float a6[] = {3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f}; egc::mat4 m6(a6); m4 = m1 * m2; if(m4 == m6) std::cout << "\tCorrect * (with another matrix) operation" << std::endl; else { std::cout << "\tIncorrect * (with another matrix) operation" << std::endl; nrOfErrors++; } egc::vec4 v1(1.0f, 1.0f, 1.0f, 1.0f); egc::vec4 v2(4.0f, 4.0f, 4.0f, 1.0f); egc::vec4 v3; v3 = m4 * v1; if(v3 == v2) std::cout << "\tCorrect * (with a vec4) operation" << std::endl; else { std::cout << "\tIncorrect * (with a vec4) operation" << std::endl; nrOfErrors++; } float a7[] = {3.0f, 4.0f, 3.0f, 9.0f, 2.0f, 0.0f, 0.0f, 2.0f, 0.0f, 1.0f, 2.0f, 3.0f, 1.0f, 2.0f, 1.0f, 1.0f}; egc::mat4 m7(a7); if(std::abs(m7.determinant() - 24.0f) < std::numeric_limits<float>::epsilon()) std::cout << "\tCorrect determinant operation" << std::endl; else { std::cout << "\tIncorrect determinant operation" << std::endl; nrOfErrors++; } float a8[] = {3.0f, 2.0f, 0.0f, 1.0f, 4.0f, 0.0f, 1.0f, 2.0f, 3.0f, 0.0f, 2.0f, 1.0f, 9.0f, 2.0f, 3.0f, 1.0f}; egc::mat4 m8(a8); if(m7.transpose() == m8) std::cout << "\tCorrect transpose operation" << std::endl; else { std::cout << "\tIncorrect transpose operation" << std::endl; nrOfErrors++; } float a9[] = {-1.0f/4.0f, 2.0f/3.0f, 1.0f/6.0f, 5.0f/12.0f, 1.0f/4.0f, -1.0f/2.0f, -1.0/2.0f, 1.0f/4.0f, -1.0f/2.0f, 1.0f/2.0f, 1.0f, 1.0f/2.0f, 1.0f/4.0f, -1.0f/6.0f, -1.0/6.0f, -5.0f/12.0f}; egc::mat4 m9(a9); if(m7.inverse() == m9) std::cout << "\tCorrect inverse operation" << std::endl; else { std::cout << "\tIncorrect inverse operation" << std::endl; nrOfErrors++; } return nrOfErrors; }
void MatrixTest::test_constructor(void) { message += "test_constructor\n"; std::string file_name = "../data/matrix.dat"; // Default Matrix<size_t> m1; assert_true(m1.get_rows_number() == 0, LOG); assert_true(m1.get_columns_number() == 0, LOG); // Rows and columns numbers Matrix<size_t> m2(0, 0); assert_true(m2.get_rows_number() == 0, LOG); assert_true(m2.get_columns_number() == 0, LOG); Matrix<double> m3(1, 1, 1.0); assert_true(m3.get_rows_number() == 1, LOG); assert_true(m3.get_columns_number() == 1, LOG); // Rows and columns numbers and initialization Matrix<size_t> m4(0, 0, 1); assert_true(m4.get_rows_number() == 0, LOG); assert_true(m4.get_columns_number() == 0, LOG); Matrix<size_t> m5(1, 1, 1); assert_true(m5.get_rows_number() == 1, LOG); assert_true(m5.get_columns_number() == 1, LOG); assert_true(m5 == true, LOG); // File constructor m1.save(file_name); Matrix<size_t> m6(file_name); assert_true(m6.get_rows_number() == 0, LOG); assert_true(m6.get_columns_number() == 0, LOG); m2.save(file_name); Matrix<size_t> m7(file_name); assert_true(m7.get_rows_number() == 0, LOG); assert_true(m7.get_columns_number() == 0, LOG); m3.save(file_name); Matrix<double> m8(file_name); assert_true(m8.get_rows_number() == 1, LOG); assert_true(m8.get_columns_number() == 1, LOG); m4.save(file_name); Matrix<size_t> m9(file_name); assert_true(m9.get_rows_number() == 0, LOG); assert_true(m9.get_columns_number() == 0, LOG); m5.save(file_name); Matrix<size_t> m10(file_name); assert_true(m10.get_rows_number() == 1, LOG); assert_true(m10.get_columns_number() == 1, LOG); assert_true(m10 == true, LOG); // Copy constructor Matrix<double> a5; Matrix<double> b5(a5); assert_true(b5.get_rows_number() == 0, LOG); assert_true(b5.get_columns_number() == 0, LOG); Matrix<size_t> a6(1, 1, true); Matrix<size_t> b6(a6); assert_true(b6.get_rows_number() == 1, LOG); assert_true(b6.get_columns_number() == 1, LOG); assert_true(b6 == true, LOG); // Operator ++ Matrix<size_t> m11(2, 2, 0); m11(0,0)++; m11(1,1)++; assert_true(m11(0,0) == 1, LOG); assert_true(m11(0,1) == 0, LOG); assert_true(m11(1,0) == 0, LOG); assert_true(m11(1,1) == 1, LOG); }
template<typename SparseMatrixType> void sparse_product() { typedef typename SparseMatrixType::Index Index; Index n = 100; const Index rows = internal::random<int>(1,n); const Index cols = internal::random<int>(1,n); const Index depth = internal::random<int>(1,n); typedef typename SparseMatrixType::Scalar Scalar; enum { Flags = SparseMatrixType::Flags }; double density = (std::max)(8./(rows*cols), 0.1); typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix; typedef Matrix<Scalar,Dynamic,1> DenseVector; Scalar s1 = internal::random<Scalar>(); Scalar s2 = internal::random<Scalar>(); // test matrix-matrix product { DenseMatrix refMat2 = DenseMatrix::Zero(rows, depth); DenseMatrix refMat2t = DenseMatrix::Zero(depth, rows); DenseMatrix refMat3 = DenseMatrix::Zero(depth, cols); DenseMatrix refMat3t = DenseMatrix::Zero(cols, depth); DenseMatrix refMat4 = DenseMatrix::Zero(rows, cols); DenseMatrix refMat4t = DenseMatrix::Zero(cols, rows); DenseMatrix refMat5 = DenseMatrix::Random(depth, cols); DenseMatrix refMat6 = DenseMatrix::Random(rows, rows); DenseMatrix dm4 = DenseMatrix::Zero(rows, rows); // DenseVector dv1 = DenseVector::Random(rows); SparseMatrixType m2 (rows, depth); SparseMatrixType m2t(depth, rows); SparseMatrixType m3 (depth, cols); SparseMatrixType m3t(cols, depth); SparseMatrixType m4 (rows, cols); SparseMatrixType m4t(cols, rows); SparseMatrixType m6(rows, rows); initSparse(density, refMat2, m2); initSparse(density, refMat2t, m2t); initSparse(density, refMat3, m3); initSparse(density, refMat3t, m3t); initSparse(density, refMat4, m4); initSparse(density, refMat4t, m4t); initSparse(density, refMat6, m6); // int c = internal::random<int>(0,depth-1); // sparse * sparse VERIFY_IS_APPROX(m4=m2*m3, refMat4=refMat2*refMat3); VERIFY_IS_APPROX(m4=m2t.transpose()*m3, refMat4=refMat2t.transpose()*refMat3); VERIFY_IS_APPROX(m4=m2t.transpose()*m3t.transpose(), refMat4=refMat2t.transpose()*refMat3t.transpose()); VERIFY_IS_APPROX(m4=m2*m3t.transpose(), refMat4=refMat2*refMat3t.transpose()); VERIFY_IS_APPROX(m4 = m2*m3/s1, refMat4 = refMat2*refMat3/s1); VERIFY_IS_APPROX(m4 = m2*m3*s1, refMat4 = refMat2*refMat3*s1); VERIFY_IS_APPROX(m4 = s2*m2*m3*s1, refMat4 = s2*refMat2*refMat3*s1); VERIFY_IS_APPROX(m4=(m2*m3).pruned(0), refMat4=refMat2*refMat3); VERIFY_IS_APPROX(m4=(m2t.transpose()*m3).pruned(0), refMat4=refMat2t.transpose()*refMat3); VERIFY_IS_APPROX(m4=(m2t.transpose()*m3t.transpose()).pruned(0), refMat4=refMat2t.transpose()*refMat3t.transpose()); VERIFY_IS_APPROX(m4=(m2*m3t.transpose()).pruned(0), refMat4=refMat2*refMat3t.transpose()); // test aliasing m4 = m2; refMat4 = refMat2; VERIFY_IS_APPROX(m4=m4*m3, refMat4=refMat4*refMat3); // sparse * dense VERIFY_IS_APPROX(dm4=m2*refMat3, refMat4=refMat2*refMat3); VERIFY_IS_APPROX(dm4=m2*refMat3t.transpose(), refMat4=refMat2*refMat3t.transpose()); VERIFY_IS_APPROX(dm4=m2t.transpose()*refMat3, refMat4=refMat2t.transpose()*refMat3); VERIFY_IS_APPROX(dm4=m2t.transpose()*refMat3t.transpose(), refMat4=refMat2t.transpose()*refMat3t.transpose()); VERIFY_IS_APPROX(dm4=m2*(refMat3+refMat3), refMat4=refMat2*(refMat3+refMat3)); VERIFY_IS_APPROX(dm4=m2t.transpose()*(refMat3+refMat5)*0.5, refMat4=refMat2t.transpose()*(refMat3+refMat5)*0.5); // dense * sparse VERIFY_IS_APPROX(dm4=refMat2*m3, refMat4=refMat2*refMat3); VERIFY_IS_APPROX(dm4=refMat2*m3t.transpose(), refMat4=refMat2*refMat3t.transpose()); VERIFY_IS_APPROX(dm4=refMat2t.transpose()*m3, refMat4=refMat2t.transpose()*refMat3); VERIFY_IS_APPROX(dm4=refMat2t.transpose()*m3t.transpose(), refMat4=refMat2t.transpose()*refMat3t.transpose()); // sparse * dense and dense * sparse outer product test_outer<SparseMatrixType,DenseMatrix>::run(m2,m4,refMat2,refMat4); VERIFY_IS_APPROX(m6=m6*m6, refMat6=refMat6*refMat6); } // test matrix - diagonal product { DenseMatrix refM2 = DenseMatrix::Zero(rows, cols); DenseMatrix refM3 = DenseMatrix::Zero(rows, cols); DenseMatrix d3 = DenseMatrix::Zero(rows, cols); DiagonalMatrix<Scalar,Dynamic> d1(DenseVector::Random(cols)); DiagonalMatrix<Scalar,Dynamic> d2(DenseVector::Random(rows)); SparseMatrixType m2(rows, cols); SparseMatrixType m3(rows, cols); initSparse<Scalar>(density, refM2, m2); initSparse<Scalar>(density, refM3, m3); VERIFY_IS_APPROX(m3=m2*d1, refM3=refM2*d1); VERIFY_IS_APPROX(m3=m2.transpose()*d2, refM3=refM2.transpose()*d2); VERIFY_IS_APPROX(m3=d2*m2, refM3=d2*refM2); VERIFY_IS_APPROX(m3=d1*m2.transpose(), refM3=d1*refM2.transpose()); // evaluate to a dense matrix to check the .row() and .col() iterator functions VERIFY_IS_APPROX(d3=m2*d1, refM3=refM2*d1); VERIFY_IS_APPROX(d3=m2.transpose()*d2, refM3=refM2.transpose()*d2); VERIFY_IS_APPROX(d3=d2*m2, refM3=d2*refM2); VERIFY_IS_APPROX(d3=d1*m2.transpose(), refM3=d1*refM2.transpose()); } // test self adjoint products { DenseMatrix b = DenseMatrix::Random(rows, rows); DenseMatrix x = DenseMatrix::Random(rows, rows); DenseMatrix refX = DenseMatrix::Random(rows, rows); DenseMatrix refUp = DenseMatrix::Zero(rows, rows); DenseMatrix refLo = DenseMatrix::Zero(rows, rows); DenseMatrix refS = DenseMatrix::Zero(rows, rows); SparseMatrixType mUp(rows, rows); SparseMatrixType mLo(rows, rows); SparseMatrixType mS(rows, rows); do { initSparse<Scalar>(density, refUp, mUp, ForceRealDiag|/*ForceNonZeroDiag|*/MakeUpperTriangular); } while (refUp.isZero()); refLo = refUp.adjoint(); mLo = mUp.adjoint(); refS = refUp + refLo; refS.diagonal() *= 0.5; mS = mUp + mLo; // TODO be able to address the diagonal.... for (int k=0; k<mS.outerSize(); ++k) for (typename SparseMatrixType::InnerIterator it(mS,k); it; ++it) if (it.index() == k) it.valueRef() *= 0.5; VERIFY_IS_APPROX(refS.adjoint(), refS); VERIFY_IS_APPROX(mS.adjoint(), mS); VERIFY_IS_APPROX(mS, refS); VERIFY_IS_APPROX(x=mS*b, refX=refS*b); VERIFY_IS_APPROX(x=mUp.template selfadjointView<Upper>()*b, refX=refS*b); VERIFY_IS_APPROX(x=mLo.template selfadjointView<Lower>()*b, refX=refS*b); VERIFY_IS_APPROX(x=mS.template selfadjointView<Upper|Lower>()*b, refX=refS*b); } }
void wisaConfirmSubmit::onShow() { // overwrite buttons previousButton->setStyleClass("btn btn-success"); previousButton->setText("Toch maar niet"); nextButton->setStyleClass("btn btn-danger"); nextButton->setText("Wijzig Database"); // count accounts in wisa file container<wisaImport::wisaAccount> & wisaAccounts = parentObject->getWisaAccounts(); string m1("Nieuw bestand bevat "); m1 += wisaAccounts.elms(); m1 += " accounts."; message1->setText(m1.wt()); // load all accounts ACCOUNTS & accounts = parentObject->ldap()->getAccounts(); int validAccounts = accounts.elms(); int linkedAccounts = 0; int accountsToRemove = 0; for(int i = 0; i < accounts.elms(); i++) { if(accounts[i].getImportStatus() == WI_DISCARD) { validAccounts--; if(accounts[i].flaggedForRemoval()) accountsToRemove++; } } for(int i = 0; i < wisaAccounts.elms(); i++) { if(wisaAccounts[i].link != nullptr) { linkedAccounts++; } } int newAccounts = wisaAccounts.elms() - linkedAccounts; string m2("De database bevat "); m2 += validAccounts; m2 += " accounts."; message2->setText(m2.wt()); string m3("Er bestaat een geldige link voor "); m3 += linkedAccounts; m3 += " accounts."; message3->setText(m3.wt()); string m4; m4 += accountsToRemove; m4 += " accounts worden verwijderd."; message4->setText(m4.wt()); string m5; m5 += newAccounts; m5 += " accounts worden toegevoegd."; message5->setText(m5.wt()); // count groups in wisa file container<wisaImport::wisaClass> & wisaClasses = parentObject->getWisaClasses(); string m6("Nieuw bestand bevat "); m6 += wisaClasses.elms(); m6 += " klassen."; message6->setText(m6.wt()); // load all accounts GROUPS & groups = parentObject->ldap()->getGroups(); int validGroups = groups.elms(); int linkedGroups = 0; int groupsToRemove = 0; for(int i = 0; i < groups.elms(); i++) { if(groups[i].getImportStatus() == WI_DISCARD) { validGroups--; } else { if(groups[i].flaggedForRemoval()) groupsToRemove++; } } for(int i = 0; i < wisaClasses.elms(); i++) { if(wisaClasses[i].link != nullptr) { linkedGroups++; } } int newGroups = wisaClasses.elms() - linkedGroups; string m7("De database bevat "); m7 += validGroups; m7 += " klassen."; message7->setText(m7.wt()); string m8("Er bestaat een geldige link voor "); m8 += linkedGroups; m8 += " klassen."; message8->setText(m8.wt()); string m9; m9 += groupsToRemove; m9 += " klassen worden verwijderd."; message9->setText(m9.wt()); string m10; m10 += newGroups; m10 += " klassen worden toegevoegd."; message10->setText(m10.wt()); }
int main() try { // Several ways to create and initialize band matrices: // Create with uninitialized values tmv::BandMatrix<double> m1(6,6,1,2); for(int i=0;i<m1.nrows();i++) for(int j=0;j<m1.ncols();j++) if (i<=j+m1.nlo() && j<=i+m1.nhi()) m1(i,j) = 3.*i-j*j+7.; std::cout<<"m1 =\n"<<m1; //! m1 = //! 6 6 //! ( 7 6 3 0 0 0 ) //! ( 10 9 6 1 0 0 ) //! ( 0 12 9 4 -3 0 ) //! ( 0 0 12 7 0 -9 ) //! ( 0 0 0 10 3 -6 ) //! ( 0 0 0 0 6 -3 ) // Create with all 2's. tmv::BandMatrix<double> m2(6,6,1,3,2.); std::cout<<"m2 =\n"<<m2; //! m2 = //! 6 6 //! ( 2 2 2 2 0 0 ) //! ( 2 2 2 2 2 0 ) //! ( 0 2 2 2 2 2 ) //! ( 0 0 2 2 2 2 ) //! ( 0 0 0 2 2 2 ) //! ( 0 0 0 0 2 2 ) // A BandMatrix can be non-square: tmv::BandMatrix<double> m3(6,8,1,3,2.); std::cout<<"m3 =\n"<<m3; //! m3 = //! 6 8 //! ( 2 2 2 2 0 0 0 0 ) //! ( 2 2 2 2 2 0 0 0 ) //! ( 0 2 2 2 2 2 0 0 ) //! ( 0 0 2 2 2 2 2 0 ) //! ( 0 0 0 2 2 2 2 2 ) //! ( 0 0 0 0 2 2 2 2 ) // Create from given elements: double mm[20] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; tmv::BandMatrix<double,tmv::ColMajor> m4(6,6,2,1); std::copy(mm,mm+20,m4.colmajor_begin()); std::cout<<"m4 (ColMajor) =\n"<<m4; //! m4 (ColMajor) = //! 6 6 //! ( 1 4 0 0 0 0 ) //! ( 2 5 8 0 0 0 ) //! ( 3 6 9 12 0 0 ) //! ( 0 7 10 13 16 0 ) //! ( 0 0 11 14 17 19 ) //! ( 0 0 0 15 18 20 ) tmv::BandMatrix<double,tmv::RowMajor> m5(6,6,2,1); std::copy(mm,mm+20,m5.rowmajor_begin()); std::cout<<"m5 (RowMajor) =\n"<<m5; //! m5 (RowMajor) = //! 6 6 //! ( 1 2 0 0 0 0 ) //! ( 3 4 5 0 0 0 ) //! ( 6 7 8 9 0 0 ) //! ( 0 10 11 12 13 0 ) //! ( 0 0 14 15 16 17 ) //! ( 0 0 0 18 19 20 ) tmv::BandMatrix<double,tmv::DiagMajor> m6(6,6,2,1); std::copy(mm,mm+20,m6.diagmajor_begin()); std::cout<<"m6 (DiagMajor) =\n"<<m6; //! m6 (DiagMajor) = //! 6 6 //! ( 10 16 0 0 0 0 ) //! ( 5 11 17 0 0 0 ) //! ( 1 6 12 18 0 0 ) //! ( 0 2 7 13 19 0 ) //! ( 0 0 3 8 14 20 ) //! ( 0 0 0 4 9 15 ) // Can make from the banded portion of a regular Matrix: tmv::Matrix<double> xm(6,6); for(int i=0;i<xm.nrows();i++) for(int j=0;j<xm.ncols();j++) xm(i,j) = 5.*i-j*j+3.; tmv::BandMatrix<double> m7(xm,3,2); std::cout<<"m7 =\n"<<m7; //! m7 = //! 6 6 //! ( 3 2 -1 0 0 0 ) //! ( 8 7 4 -1 0 0 ) //! ( 13 12 9 4 -3 0 ) //! ( 18 17 14 9 2 -7 ) //! ( 0 22 19 14 7 -2 ) //! ( 0 0 24 19 12 3 ) // Or from a wider BandMatrix: tmv::BandMatrix<double> m8(m7,3,0); std::cout<<"m8 =\n"<<m8; //! m8 = //! 6 6 //! ( 3 0 0 0 0 0 ) //! ( 8 7 0 0 0 0 ) //! ( 13 12 9 0 0 0 ) //! ( 18 17 14 9 0 0 ) //! ( 0 22 19 14 7 0 ) //! ( 0 0 24 19 12 3 ) // Shortcuts to Bi- and Tri-diagonal matrices: tmv::Vector<double> v1(5,1.); tmv::Vector<double> v2(6,2.); tmv::Vector<double> v3(5,3.); tmv::BandMatrix<double> m9 = LowerBiDiagMatrix(v1,v2); tmv::BandMatrix<double> m10 = UpperBiDiagMatrix(v2,v3); tmv::BandMatrix<double> m11 = TriDiagMatrix(v1,v2,v3); std::cout<<"LowerBiDiagMatrix(v1,v2) =\n"<<m9; //! LowerBiDiagMatrix(v1,v2) = //! 6 6 //! ( 2 0 0 0 0 0 ) //! ( 1 2 0 0 0 0 ) //! ( 0 1 2 0 0 0 ) //! ( 0 0 1 2 0 0 ) //! ( 0 0 0 1 2 0 ) //! ( 0 0 0 0 1 2 ) std::cout<<"UpperBiDiagMatrix(v2,v3) =\n"<<m10; //! UpperBiDiagMatrix(v2,v3) = //! 6 6 //! ( 2 3 0 0 0 0 ) //! ( 0 2 3 0 0 0 ) //! ( 0 0 2 3 0 0 ) //! ( 0 0 0 2 3 0 ) //! ( 0 0 0 0 2 3 ) //! ( 0 0 0 0 0 2 ) std::cout<<"TriDiagMatrix(v1,v2,v3) =\n"<<m11; //! TriDiagMatrix(v1,v2,v3) = //! 6 6 //! ( 2 3 0 0 0 0 ) //! ( 1 2 3 0 0 0 ) //! ( 0 1 2 3 0 0 ) //! ( 0 0 1 2 3 0 ) //! ( 0 0 0 1 2 3 ) //! ( 0 0 0 0 1 2 ) // Norms, etc. std::cout<<"Norm1(m1) = "<<Norm1(m1)<<std::endl; //! Norm1(m1) = 30 std::cout<<"Norm2(m1) = "<<Norm2(m1)<<std::endl; //! Norm2(m1) = 24.0314 std::cout<<"NormInf(m1) = "<<NormInf(m1)<<std::endl; //! NormInf(m1) = 28 std::cout<<"NormF(m1) = "<<NormF(m1)<<" = "<<Norm(m1)<<std::endl; //! NormF(m1) = 32.0312 = 32.0312 std::cout<<"MaxAbsElement(m1) = "<<MaxAbsElement(m1)<<std::endl; //! MaxAbsElement(m1) = 12 std::cout<<"Trace(m1) = "<<Trace(m1)<<std::endl; //! Trace(m1) = 32 std::cout<<"Det(m1) = "<<Det(m1)<<std::endl; //! Det(m1) = 67635 // Views: std::cout<<"m1 =\n"<<m1; //! m1 = //! 6 6 //! ( 7 6 3 0 0 0 ) //! ( 10 9 6 1 0 0 ) //! ( 0 12 9 4 -3 0 ) //! ( 0 0 12 7 0 -9 ) //! ( 0 0 0 10 3 -6 ) //! ( 0 0 0 0 6 -3 ) std::cout<<"m1.diag() = "<<m1.diag()<<std::endl; //! m1.diag() = 6 ( 7 9 9 7 3 -3 ) std::cout<<"m1.diag(1) = "<<m1.diag(1)<<std::endl; //! m1.diag(1) = 5 ( 6 6 4 0 -6 ) std::cout<<"m1.diag(-1) = "<<m1.diag(-1)<<std::endl; //! m1.diag(-1) = 5 ( 10 12 12 10 6 ) std::cout<<"m1.subBandMatrix(0,3,0,3,1,1) =\n"<< m1.subBandMatrix(0,3,0,3,1,1); //! m1.subBandMatrix(0,3,0,3,1,1) = //! 3 3 //! ( 7 6 0 ) //! ( 10 9 6 ) //! ( 0 12 9 ) std::cout<<"m1.transpose() =\n"<<m1.transpose(); //! m1.transpose() = //! 6 6 //! ( 7 10 0 0 0 0 ) //! ( 6 9 12 0 0 0 ) //! ( 3 6 9 12 0 0 ) //! ( 0 1 4 7 10 0 ) //! ( 0 0 -3 0 3 6 ) //! ( 0 0 0 -9 -6 -3 ) // rowRange, colRange shrink both dimensions of the matrix to include only // the portions that are in those rows or columns: std::cout<<"m1.rowRange(0,4) =\n"<<m1.rowRange(0,4); //! m1.rowRange(0,4) = //! 4 6 //! ( 7 6 3 0 0 0 ) //! ( 10 9 6 1 0 0 ) //! ( 0 12 9 4 -3 0 ) //! ( 0 0 12 7 0 -9 ) std::cout<<"m1.colRange(1,4) =\n"<<m1.colRange(1,4); //! m1.colRange(1,4) = //! 5 3 //! ( 6 3 0 ) //! ( 9 6 1 ) //! ( 12 9 4 ) //! ( 0 12 7 ) //! ( 0 0 10 ) std::cout<<"m1.diagRange(0,2) =\n"<<m1.diagRange(0,2); //! m1.diagRange(0,2) = //! 6 6 //! ( 7 6 0 0 0 0 ) //! ( 0 9 6 0 0 0 ) //! ( 0 0 9 4 0 0 ) //! ( 0 0 0 7 0 0 ) //! ( 0 0 0 0 3 -6 ) //! ( 0 0 0 0 0 -3 ) std::cout<<"m1.diagRange(-1,1) =\n"<<m1.diagRange(-1,1); //! m1.diagRange(-1,1) = //! 6 6 //! ( 7 0 0 0 0 0 ) //! ( 10 9 0 0 0 0 ) //! ( 0 12 9 0 0 0 ) //! ( 0 0 12 7 0 0 ) //! ( 0 0 0 10 3 0 ) //! ( 0 0 0 0 6 -3 ) // Fortran Indexing: tmv::BandMatrix<double,tmv::FortranStyle> fm1 = m1; std::cout<<"fm1 = m1 =\n"<<fm1; //! fm1 = m1 = //! 6 6 //! ( 7 6 3 0 0 0 ) //! ( 10 9 6 1 0 0 ) //! ( 0 12 9 4 -3 0 ) //! ( 0 0 12 7 0 -9 ) //! ( 0 0 0 10 3 -6 ) //! ( 0 0 0 0 6 -3 ) std::cout<<"fm1(1,1) = "<<fm1(1,1)<<std::endl; //! fm1(1,1) = 7 std::cout<<"fm1(4,3) = "<<fm1(4,3)<<std::endl; //! fm1(4,3) = 12 std::cout<<"fm1.subBandMatrix(1,3,1,3,1,1) =\n"<< fm1.subBandMatrix(1,3,1,3,1,1); //! fm1.subBandMatrix(1,3,1,3,1,1) = //! 3 3 //! ( 7 6 0 ) //! ( 10 9 6 ) //! ( 0 12 9 ) std::cout<<"fm1.rowRange(1,4) =\n"<<fm1.rowRange(1,4); //! fm1.rowRange(1,4) = //! 4 6 //! ( 7 6 3 0 0 0 ) //! ( 10 9 6 1 0 0 ) //! ( 0 12 9 4 -3 0 ) //! ( 0 0 12 7 0 -9 ) std::cout<<"fm1.colRange(2,4) =\n"<<fm1.colRange(2,4); //! fm1.colRange(2,4) = //! 5 3 //! ( 6 3 0 ) //! ( 9 6 1 ) //! ( 12 9 4 ) //! ( 0 12 7 ) //! ( 0 0 10 ) std::cout<<"fm1.diagRange(0,1) =\n"<<fm1.diagRange(0,1); //! fm1.diagRange(0,1) = //! 6 6 //! ( 7 6 0 0 0 0 ) //! ( 0 9 6 0 0 0 ) //! ( 0 0 9 4 0 0 ) //! ( 0 0 0 7 0 0 ) //! ( 0 0 0 0 3 -6 ) //! ( 0 0 0 0 0 -3 ) std::cout<<"fm1.diagRange(-1,0) =\n"<<fm1.diagRange(-1,0); //! fm1.diagRange(-1,0) = //! 6 6 //! ( 7 0 0 0 0 0 ) //! ( 10 9 0 0 0 0 ) //! ( 0 12 9 0 0 0 ) //! ( 0 0 12 7 0 0 ) //! ( 0 0 0 10 3 0 ) //! ( 0 0 0 0 6 -3 ) // Matrix arithmetic: tmv::BandMatrix<double> m1pm2 = m1 + m2; std::cout<<"m1 + m2 =\n"<<m1pm2; //! m1 + m2 = //! 6 6 //! ( 9 8 5 2 0 0 ) //! ( 12 11 8 3 2 0 ) //! ( 0 14 11 6 -1 2 ) //! ( 0 0 14 9 2 -7 ) //! ( 0 0 0 12 5 -4 ) //! ( 0 0 0 0 8 -1 ) // Works correctly even if matrices are stored in different order: tmv::BandMatrix<double> m5pm6 = m5 + m6; std::cout<<"m5 + m6 =\n"<<m5pm6; //! m5 + m6 = //! 6 6 //! ( 11 18 0 0 0 0 ) //! ( 8 15 22 0 0 0 ) //! ( 7 13 20 27 0 0 ) //! ( 0 12 18 25 32 0 ) //! ( 0 0 17 23 30 37 ) //! ( 0 0 0 22 28 35 ) // Also expands the number of off-diagonals appropriately as needed: tmv::BandMatrix<double> m2pm4 = m2 + m4; std::cout<<"m2 + m4 =\n"<<m2pm4; //! m2 + m4 = //! 6 6 //! ( 3 6 2 2 0 0 ) //! ( 4 7 10 2 2 0 ) //! ( 3 8 11 14 2 2 ) //! ( 0 7 12 15 18 2 ) //! ( 0 0 11 16 19 21 ) //! ( 0 0 0 15 20 22 ) m1 *= 2.; std::cout<<"m1 *= 2 =\n"<<m1; //! m1 *= 2 = //! 6 6 //! ( 14 12 6 0 0 0 ) //! ( 20 18 12 2 0 0 ) //! ( 0 24 18 8 -6 0 ) //! ( 0 0 24 14 0 -18 ) //! ( 0 0 0 20 6 -12 ) //! ( 0 0 0 0 12 -6 ) m2 += m1; std::cout<<"m2 += m1 =\n"<<m2; //! m2 += m1 = //! 6 6 //! ( 16 14 8 2 0 0 ) //! ( 22 20 14 4 2 0 ) //! ( 0 26 20 10 -4 2 ) //! ( 0 0 26 16 2 -16 ) //! ( 0 0 0 22 8 -10 ) //! ( 0 0 0 0 14 -4 ) tmv::Vector<double> v = xm.col(0); std::cout<<"v = "<<v<<std::endl; //! v = 6 ( 3 8 13 18 23 28 ) std::cout<<"m1 * v = "<<m1*v<<std::endl; //! m1 * v = 6 ( 216 396 432 60 162 108 ) std::cout<<"v * m1 = "<<v*m1<<std::endl; //! v * m1 = 6 ( 202 492 780 832 396 -768 ) // Matrix * matrix product also expands bands appropriately: tmv::BandMatrix<double> m1m2 = m1 * m2; std::cout<<"m1 * m2 =\n"<<m1m2; //! m1 * m2 = //! 6 6 //! ( 488 592 400 136 0 12 ) //! ( 716 952 704 264 -8 -8 ) //! ( 528 948 904 272 -56 -32 ) //! ( 0 624 844 464 -320 -104 ) //! ( 0 0 520 452 -80 -332 ) //! ( 0 0 0 264 12 -96 ) // Can mix BandMatrix with other kinds of matrices: std::cout<<"xm * m1 =\n"<<xm*m1; //! xm * m1 = //! 6 6 //! ( 82 48 -120 -348 -336 396 ) //! ( 252 318 180 -128 -276 216 ) //! ( 422 588 480 92 -216 36 ) //! ( 592 858 780 312 -156 -144 ) //! ( 762 1128 1080 532 -96 -324 ) //! ( 932 1398 1380 752 -36 -504 ) tmv::UpperTriMatrix<double> um(xm); std::cout<<"um + m1 =\n"<<um+m1; //! um + m1 = //! 6 6 //! ( 17 14 5 -6 -13 -22 ) //! ( 20 25 16 1 -8 -17 ) //! ( 0 24 27 12 -9 -12 ) //! ( 0 0 24 23 2 -25 ) //! ( 0 0 0 20 13 -14 ) //! ( 0 0 0 0 12 -3 ) tmv::LowerTriMatrix<double> lm(xm); lm *= m8; std::cout<<"lm *= m8 =\n"<<lm; //! lm *= m8 = //! 6 6 //! ( 9 0 0 0 0 0 ) //! ( 80 49 0 0 0 0 ) //! ( 252 192 81 0 0 0 ) //! ( 534 440 252 81 0 0 ) //! ( 744 774 500 224 49 0 ) //! ( 954 1064 782 396 120 9 ) tmv::DiagMatrix<double> dm(xm); m1 *= dm; std::cout<<"m1 *= dm =\n"<<m1; //! m1 *= dm = //! 6 6 //! ( 42 84 54 0 0 0 ) //! ( 60 126 108 18 0 0 ) //! ( 0 168 162 72 -42 0 ) //! ( 0 0 216 126 0 -54 ) //! ( 0 0 0 180 42 -36 ) //! ( 0 0 0 0 84 -18 ) return 0; } catch (tmv::Error& e) { std::cerr<<e<<std::endl; return 1; }
static uint32_t rgb_to_color_cube(uint32_t c) { return 16 + m6(R(c))*36 + m6(G(c))*6 + m6(B(c)); }
int main(void) { struct tm *newtime; time_t ltime; time(<ime); /* Get the time in seconds */ newtime = localtime(<ime); /* Convert it to the structure tm */ char * st; // gen purpose string for bcd's st = new char[35]; // 32 digits + sign + decimal pt + '\0' ofstream dout("bcdrun.log"); bcd numa("1234567890987654.123"); // fraction will be dropped bcd numb(4321.6789); // ditto - we are using integer rules bcd numc(-24681357L); bcd numd = numa + numb; bcd e(0.0); bcd f(0L); bcd g(-0.0); bcd h(-0L); bcd w(1L); bcd x(-1.0); bcd y("-2.0"); bcd z("300."); bcd aa("99999999999999999999999999999999"); bcd bb("1"); bcd cc("10000000000000000"); bcd dd(".00000000000000001"); bcd m1(12L); bcd m2(2L); bcd m3(123456789L); bcd m4(4096L); bcd m5(748345987654321.0); bcd m6(288834570200345.0); bcd m7("8599238847786248452455563809"); bcd d1("8765432109876"); bcd d2(24687L); bcd d3(75237L); bcd d4(45263L); bcd d5 ("92732081006447"); bcd s1("1234567890987654"); dout << " Regression Log for " << asctime(newtime) << endl; dout << "significant digits test: 1 = " << w.sigD() << ", 3 = " << z.sigD() << ", 32 = " << aa.sigD() << ", 0 = " << dd.sigD() << "\n" << endl; int rc = numa.bcdToString(st); // convert numa to string no decimal point dout << "bcd to string test = " << st << "\n" << " expected: +1234567890987654" << endl; rc = numa.bcdToString(st,1); // numa to str with 1 psn to right of dec pt dout << "bcd to string test = " << st << "\n" << " expected: +123456789098765.4" << endl; rc = numa.bcdToString(st,6); // numa to str with 6 psns to rt of decimal pt dout << "bcd to string test = " << st << "\n" << " expected: +1234567890.987654" << "\n" << endl; rc = m3.bcdToString(st); // convert m3 to string no decimal point dout << "bcd to string test = " << st << "\n" << " expected: +123456789" << endl; rc = m3.bcdToString(st,1); // m3 to str with 1 psn to right of dec pt dout << "bcd to string test = " << st << "\n" << " expected: +12345678.9" << endl; rc = m3.bcdToString(st,6); // m3 to str with 6 psns to rt of decimal pt dout << "bcd to string test = " << st << "\n" << " expected: +123.456789" << "\n" << endl; rc = h.bcdToString(st); // convert h to string no decimal point dout << "bcd to string test = " << st << "\n" << " expected: +0" << endl; rc = h.bcdToString(st,1); // convert h to str with 1 psn to right of dec pt dout << "bcd to string test = " << st << "\n" << " expected: +0.0" << endl; rc = h.bcdToString(st,6); // h to str with 6 psns to rt of decimal pt dout << "bcd to string test = " << st << "\n" << " expected: +0.0" << "\n" << endl; rc = m2.bcdToString(st); // convert m2 to string no decimal point dout << "bcd to string test = " << st << "\n" << " expected: +2" << endl; rc = m2.bcdToString(st,1); // m2 to str with 1 psn to right of dec pt dout << "bcd to string test = " << st << "\n" << " expected: +0.2" << endl; rc = m2.bcdToString(st,6); // m2 to str with 6 psns to rt of decimal pt dout << "bcd to string test = " << st << "\n" << " expected: +0.000002" << "\n" << endl; s1.shl(1); dout << "shift test 1234567890987654 shifted left 1 = " << s1 << " expected = +00000000000000012345678909876540 cc: 0\n" << endl; s1.shl(2); dout << "shift test 1234567890987654 shifted left 2 = " << s1 << " expected = +00000000000001234567890987654000 cc: 0\n" << endl; s1.shl(3); dout << "shift test 1234567890987654 shifted left 3 = " << s1 << " expected = +00000000001234567890987654000000 cc: 0\n" << endl; s1.shl(13); dout << "shift test 1234567890987654 shfted left 13 = " << s1 << " expected = +00000000001234567890987654000000 cc: 16\n" << endl; s1.shr(1); dout << "shift test 1234567890987654 shifted rt 1 = " << s1 << " expected = +00000000000123456789098765400000 cc: 0\n" << endl; s1.shr(2); dout << "shift test 1234567890987654 shifted rt 2 = " << s1 << " expected = +00000000000001234567890987654000 cc: 0\n" << endl; s1.shr(5); dout << "shift test 1234567890987654 shifted rt 5 = " << s1 << " expected = +00000000000000000012345678909876 cc: 0\n" << endl; s1.shrRnd(4); dout << "shift test 12345678909876 sh rt 4 & rnd = " << s1 << " expected = +00000000000000000000001234567891 cc: 0\n" << endl; s1.shrRnd(4); dout << "shift test 12345678909876 sh rt 4 & rnd = " << s1 << " expected = +00000000000000000000000000123457 cc: 0\n" << endl; s1.shrRnd(5); dout << "shift test 12345678909876 sh rt 5 & rnd = " << s1 << " expected = +00000000000000000000000000000001 cc: 0\n" << endl; s1.shl(31); dout << "shift test 12345678909876 sh lt 31 = " << s1 << " expected = +10000000000000000000000000000000 cc: 0\n" << endl; bcd s2("1234567890987654321"); s2.shrCpld(s1,6); // odd shift even dout << "coupled shift s2 > s1, s1 = " << s1 << " expected s1 = +00000000000000000000000000654321 cc: 0\n" << " s2 = " << s2 << " expected s2 = +00000000000000000001234567890987 cc: 0\n" << endl; s2.shrCpld(s1,5); // odd shift odd dout << "coupled shift s2 > s1, s1 = " << s1 << " expected s1 = +00000000000000000000000000090987 cc: 0\n" << " s2 = " << s2 << " expected s2 = +00000000000000000000000012345678 cc: 0\n" << endl; s2.shrCpld(s1,4); // even shift even dout << "coupled shift s2 > s1, s1 = " << s1 << " expected s1 = +00000000000000000000000000005678 cc: 0\n" << " s2 = " << s2 << " expected s2 = +00000000000000000000000000001234 cc: 0\n" << endl; s2.shrCpld(s1,3); // odd shift odd dout << "coupled shift s2 > s1, s1 = " << s1 << " expected s1 = +00000000000000000000000000000234 cc: 0\n" << " s2 = " << s2 << " expected s2 = +00000000000000000000000000000001 cc: 0\n" << endl; dout << "logical test 1 < 2 = " << int(bb<m2) << "\n" << "expected = 1 \n" << endl; dout << "logical test 1 > 2 = " << int(bb>m2) << "\n" << "expected = 0 \n" << endl; dout << "logical test 1 = 2 = " << int(bb==m2) << "\n" << "expected = 0 \n" << endl; dout << "logical test 2 < 1 = " << int(m2<bb) << "\n" << "expected = 0 \n" << endl; dout << "logical test 2 > 1 = " << int(m2>bb) << "\n" << "expected = 1 \n" << endl; dout << "logical test 2 = 1 = " << int(m2==bb) << "\n" << "expected = 0 \n" << endl; dout << "logical test 1 < 12 = " << int(bb<m1) << "\n" << "expected = 1 \n" << endl; dout << "logical test 1 > 12 = " << int(bb>m1) << "\n" << "expected = 0 \n" << endl; dout << "logical test 1 = 12 = " << int(bb==m1) << "\n" << "expected = 0 \n" << endl; dout << "logical test 12 < 1 = " << int(m1<bb) << "\n" << "expected = 0 \n" << endl; dout << "logical test 12 > 1 = " << int(m1>bb) << "\n" << "expected = 1 \n" << endl; dout << "logical test 12 = 1 = " << int(m1==bb) << "\n" << "expected = 0 \n" << endl; dout << "logical test -1 < 2 = " << int(x<m2) << "\n" << "expected = 1 \n" << endl; dout << "logical test -1 > 2 = " << int(x>m2) << "\n" << "expected = 0 \n" << endl; dout << "logical test -1 = 2 = " << int(x==m2) << "\n" << "expected = 0 \n" << endl; dout << "logical test 2 < -1 = " << int(m2<x) << "\n" << "expected = 0 \n" << endl; dout << "logical test -1 != 2 = " << int(x!=m2) << "\n" << "expected = 1 \n" << endl; dout << "logical test 2 != -1 = " << int(m2!=x) << "\n" << "expected = 1 \n" << endl; dout << "logical test 2 != 2 = " << int(m2!=m2) << "\n" << "expected = 0 \n" << endl; dout << "logical test 2 > -1 = " << int(m2>x) << "\n" << "expected = 1 \n" << endl; dout << "logical test 2 = -1 = " << int(m2==x) << "\n" << "expected = 0 \n" << endl; dout << "logical test d1 = d1 = " << int(d1==d1) << "\n" << "expected = 1 \n" << endl; dout << "logical test 0 = -0 = " << int(f==h) << "\n" << "expected = 1 \n" << endl; dout << "logical test -0 = 0 = " << int(h==f) << "\n" << "expected = 1 \n" << endl; dout << "logical test 0 = 0 = " << int(f==f) << "\n" << "expected = 1 \n" << endl; dout << "logical test -0 = -0 = " << int(h==h) << "\n" << "expected = 1 \n" << endl; dout << "divide test 8765432109876/24687 = " << d1/d2 << "expected = +00000000000000000000000355062669 cc: 0\n" << endl; dout << "divide tst 92732081006447/45263 = " << d5/d4 << "expected = +00000000000000000000002048739169 cc: 0\n" << endl; dout << "divide test 8765432109876/75237 = " << d1/d3 << "expected = +00000000000000000000000116504274 cc: 0\n" << endl; dout << "divide test 1/24687 = " << bb/d2 << "expected = +00000000000000000000000000000000 cc: 0\n" << endl; dout << " test 10000000000000000/24687 = " << cc/d2 << "expected = +00000000000000000000405071495118 cc: 0\n" << endl; dout << " test 10000000000000000/3 = " << cc/3L << "expected = +00000000000000003333333333333333 cc: 0\n" << endl; dout << " test 10000000000000000/6 = " << cc/6L << "expected = +00000000000000001666666666666666 cc: 0\n" << endl; dout << " test 10000000000000000/7 = " << cc/7L << "expected = +00000000000000001428571428571428 cc: 0\n" << endl; dout << " div test 22000000000000000/7 = " << (cc*22L)/7L << "expected = +00000000000000031428571428571428 cc: 0\n" << endl; dout << "modulus test 24687%1000 = " << d2%1000L << "expected = +00000000000000000000000000000687 cc: 0\n" << endl; dout << "divide by zero test 75237/0 = " << d3/0L << "expected = +00000000000000000000000000075237 cc: 16\n" << endl; dout << "divide d1/d1 test = " << d1/d1 << "expected = +00000000000000000000000000000001 cc: 0\n" << endl; dout << "re-subtract test: 12345 - 12346 = " << bcd(12345L) - 12346L << "expected = -00000000000000000000000000000001 cc: 0\n" << " reverse opnds: 12346 - 12345 = " << bcd(12346L) - 12345L << "expected = +00000000000000000000000000000001 cc: 0\n" << endl; dout << "8599238847786248452455563809*45263 = " << m7 * d4 << " expected: +00008599238847786248452455563809 cc: 15\n" << endl; dout << "748345987654321 x 288834570200345 = " << m5 * m6 << " expected: +00216148191705288491573574940745 cc: 0\n" << endl; dout << "748345987654321 x 288834570200345 x 10 = " << m5 * m6 * 10.0 << " expected: +02161481917052884915735749407450 cc: 0\n" << endl; dout << "748345987654321 x 288834570200345 x 100 = " << m5 * m6 * 100.0 << " expected: +21614819170528849157357494074500 cc: 0\n" << endl; dout << "748345987654321 x 288834570200345 x 1000 = " << m5 * m6 * 1000.0 << " expected: +00216148191705288491573574940745 cc: 16\n" << endl; dout << "123456789 x 123456789 x 123456789 = " << m3 * m3 * m3 << " expected: +00000001881676371789154860897069 cc: 0\n" << endl; dout << "123456789 x 123456789 x 123456789 x 123456789 = " << m3 * m3 * m3 * m3 << " expected: +00000001881676371789154860897069 cc: 16\n" << endl; dout << " 2 x 2 = " << m2*m2 << " expected: +00000000000000000000000000000004 cc: 0\n" << endl; dout << " 2 x 12 = " << m2*m1 << " expected: +00000000000000000000000000000024 cc: 0\n" << endl; dout << " 2 x 123456789 = " << m2 * m3 << " expected: +00000000000000000000000246913578 cc: 0\n" << endl; dout << " 123456789 x 2 = " << m3 * m2 << " expected: +00000000000000000000000246913578 cc: 0\n" << endl; dout << " 4096 x 2 = " << m4 * m2 << "expected: +00000000000000000000000000008192 cc: 0\n" << endl; dout << " 2 x 4096 = " << m2 * m4 << "expected: +00000000000000000000000000008192 cc: 0\n" << endl; dout << " 2 x 12 x 4096 = " << m2 * m1 * m4 << "expected: +00000000000000000000000000098304 cc: 0\n" << endl; dout << " aa = " << aa << " bb = " << bb << " aa-bb = " << aa-bb << "expected:+99999999999999999999999999999998 cc: 0\n" << " aa+bb = " << aa+bb << "expected:+00000000000000000000000000000000 cc: 1\n" << endl; dout << " e = " << e << " f = " << f << " e + f = " << e+f << "expected:+00000000000000000000000000000000 cc: 0\n" << " e - f = " << e-f << "expected:+00000000000000000000000000000000 cc: 0\n" << endl; dout << " g = " << g << " h = " << h << " g + h = " << g+h << "expected:+00000000000000000000000000000000 cc: 0\n" << " g - h = " << g-h << "expected:+00000000000000000000000000000000 cc: 0\n" << endl; dout << " w = " << w << " x = " << x << " w + x = " << w+x << "expected:+00000000000000000000000000000000 cc: 0\n" << " w - x = " << w-x << "expected:+00000000000000000000000000000002 cc: 0\n" << endl; dout << " y = " << y << " z = " << z << " y + z = " << y+z << "expected:+00000000000000000000000000000298 cc: 0\n" << " y - z = " << y-z << "expected:-00000000000000000000000000000302 cc: 0\n" << endl; dout << "numa = " << numa << "numb = " << numb << "numa+numb = " << numd << "expected: +00000000000000001234567890991975 cc: 0\n" << "numb+numa = " << numb+numa << "expected: +00000000000000001234567890991975 cc: 0\n" << endl; dout << "numa = " << numa << "numc = " << numc << "numa+numc = " << numa+numc << "expected: +00000000000000001234567866306297 cc: 0\n" << "numc+numa = " << numc+numa << "expected: +00000000000000001234567866306297 cc: 0\n" << endl; dout << "numb = " << numb << "numc = " << numc << "numb+numc = " << numb+numc << "expected: -00000000000000000000000024677036 cc: 0\n" << "numc+numb = " << numc+numb << "expected: -00000000000000000000000024677036 cc: 0\n" << endl; dout << "numa = " << numa << "numb = " << numb << "numa-numb = " << numa-numb << "expected: +00000000000000001234567890983333 cc: 0\n" << "numb-numa = " << numb-numa << "expected: -00000000000000001234567890983333 cc: 0\n" << endl; dout << "numa = " << numa << "numc = " << numc << "numa-numc = " << numa-numc << "expected: +00000000000000001234567915669011 cc: 0\n" << "numc-numa = " << numc-numa << "expected: -00000000000000001234567915669011 cc: 0\n" << endl; dout << "numb = " << numb << "numc = " << numc << "numb-numc = " << numb-numc << "expected: +00000000000000000000000024685678 cc: 0\n" << "numc-numb = " << numc-numb << "expected: -00000000000000000000000024685678 cc: 0\n" << endl; dout.close(); delete st; return 0; }