next up previous contents
Next: 2.2.4 Standard Args Initialize Up: 2.2 Constructors Previous: 2.2.2 Copy Constructor   Contents

2.2.3 Array Initialize Constructor

The array initialize constructor takes one argument, the address of the beginning of a contiguous block of data to be loaded row-wise, as is the C++ convention, into the element storage area. No offsets are necessary and the address must be of type tData* relative to the definition below:


  template < typename tData, int tRows, int tCols >
  Matrix< tData, tRows, tCols > (tData* tArray);


  double r[3] = {0.0,1.0,2.0};
  Matrix < double, 3, 1 > R(r);
  double s[2][2] = {{0.0, 1.0}, {2.0, 3.0}};
  Matrix < double, 4, 1 > S((double*)s); 
  Matrix < double, 4, 1 > T(&s[0][0]);

There are many different possible and valid pointer and address combinations; be careful. Two point are important. If the size of the input array or block is larger than the matrix only the fist $(tRows*tCols)$ elements will be loaded.If the size of the input array or block is smaller than $(tRows*tCols)$, the values of the remaining elements are not deterministic.

Andrew Douglas 2005-03-15