next up previous contents
Next: 2.2.3 Array Initialize Constructor Up: 2.2 Constructors Previous: 2.2.1 Default Constructor   Contents

2.2.2 Copy Constructor

The copy constructor, not to be confused with the assignment operator, takes one argument, another matrix of the same type. Since the basic EMatrix type, Matrix<>, is a template, for the two matrices to be of the same type, both the matrix type and the dimensions must be the same. The protected method, matalloc, is called before the data is memcpy'd to the new area. There is an error check to ensure that the matrix is of greater than zero size, which may not be necessary.

Definition:

  template < typename tData, int tRows, int tCols >
  Matrix< tData, tRows, tCols > (const Matrix< tData, tRows, tCols > & R);

Examples:

  Matrix < double, 3, 1 > R; 
  R.rand();
  Matrix < double, 3, 1 > S(R); 
  Matrix < double, 3, 1 > T = S;  // This is still the copy constructor



Andrew Douglas 2005-03-15