SHARE
TWEET

Untitled

sve_vash Oct 23rd, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TEST_CASE("Operator * (vector * matrix)") {
  2.     Matrix A(5, 3, 1);
  3.     std::pair<size_t, size_t> p(5, 3);
  4.     for (int i = 0; i < p.first; ++i) {
  5.         for (int j = 0; j < p.second; ++j) {
  6.             A.get(i, j) = i * p.first + i + j + 1;
  7.         }
  8.     }
  9.     Vector B(5);
  10.     for (int i = 0; i < B.size(); ++i) {
  11.         B[i] = i + 1;
  12.     }
  13.  
  14.     Vector C(1);
  15.     C = B * A;
  16.     REQUIRE(C.size() == 3);
  17.     REQUIRE(abs(C[0] - 135) < eps);
  18.     REQUIRE(abs(C[1] - 150) < eps);
  19.     REQUIRE(abs(C[2] - 165) < eps);
  20.  
  21.     ////////////////////
  22.     B *= A;
  23.     REQUIRE(B.size() == 3);
  24.     REQUIRE(abs(B[0] - 135) < eps);
  25.     REQUIRE(abs(B[1] - 150) < eps);
  26.     REQUIRE(abs(B[2] - 165) < eps);
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top