next up previous contents
Next: 2.3 Accessor Methods Up: 2.2 Constructors Previous: 2.2.3 Array Initialize Constructor   Contents

2.2.4 Standard Args Initialize Constructor

The standard args initialize constructor takes a minimum of two arguments. The first argument is the number of elements that the user would like to load; the remaining arguments correspond the the elements themselves. The elements are loaded row-wise into the matrix, as with the array initialize constructor described above.

Definition:

  template < class tData, int tRows, int tCols >
  Matrix< tData, tRows, tCols >::Matrix (int count, tData first, ...);

Examples:

  Matrix <  float, 3, 1 > R1(3,5.0f,6.0f,7.0f);
  Matrix < double, 3, 1 > R2(3,5.0,6.0,7.0);
  Matrix <    int, 3, 1 > S1(2,10,12); 
  Matrix <   long, 3, 1 > S2(2,10l,12l);

N.B., using standard args is very brittle and not type safe. Make sure to count well and ensure the element you are loading are of the same type as the matrix define. The user must cast appropriately or use other means to identify the type. See the first and the forth examples above.



Andrew Douglas 2005-03-15