namespace Eigen { /** \page QuickStartGuide
\include Tutorial_simple_example_fixed_size.cpp | output: \include Tutorial_simple_example_fixed_size.out |
\include Tutorial_simple_example_dynamic_size.cpp | output: \include Tutorial_simple_example_dynamic_size.out |
\code int rows=2, cols=3; cout << MatrixXf::Constant(rows, cols, sqrt(2)); \endcode | output: \code 1.41 1.41 1.41 1.41 1.41 1.41 \endcode |
Fixed-size matrix or vector | Dynamic-size matrix | Dynamic-size vector |
\code Matrix3f x; x = Matrix3f::Zero(); x = Matrix3f::Ones(); x = Matrix3f::Constant(6); x = Matrix3f::Identity(); x = Matrix3f::Random(); x.setZero(); x.setOnes(); x.setIdentity(); x.setConstant(6); x.setRandom(); \endcode | \code MatrixXf x; x = MatrixXf::Zero(rows, cols); x = MatrixXf::Ones(rows, cols); x = MatrixXf::Constant(rows, cols, 6); x = MatrixXf::Identity(rows, cols); x = MatrixXf::Random(rows, cols); x.setZero(rows, cols); x.setOnes(rows, cols); x.setConstant(rows, cols, 6); x.setIdentity(rows, cols); x.setRandom(rows, cols); \endcode | \code VectorXf x; x = VectorXf::Zero(size); x = VectorXf::Ones(size); x = VectorXf::Constant(size, 6); x = VectorXf::Identity(size); x = VectorXf::Random(size); x.setZero(size); x.setOnes(size); x.setConstant(size, 6); x.setIdentity(size); x.setRandom(size); \endcode |
\include Tutorial_commainit_01.cpp | output: \verbinclude Tutorial_commainit_01.out |
\include Tutorial_commainit_02.cpp | output: \verbinclude Tutorial_commainit_02.out |
matrix/vector product | \code col2 = mat1 * col1; row2 = row1 * mat1; row1 *= mat1; mat3 = mat1 * mat2; mat3 *= mat1; \endcode |
add/subtract | \code mat3 = mat1 + mat2; mat3 += mat1; mat3 = mat1 - mat2; mat3 -= mat1;\endcode |
scalar product | \code mat3 = mat1 * s1; mat3 = s1 * mat1; mat3 *= s1; mat3 = mat1 / s1; mat3 /= s1;\endcode |
\link MatrixBase::dot() dot product \endlink (inner product) | \code scalar = vec1.dot(vec2);\endcode |
outer product | \code mat = vec1 * vec2.transpose();\endcode |
\link MatrixBase::cross() cross product \endcode | \code
#include |
Coefficient wise product | \code mat3 = mat1.cwise() * mat2; \endcode |
Add a scalar to all coefficients | \code mat3 = mat1.cwise() + scalar; mat3.cwise() += scalar; mat3.cwise() -= scalar; \endcode |
Coefficient wise division | \code mat3 = mat1.cwise() / mat2; \endcode |
Coefficient wise reciprocal | \code mat3 = mat1.cwise().inverse(); \endcode |
Coefficient wise comparisons \n (support all operators) | \code mat3 = mat1.cwise() < mat2; mat3 = mat1.cwise() <= mat2; mat3 = mat1.cwise() > mat2; etc. \endcode |
Trigo:\n sin, cos, tan | \code mat3 = mat1.cwise().sin(); etc. \endcode |
Power:\n pow, square, cube, sqrt, exp, log | \code mat3 = mat1.cwise().square(); mat3 = mat1.cwise().pow(5); mat3 = mat1.cwise().log(); etc. \endcode |
min, max, absolute value | \code mat3 = mat1.cwise().min(mat2); mat3 = mat1.cwise().max(mat2); mat3 = mat1.cwise().abs(mat2); mat3 = mat1.cwise().abs2(mat2); \endcode |
\code mat \endcode | \code 5 3 1 2 7 8 9 4 6 \endcode | |||
\code mat.minCoeff(); \endcode | \code 1 \endcode | \code mat.maxCoeff(); \endcode | \code 9 \endcode | |
\code mat.colwise().minCoeff(); \endcode | \code 2 3 1 \endcode | \code mat.colwise().maxCoeff(); \endcode | \code 9 7 8 \endcode | |
\code mat.rowwise().minCoeff(); \endcode | \code 1 2 4 \endcode | \code mat.rowwise().maxCoeff(); \endcode | \code 5 8 9 \endcode |
Default versions | Optimized versions when the size is known at compile time | |
\code vec1.start(n)\endcode | \code vec1.start | the first \c n coeffs |
\code vec1.end(n)\endcode | \code vec1.end | the last \c n coeffs |
\code vec1.block(pos,n)\endcode | \code vec1.block |
the \c size coeffs in the range [\c pos : \c pos + \c n [ |
Default versions | Optimized versions when the size is known at compile time | |
\code mat1.block(i,j,rows,cols)\endcode \link MatrixBase::block(int,int,int,int) (more) \endlink | \code mat1.block |
the \c rows x \c cols sub-matrix starting from position (\c i,\c j) |
\code mat1.corner(TopLeft,rows,cols) mat1.corner(TopRight,rows,cols) mat1.corner(BottomLeft,rows,cols) mat1.corner(BottomRight,rows,cols)\endcode \link MatrixBase::corner(CornerType,int,int) (more) \endlink | \code
mat1.corner |
the \c rows x \c cols sub-matrix \n taken in one of the four corners |