Scythe-1.0.3
|
template<typename T_type = double, matrix_order ORDER = Col, matrix_style STYLE = Concrete>
Default copy constructor. Copy constructing a concrete Matrix makes an exact copy of M in a new data block. On the other hand, copy constructing a view Matrix generates a new Matrix object that references (or views) M's existing data block.
Example: #include <iostream> #include <scythestat/matrix.h> using namespace scythe; int main () { // Construct two 10x10 matrices of 1s. Creates two distinct copies. Matrix<> A(10, 10, true, 1); Matrix<> B(A); // Construct two 2x4 matrix views, both viewing the same block of 4s. Matrix<double, Col, View> C(2, 4, true, 4); Matrix<double, Col, View> D(C); // Construct a 10x10 view of a concrete matrix. Matrix<double, Col, View> E(B); B[2] = 23.2; C[2] = 12.34; // Prints false (0) std::cout << A.equals(B) << "\n"; // Prints true (1) std::cout << C.equals(D) << "\n"; // Prints false (0) std::cout << A.equals(E) << "\n"; // Prints true (1) std::cout << B.equals(E) << "\n"; return 0; } |