Scythe-1.0.3
|
template<typename T_type = double, matrix_order ORDER = Col, matrix_style STYLE = Concrete>
template<matrix_order O, matrix_style S>
Cross order and/or style 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. This version of the copy constructor extends Matrix(const Matrix &) by allowing the user to make concrete copies and views of matrices that have matrix_order or matrix_style that does not match that of the constructed Matrix. That is, this constructor makes it possible to create views of concrete matrices and concrete copies of views, row-major copies of col-major matrices, and so on.
Example: #include <iostream> #include <scythestat/matrix.h> using namespace scythe; int main () { // Construct a 4x4 matrix of 1s using the standard constructor. Matrix<> A(4, 5, true, 1); // Create a copy of this matrix in row-major order. Matrix<double, Row> B(A); // Create a row-major view of A. Matrix<double, Row, View> C(A); C[2] = 34.333; // Prints true (1) std::cout << A.equals(C) << "\n"; // Prints false (0) std::cout << A.equals(B) << "\n"; return 0; } |