[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN/doc matrixdoc.h vectordoc.h
From: |
Paul Smith |
Subject: |
[Toon-members] TooN/doc matrixdoc.h vectordoc.h |
Date: |
Thu, 21 Sep 2006 11:02:10 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Paul Smith <aardvaark> 06/09/21 11:02:10
Modified files:
doc : matrixdoc.h vectordoc.h
Log message:
Replaced /// with /** in documentation so that code examples now
display properly for my version of Doxygen
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/doc/matrixdoc.h?cvsroot=toon&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/TooN/doc/vectordoc.h?cvsroot=toon&r1=1.6&r2=1.7
Patches:
Index: matrixdoc.h
===================================================================
RCS file: /cvsroot/toon/TooN/doc/matrixdoc.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- matrixdoc.h 21 Nov 2005 16:49:38 -0000 1.6
+++ matrixdoc.h 21 Sep 2006 11:02:09 -0000 1.7
@@ -29,29 +29,34 @@
A matrix.
Support is provided for all the usual matrix operations:
- the (a,b) notation can be used to access an element directly
-- the [] operator can be used to yield a vector from a matrix (which can be
used as an l-value)
+- the [] operator can be used to yield a vector from a matrix (which can be
used
+as an l-value)
- they can be added and subtracted
- they can be multiplied (on either side) or divided by a scalar on the right:
- they can be multiplied by matrices or vectors
- submatrices can be extracted using the templated slice() member function
- they can be transposed (and the transpose used as an l-value)
-- inverse is \e not supported. Use one of the @link gDecomps matrix
decompositions @endlink instead
+- inverse is \e not supported. Use one of the @link gDecomps matrix
+decompositions @endlink instead
See individual member function documentation for examples of usage.
\par Statically-sized matrices
-The library provides classes for statically and dynamically sized matrices. As
with @link Vector address@hidden, statically sized matrices are more efficient,
since their size is determined at compile-time, not run-time.
+The library provides classes for statically and dynamically sized matrices. As
+with @link Vector address@hidden, statically sized matrices are more efficient,
+since their size is determined at compile-time, not run-time.
To create a \f$3\times4\f$ matrix, use:
@code
Matrix<3,4> M;
@endcode
-or replace 3 and 4 with the dimensions of your choice. If the matrix is
square, it can be declared as:
+or replace 3 and 4 with the dimensions of your choice. If the matrix is square,
+it can be declared as:
@code
Matrix<3> M;
@endcode
-which just is a synonym for <code>Matrix<3,3></code>. Matrices can also be
constructed
-from pointers or static 1D or 2D arrays of doubles:
+which just is a synonym for <code>Matrix<3,3></code>. Matrices can also be
+constructed from pointers or static 1D or 2D arrays of doubles:
@code
void foo(double* dptr) {
@@ -73,8 +78,9 @@
@code
Matrix<> M(num_rows, num_cols);
@endcode
-where \a num_rows and \a num_cols are integers which will be evaluated at run
time.
-Dynamically-sized matrices can be constructed from pointers in a similar
manner to static sized matrices:
+where \a num_rows and \a num_cols are integers which will be evaluated at run
+time. Dynamically-sized matrices can be constructed from pointers in a similar
+manner to static sized matrices:
@code
void bar(int r, int c, double* dptr) {
Matrix<> M (r,c,dptr);
@@ -85,11 +91,14 @@
\par Row-major and column-major
-The library supports both row major (the default - but you can change this if
you prefer) and
-column major layout ordering. Row major implies that the matrix is laid out in
memory in
-raster scan order:
-\f[\begin{matrix}\text{Row major} & \text {Column
major}\\\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix} &
\begin{bmatrix}1&4&7\\2&5&8\\3&6&9\end{bmatrix} \end{matrix}\f]
-You can override the default for a specific matrix by specifying the layout
when you construct it:
+The library supports both row major (the default - but you can change this if
+you prefer) and column major layout ordering. Row major implies that the matrix
+is laid out in memory in raster scan order:
+\f[\begin{matrix}\text{Row major} & \text {Column major}\\
+\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix} &
+\begin{bmatrix}1&4&7\\2&5&8\\3&6&9\end{bmatrix} \end{matrix}\f]
+You can override the default for a specific matrix by specifying the layout
when
+you construct it:
@code
Matrix<3,3,ColMajor> M1;
Matrix<-1,-1,RowMajor> M2(nrows, ncols);
@@ -105,28 +114,34 @@
//@{
/// Default constructor.
- /// For fixed sized matrices, this does nothing, i.e. does not
guarantee to initialise the vector to any particular values.
+ /// For fixed sized matrices, this does nothing, i.e. does not guarantee to
+ initialise the vector to any particular values.
/// For dynamically sized matrices, this sets up a 0x0 matrix.
Matrix();
- /// Construct a (fixed-size) matrix from a 1D array of doubles. By
default the layout ordering is
- /// row major (along the rows first i.e. raster scan order), unless
<code>ColMajor</code> is specified
- /// in the template arguments (see detailed description). No errors are
generated if the array is the
- /// wrong length.
- /// @code
- /// double d[4] = {1, 2, 3, 4};
- /// Matrix<2> m(d); // now m = [1 2]
- /// // [3 4]
- /// @endcode
+ /**
+ Construct a (fixed-size) matrix from a 1D array of doubles. By default the
+ layout ordering is row major (along the rows first i.e. raster scan order),
+ unless <code>ColMajor</code> is specified in the template arguments (see
+ detailed description). No errors are generated if the array is the wrong
+ length.
+ @code
+ double d[4] = {1, 2, 3, 4};
+ Matrix<2> m(d); // now m = [1 2]
+ // [3 4]
+ @endcode
+ */
Matrix(double darray[Rows*Cols]);
- /// Construct a (fixed-size) matrix from a 2D array of doubles. No
errors are generated if the array is the
- /// wrong length.
- /// @code
- /// double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
- /// Matrix<2,3> m(d); // now m = [1 2 3]
- /// // [4 5 6]
- /// @endcode
+ /**
+ Construct a (fixed-size) matrix from a 2D array of doubles. No errors
+ are generated if the array is the wrong length.
+ @code
+ double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+ Matrix<2,3> m(d); // now m = [1 2 3]
+ // [4 5 6]
+ @endcode
+ */
Matrix(double darray[Rows][Cols]);
/// Copy constructor.
@@ -139,62 +154,69 @@
//@{
/// Assignment operator.
- /// For dynamically sized matrices this will not cause a resize if the
sizes are mismatched.
+ /// For dynamically sized matrices this will not cause a resize if the sizes
+are mismatched.
Matrix<Rows, Cols>& operator=(const Matrix<Rows, Cols>& from);
/// Resize a dynamically sized matrix.
resize(int rows, int cols);
- /// Access an element from the matrix.
- /// The index starts at zero, i.e. the top-left element is m(0, 0).
- /// @code
- /// double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
- /// Matrix<2,3> m(d);
- /// double e = m(1,2); // now e = 5.0;
- /// @endcode
+ /**
+ Access an element from the matrix.
+ The index starts at zero, i.e. the top-left element is m(0, 0).
+ @code
+ double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+ Matrix<2,3> m(d);
+ double e = m(1,2); // now e = 5.0;
+ @endcode
+ */
const double& operator() (int r, int c) const;
- /// Access an element from the matrix.
- /// This can be used as either an r-value or an l-value.
- /// The index starts at zero, i.e. the top-left element is m(0, 0).
- /// @code
- /// double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
- /// Matrix<2,3> m(d);
- /// m(1,2) = 8; // now d = [1 2 3]
- /// // [4 8 6]
- /// @endcode
+ /**
+ Access an element from the matrix.
+ This can be used as either an r-value or an l-value. The index starts at
zero,
+ i.e. the top-left element is m(0, 0).
+ @code
+ double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+ Matrix<2,3> m(d);
+ m(1,2) = 8; // now d = [1 2 3]
+ // [4 8 6]
+ @endcode
+ */
double& operator() (int r, int c);
- /// Access a row from the matrix.
- /// This can be used either as an r-value or an l-value.
- /// The index starts at zero, i.e. the first row is m[0].
- /// To extract a column from a matrix, apply []
- /// to the transpose of the matrix (see example).
- /// This can be used either as an r-value or an l-value
- /// The index starts at zero, i.e. the first row (or column) is m[0].
- /// @code
- /// double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
- /// Matrix<2,3> m(d);
- /// Vector<3> v = m[1]; // now v = [4 5 6];
- /// Vector<2> v2 = m.T()[0]; // now v2 = [1 4];
- /// @endcode
+ /**
+ Access a row from the matrix.
+ This can be used either as an r-value or an l-value. The index starts at
zero,
+ i.e. the first row is m[0]. To extract a column from a matrix, apply [] to
the
+ transpose of the matrix (see example). This can be used either as an r-value
+ or an l-value. The index starts at zero, i.e. the first row (or column) is
+ m[0].
+ @code
+ double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+ Matrix<2,3> m(d);
+ Vector<3> v = m[1]; // now v = [4 5 6];
+ Vector<2> v2 = m.T()[0]; // now v2 = [1 4];
+ @endcode
+ */
const Vector& operator[] (int r) const;
- /// Access a row from the matrix.
- /// This can be used either as an r-value or an l-value.
- /// The index starts at zero, i.e. the first row is m[0].
- /// To extract a column from a matrix, apply []
- /// to the transpose of the matrix (see example).
- /// This can be used either as an r-value or an l-value
- /// The index starts at zero, i.e. the first row (or column) is m[0].
- /// @code
- /// double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
- /// Matrix<2,3> m(d);
- /// Zero(m[0]); // set the first row to zero
- /// Vector<2> v = 8,9;
- /// m.T()[1] = v; // now m = [0 8 0]
- /// // [4 9 6]
- /// @endcode
+ /**
+ Access a row from the matrix.
+ This can be used either as an r-value or an l-value. The index starts at
zero,
+ i.e. the first row is m[0]. To extract a column from a matrix, apply [] to
the
+ transpose of the matrix (see example). This can be used either as an r-value
+ or an l-value. The index starts at zero, i.e. the first row (or column) is
+ m[0].
+ @code
+ double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+ Matrix<2,3> m(d);
+ Zero(m[0]); // set the first row to zero
+ Vector<2> v = 8,9;
+ m.T()[1] = v; // now m = [0 8 0]
+ // [4 9 6]
+ @endcode
+ */
Vector& operator[] (int r);
/// How many rows does this matrix have?
@@ -204,79 +226,94 @@
int num_cols() const;
/// What is the memory layout of this matrix?
- /// This is a
{RowMajor, ColMajor} layout const;
//@}
/// @name Transpose and sub-matrices
//@{
- /// The transpose of the matrix. This is a very fast operation--it
simply reinterprets a row-major
- /// matrix as column-major or vice-versa. This can be used as an
l-value.
- /// @code
- /// double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
- /// Matrix<2,3> m(d);
- /// Zero(m[0]); // set the first row to zero
- /// Vector<2> v = 8,9;
- /// m.T()[1] = v; // now m = [0 8 0]
- /// // [4 9 6]
- /// @endcode
+ /**
+ The transpose of the matrix. This is a very fast operation--it simply
+ reinterprets a row-major matrix as column-major or vice-versa. This can be
+ used as an l-value.
+ @code
+ double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+ Matrix<2,3> m(d);
+ Zero(m[0]); // set the first row to zero
+ Vector<2> v = 8,9;
+ m.T()[1] = v; // now m = [0 8 0]
+ // [4 9 6]
+ @endcode
+ */
const Matrix<Cols, Rows>& T() const;
- /// The transpose of the matrix. This is a very fast operation--it
simply reinterprets a row-major
- /// matrix as column-major or vice-versa. The result can be used as an
l-value.
- /// @code
- /// double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
- /// Matrix<2,3> m(d);
- /// Vector<2> v = 8,9;
- /// // Set the first column to v
- /// m.T()[0] = v; // now m = [8 2 3]
- /// // [9 5 6]
- /// @endcode
- /// <b>This means that the semantics of <code>M=M.T()</code> are
broken</b>. In general, it is not
- /// necessary to say <code>M=M.T()</code>, since you can use M.T() for
free whenever you need the transpose,
- /// but if you do need to, you have to use the Tranpose() function
defined in <code>helpers.h</code>.
+ /**
+ The transpose of the matrix. This is a very fast operation--it simply
+ reinterprets a row-major matrix as column-major or vice-versa. The result
can
+ be used as an l-value.
+ @code
+ double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+ Matrix<2,3> m(d);
+ Vector<2> v = 8,9;
+ // Set the first column to v
+ m.T()[0] = v; // now m = [8 2 3]
+ // [9 5 6]
+ @endcode
+ <b>This means that the semantics of <code>M=M.T()</code> are broken</b>. In
+ general, it is not necessary to say <code>M=M.T()</code>, since you can use
+ M.T() for free whenever you need the transpose, but if you do need to, you
+ have to use the Tranpose() function defined in <code>helpers.h</code>.
+ */
Matrix<Cols, Rows>& T();
- /// Extract a sub-matrix. The matrix extracted will be begin at element
(Rstart, Cstart) and will
- /// contain the next Rsize by Csize elements.
- /// @code
- /// double d[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
- /// Matrix<3> m(d);
- /// Extract the top-left 2x2 matrix
- /// Matrix<2> b = m.slice<0,0,2,2>(); // b = [1 2]
- /// // [4 5]
- /// @endcode
+ /**
+ Extract a sub-matrix. The matrix extracted will be begin at element
+ (Rstart, Cstart) and will contain the next Rsize by Csize elements.
+ @code
+ double d[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
+ Matrix<3> m(d);
+ Extract the top-left 2x2 matrix
+ Matrix<2> b = m.slice<0,0,2,2>(); // b = [1 2]
+ // [4 5]
+ @endcode
+ */
template<Rstart, Cstart, Rsize, Csize>
const Matrix<Rsize, Csize>& slice() const;
- /// Extract a sub-matrix. The matrix extracted will be begin at element
(Rstart, Cstart) and will
- /// contain the next Rsize by Csize elements. This can be used as
either an r-value or an l-value.
- /// @code
- /// double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
- /// Matrix<2,3> m(d);
- /// Zero(m.slice<0,2,2,1>()); // b = [1 2 0]
- /// // [4 5 0]
- /// @endcode
+ /**
+ Extract a sub-matrix. The matrix extracted will be begin at element (Rstart,
+ Cstart) and will contain the next Rsize by Csize elements. This can be used
as
+ either an r-value or an l-value.
+ @code
+ double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+ Matrix<2,3> m(d);
+ Zero(m.slice<0,2,2,1>()); // b = [1 2 0]
+ // [4 5 0]
+ @endcode
+ */
template<Rstart, Cstart, Rsize, Csize>
Matrix<Rsize, Csize>& slice();
- /// Extract a sub-matrix with runtime location and size.
- /// The matrix extracted will be begin at element (rstart, cstart) and
will
- /// contain the next rsize by csize elements.
- /// @code
- /// Matrix<> m(3,3);
- /// Extract the top-left 2x2 matrix
- /// Matrix<2> b = m.slice(0,0,2,2);
- /// @endcode
+ /**
+ Extract a sub-matrix with runtime location and size. The matrix extracted
will
+ begin at element (rstart, cstart) and will
+ contain the next rsize by csize elements.
+ @code
+ Matrix<> m(3,3);
+ Extract the top-left 2x2 matrix
+ Matrix<2> b = m.slice(0,0,2,2);
+ @endcode
+ */
const Matrix<>& slice(int rstart, int cstart, int rsize, int csize)
const;
- /// Extract a sub-matrix with runtime location and size, which can be
used as an l-value.
- /// The matrix extracted will be begin at element (rstart, cstart) and
will
- /// contain the next rsize by csize elements.
- /// @code
- /// Matrix<> m(3,3);
- /// Zero(m.slice(0,0,2,2));
- /// @endcode
+ /**
+ Extract a sub-matrix with runtime location and size, which can be used as
+ an l-value. The matrix extracted will be begin at element (rstart, cstart)
and
+ will contain the next rsize by csize elements.
+ @code
+ Matrix<> m(3,3);
+ Zero(m.slice(0,0,2,2));
+ @endcode
+ */
Matrix<>& slice(int rstart, int cstart, int rsize, int csize);
//@}
@@ -285,15 +322,21 @@
/// @name Input/output
//@{
-/// Write the matrix to a stream. The elements are space-separated with rows
being separated by
-/// new lines. The numbers are printed with a minimum field width of 12
characters.
-/// @relates Matrix
+/**
+Write the matrix to a stream. The elements are space-separated with rows
+being separated by new lines. The numbers are printed with a minimum field
width
+of 12 characters.
address@hidden Matrix
+*/
template <int Rows, Cols>
std::ostream& operator<< (std::ostream& os, const Matrix<Rows, Cols>& v);
-/// Read a matrix from a stream. The numbers can be comma or white-space
separated, and are assumed
-/// to be in row-major layout (i.e. scanline order) unless the matrix is
defined as <code>ColMajor</code>
-/// @relates Matrix
+/**
+Read a matrix from a stream. The numbers can be comma or white-space
+separated, and are assumed to be in row-major layout (i.e. scanline order)
+unless the matrix is defined as <code>ColMajor</code>
address@hidden Matrix
+*/
template <int Rows, Cols>
std::istream& operator<< (std::istream& is, Matrix<Rows, Cols>& v);
//@}
Index: vectordoc.h
===================================================================
RCS file: /cvsroot/toon/TooN/doc/vectordoc.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- vectordoc.h 13 Jan 2006 16:05:39 -0000 1.6
+++ vectordoc.h 21 Sep 2006 11:02:09 -0000 1.7
@@ -164,20 +164,24 @@
/// guarantee to initialise the vector to any particular values
Vector(int size);
- /// Construct a fixed-size vector from an array of doubles. No errors
are generated if the array
- /// is the wrong length.
- /// @code
- /// double d[4] = {1, 2, 3, 4};
- /// Vector<4> a(d); // now a = [1 2 3 4]
- /// @endcode
+ /**
+ Construct a fixed-size vector from an array of doubles. No errors are
+ generated if the array is the wrong length.
+ @code
+ double d[4] = {1, 2, 3, 4};
+ Vector<4> a(d); // now a = [1 2 3 4]
+ @endcode
+ */
Vector(double darray[]);
- /// Construct a dynamically-sized vector from an array of doubles. No
errors are generated if the array
- /// is the wrong length.
- /// @code
- /// double d[4] = {1, 2, 3, 4};
- /// Vector<> a(4, d); // now a = [1 2 3 4]
- /// @endcode
+ /**
+ Construct a dynamically-sized vector from an array of doubles. No errors
+ are generated if the array is the wrong length.
+ @code
+ double d[4] = {1, 2, 3, 4};
+ Vector<> a(4, d); // now a = [1 2 3 4]
+ @endcode
+ */
Vector(int size, double* dptr);
/// Copy constructor.
@@ -189,74 +193,89 @@
/// @name Reading and writing elements, and defining vectors
//@{
- /// Assignment operator. This will not cause a resize on dynamically
sized vectors if the sizes are not matched.
+ /// Assignment operator. This will not cause a resize on dynamically sized
+ vectors if the sizes are not matched.
Vector<Size>& operator=(const Vector<Size>& from);
/// Resize a dynamically sized vector.
resize(int size);
- /// Create a (fixed-size) vector from a list of doubles.
- /// This operator should be followed by a comma-separated list of
doubles, and the whole enclosed in
- /// brackets (see the example).
- /// The list of doubles most be of the correct length: if the wrong
number of
- /// element are provided, a compile error is generated.
- /// @code
- /// Vector<4> a;
- /// a = (make_Vector, 1, 2, 3, 4); // v = [ 1 2 3 4 ]
- /// a = make_Vector, 1, 2, 3, 4; // compile error
- /// a = (make_Vector, 1, 2, 3, 4, 5); // compile error
- /// a = (make_Vector, 1, 2, 3); // compile error;
- /// @endcode
- /// The <code>(make_Vector, 1, 2, 3, 4)</code> syntax generates a real
vector object
- /// which can be used in other operations, not just for assigning to a
Vector.
+ /**
+ Create a (fixed-size) vector from a list of doubles.
+ This operator should be followed by a comma-separated list of doubles, and
the
+ whole enclosed in brackets (see the example). The list of doubles most be of
+ the correct length: if the wrong number of elements are provided, a compile
+ error is generated.
+ @code
+ Vector<4> a;
+ a = (make_Vector, 1, 2, 3, 4); // v = [ 1 2 3 4 ]
+ a = make_Vector, 1, 2, 3, 4; // compile error
+ a = (make_Vector, 1, 2, 3, 4, 5); // compile error
+ a = (make_Vector, 1, 2, 3); // compile error;
+ @endcode
+ The <code>(make_Vector, 1, 2, 3, 4)</code> syntax generates a real vector
+ object which can be used in other operations, not just for assigning to a
+ Vector.
+ */
const Vector<Size>& operator=(const make_Vector mv);
- /// Set the elements of a (fixed-size) vector from a list of doubles.
This operator should be used
- /// together with the comma operator to provide a list of doubles of
the correct length.
- /// Providing too many numbers will generate a compile-time error, but
if too few are provided,
- /// only a run-time error is generated. The operator=(make_Vector)
syntax (see above) can check for both
- /// at compile time.
- /// @code
- /// Vector<4> a;
- /// a = 5,6,7,8; // now a = [5 6 7 8]
- /// a = 5,6,7; // run-time error (underfilling)
- /// a = 5,6,7,8,9; // compile error (overfilling)
- /// @endcode
+ /**
+ Set the elements of a (fixed-size) vector from a list of doubles.
+ This operator should be used together with the comma operator to provide a
+ list of doubles of the correct length. Providing too many numbers will
+ generate a compile-time error, but if too few are provided, only a run-time
+ error is generated. The operator=(make_Vector) syntax (see above) can check
+ for both at compile time.
+ @code
+ Vector<4> a;
+ a = 5,6,7,8; // now a = [5 6 7 8]
+ a = 5,6,7; // run-time error (underfilling)
+ a = 5,6,7,8,9; // compile error (overfilling)
+ @endcode
+ */
template <typename T>
void operator=(const T& t);
- /// Set the elements of a (fixed-size) vector by sequential insertion.
- /// This operator replaces the elements of a vector starting from the
beginning of the vector (see example).
- /// A compile error is generated if too many elements are provided.
Single or multiple elements may
- /// be skipped and left unmodified by using the no_change() command;
- /// @code
- /// Vector<4> a;
- /// a << 9 << 10 << 11 << 12; // now a = [9 10 11 12]
- /// a << 9 << 10 << 11 << 12 << 12; //compile error
- /// a << 13 << 14 << 15; // now a = [13 14 15 12]
- /// a << 3 << no_change<2>() << 3; // now a = [3 14 15 3];
- /// a << no_change() << 17 << no_change() << 17; // now a = [3 17 15 17],
no_change() is no_change<1>()
- /// @endcode
+ /**
+ Set the elements of a (fixed-size) vector by sequential insertion.
+ This operator replaces the elements of a vector starting from the beginning
of
+ the vector (see example). A compile error is generated if too many elements
+ are provided. Single or multiple elements may be skipped and left unmodified
+ by using the no_change() command.
+ @code
+ Vector<4> a;
+ a << 9 << 10 << 11 << 12; // now a = [9 10 11 12]
+ a << 9 << 10 << 11 << 12 << 12; //compile error
+ a << 13 << 14 << 15; // now a = [13 14 15 12]
+ a << 3 << no_change<2>() << 3; // now a = [3 14 15 3];
+ a << no_change() << 17 << no_change() << 17;
+ // now a = [3 17 15 17], no_change() is no_change<1>()
+ @endcode
+ */
template <typename T>
void operator<<(const T& t);
- /// Access an element from the vector in the usual way.
- /// The index starts at zero, i.e. the first element is vect[0].
- /// @code
- /// Vector<3> a = 1,2,3;
- /// double d = a[1]; // now d = 2.0;
- /// @endcode
+ /**
+ Access an element from the vector in the usual way.
+ The index starts at zero, i.e. the first element is vect[0].
+ @code
+ Vector<3> a = 1,2,3;
+ double d = a[1]; // now d = 2.0;
+ @endcode
+ */
const double& operator[] (int i) const;
- /// Access an element from the vector in the usual way.
- /// This can be used as either an r-value or an l-value.
- /// The index starts at zero, i.e. the first element is vect[0].
- /// @code
- /// Vector<3> a = 1,2,3;
- /// double d = a[0]; // now d = 1.0;
- /// a[1] = 0; // now a = [1 0 3];
- /// @endcode
+ /**
+ Access an element from the vector in the usual way.
+ This can be used as either an r-value or an l-value.
+ The index starts at zero, i.e. the first element is vect[0].
+ @code
+ Vector<3> a = 1,2,3;
+ double d = a[0]; // now d = 1.0;
+ a[1] = 0; // now a = [1 0 3];
+ @endcode
+ */
double& operator[] (int i);
/// Get the raw double array.
@@ -271,60 +290,76 @@
/// @name Reshaping, sub-vectors and matrices
//@{
- /// Convert this vector into a 1-by-Size matrix, i.e. a matrix which
has this matrix as its only row.
- /// @code
- /// Vector<3> a = 1,2,3;
- /// Matrix<1,3> m = a.as_row(); // now m = [1 2 3]
- /// @endcode
+ /**
+ Convert this vector into a 1-by-Size matrix, i.e. a matrix which has this
+ matrix as its only row.
+ @code
+ Vector<3> a = 1,2,3;
+ Matrix<1,3> m = a.as_row(); // now m = [1 2 3]
+ @endcode
+ */
Matrix<1, Size> as_row();
- /// Convert this vector into a Size-by-1 matrix, i.e. a matrix which
has this matrix as its only column.
- /// @code
- /// Vector<3> a = 1,2,3;
- /// Matrix<3,1> m = a.as_col(); // now m = [1 2 3]'
- /// @endcode
+ /**
+ Convert this vector into a Size-by-1 matrix, i.e. a matrix which has this
+ matrix as its only column.
+ @code
+ Vector<3> a = 1,2,3;
+ Matrix<3,1> m = a.as_col(); // now m = [1 2 3]'
+ @endcode
+ */
Matrix<Size, 1> as_col();
- /// Extract a sub-vector. The vector extracted will be begin at element
Start and will
- /// contain the next Length elements.
- /// @code
- /// Vector<5> a = 1,2,3,4,5;
- /// Extract the three elements starting from element 2
- /// Vector<3> b = a.slice<2,3>(); /// b = [3 4 5]
- /// @endcode
+ /**
+ Extract a sub-vector. The vector extracted will be begin at element Start
+ and will contain the next Length elements.
+ @code
+ Vector<5> a = 1,2,3,4,5;
+ Extract the three elements starting from element 2
+ Vector<3> b = a.slice<2,3>(); /// b = [3 4 5]
+ @endcode
+ */
template<Start, Length>
const Vector<Length>& slice() const;
- /// Extract a sub-vector. The vector extracted will be begin at element
Start and will
- /// contain the next Length elements. This version can be used as an
l-value as well as an r-value
- /// @code
- /// Vector<5> a = 1,2,3,4,5;
- /// Vector<2> b = 8,9;
- /// // replace the two elements starting from element 1 with b
- /// a.slice<1, 2>() = b; /// now a = [1 8 9 4 5]
- /// @endcode
+ /**
+ Extract a sub-vector. The vector extracted will be begin at element Start
+ and will contain the next Length elements. This version can be used as an
+ l-value as well as an r-value
+ @code
+ Vector<5> a = 1,2,3,4,5;
+ Vector<2> b = 8,9;
+ // replace the two elements starting from element 1 with b
+ a.slice<1, 2>() = b; /// now a = [1 8 9 4 5]
+ @endcode
+ */
template<Start, Length>
Vector<Length>& slice();
- /// Extract a sub-vector with runtime parameters.
- /// The vector extracted will be begin at element start and will
- /// contain the next length elements.
- /// @code
- /// Vector<5> a = (makeVector, 1,2,3,4,5);
- /// Extract the three elements starting from element 2
- /// Vector<3> b = a.slice(2,3); /// b = [3 4 5]
- /// @endcode
+ /**
+ Extract a sub-vector with runtime parameters.
+ The vector extracted will be begin at element start and will contain the next
+ length elements.
+ @code
+ Vector<5> a = (makeVector, 1,2,3,4,5);
+ Extract the three elements starting from element 2
+ Vector<3> b = a.slice(2,3); /// b = [3 4 5]
+ @endcode
+ */
template<Start, Length>
const Vector<Length>& slice() const;
- /// Extract a sub-vector with runtime parameters, which can be used as
an l-value.
- /// The vector extracted will be begin at element start and will
- /// contain the next length elements.
- /// @code
- /// Vector<5> a = (makeVector, 1,2,3,4,5);
- /// Extract the three elements starting from element 2
- /// a.slice(2,3)[0] = 17; /// a -> [1 2 17 4 5]
- /// @endcode
+ /**
+ Extract a sub-vector with runtime parameters, which can be used as an
+ l-value.
+ The vector extracted will be begin at element start and will contain the next
+ length elements.
+ @code
+ Vector<5> a = (makeVector, 1,2,3,4,5);
+ Extract the three elements starting from element 2
+ a.slice(2,3)[0] = 17; /// a -> [1 2 17 4 5]
+ @endcode
+ */
template<Start, Length>
const Vector<Length>& slice() const;
//@}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN/doc matrixdoc.h vectordoc.h,
Paul Smith <=