Scythe-1.0.3
|
template<typename T_type = double, matrix_order ORDER = Col, matrix_style STYLE = Concrete>
template<matrix_order O, matrix_style S>
View another Matrix's data. This modifier makes this matrix a view of another's data. The action detaches the Matrix from its current view; if no other Matrix views the detached DataBlock, it will be deallocated. Concrete matrices cannot convert into views at run time. Therefore, it is an error to invoke this method on a concrete Matrix.
Example: #include <iostream> #include <scythestat/matrix.h> using namespace scythe; int main () { // Construct a 10x10 matrices of 1s and a view of it. Matrix<> A(10, 10, true, 1); Matrix<double,Col,View> B(A); // Construct a null matrix view and make it reference B. Matrix<double,Col,View> C; C.reference(B); // Prints true (1) std::cout << (A.equals(B) && A.equals(C)) << "\n"; C[4] = 3.2; // Prints true (1) std::cout << (A.equals(B) && A.equals(C)) << "\n"; // Construct another concrete matrix. Matrix<> D(10, 10, false); // Throws error because concretes can't reference other matrices. D.reference(A); return 0; } |