Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | Related Functions
MatrixBase Class Reference

Base class for all matrices, vectors, and expressions. More...

List of all members.

Public Types

enum  {
  RowsAtCompileTime,
  ColsAtCompileTime,
  SizeAtCompileTime,
  MaxRowsAtCompileTime,
  MaxColsAtCompileTime,
  MaxSizeAtCompileTime,
  IsVectorAtCompileTime,
  Flags,
  CoeffReadCost
}

Public Member Functions

const AdjointReturnType adjoint () const
bool all (void) const
bool any (void) const
const DiagonalMatrix< Derived > asDiagonal () const
template<typename CustomBinaryOp , typename OtherDerived >
const CwiseBinaryOp
< CustomBinaryOp, Derived,
OtherDerived > 
binaryExpr (const MatrixBase< OtherDerived > &other, const CustomBinaryOp &func=CustomBinaryOp()) const
BlockReturnType< Derived >::Type block (int startRow, int startCol, int blockRows, int blockCols)
const BlockReturnType< Derived >
::Type 
block (int startRow, int startCol, int blockRows, int blockCols) const
template<int BlockRows, int BlockCols>
BlockReturnType< Derived,
BlockRows, BlockCols >::Type 
block (int startRow, int startCol)
template<int BlockRows, int BlockCols>
const BlockReturnType< Derived,
BlockRows, BlockCols >::Type 
block (int startRow, int startCol) const
template<typename NewType >
const CwiseUnaryOp
< ei_scalar_cast_op< typename
ei_traits< Derived >::Scalar,
NewType >, Derived > 
cast () const
const Scalar coeff (int row, int col) const
const Scalar coeff (int index) const
Scalar & coeffRef (int row, int col)
Scalar & coeffRef (int index)
ColXpr col (int i)
const ColXpr col (int i) const
int cols () const
const PartialRedux< Derived,
Vertical > 
colwise () const
template<typename OtherDerived >
void computeInverse (MatrixBase< OtherDerived > *result) const
template<typename ResultType >
void computeInverse (MatrixBase< ResultType > *result) const
ConjugateReturnType conjugate () const
BlockReturnType< Derived >::Type corner (CornerType type, int cRows, int cCols)
const BlockReturnType< Derived >
::Type 
corner (CornerType type, int cRows, int cCols) const
template<int CRows, int CCols>
BlockReturnType< Derived,
CRows, CCols >::Type 
corner (CornerType type)
template<int CRows, int CCols>
const BlockReturnType< Derived,
CRows, CCols >::Type 
corner (CornerType type) const
int count () const
template<typename OtherDerived >
PlainMatrixType cross (const MatrixBase< OtherDerived > &other) const
const Cwise< Derived > cwise () const
Cwise< Derived > cwise ()
Scalar determinant () const
DiagonalCoeffs< Derived > diagonal ()
const DiagonalCoeffs< Derived > diagonal () const
template<typename OtherDerived >
Scalar dot (const MatrixBase< OtherDerived > &other) const
EigenvaluesReturnType eigenvalues () const
BlockReturnType< Derived,
Dynamic >::SubVectorType 
end (int size)
const BlockReturnType< Derived,
Dynamic >::SubVectorType 
end (int size) const
template<int Size>
BlockReturnType< Derived, Size >
::SubVectorType 
end ()
template<int Size>
const BlockReturnType< Derived,
Size >::SubVectorType 
end () const
Matrix< Scalar, 3, 1 > eulerAngles (int a0, int a1, int a2) const
const ei_eval< Derived >::type eval () const
void fill (const Scalar &value)
const WithFormat< Derived > format (const IOFormat &fmt) const
const ImagReturnType imag () const
int innerSize () const
const PlainMatrixType inverse () const
template<typename OtherDerived >
bool isApprox (const MatrixBase< OtherDerived > &other, typename NumTraits< Scalar >::Real prec) const
template<typename OtherDerived >
bool isApprox (const MatrixBase< OtherDerived > &other, RealScalar prec=precision< Scalar >()) const
bool isApproxToConstant (const Scalar &value, RealScalar prec=precision< Scalar >()) const
bool isConstant (const Scalar &value, RealScalar prec=precision< Scalar >()) const
bool isDiagonal (RealScalar prec=precision< Scalar >()) const
bool isIdentity (RealScalar prec=precision< Scalar >()) const
bool isLowerTriangular (RealScalar prec=precision< Scalar >()) const
template<typename Derived >
bool isMuchSmallerThan (const typename NumTraits< Scalar >::Real &other, typename NumTraits< Scalar >::Real prec) const
template<typename OtherDerived >
bool isMuchSmallerThan (const MatrixBase< OtherDerived > &other, typename NumTraits< Scalar >::Real prec) const
bool isMuchSmallerThan (const RealScalar &other, RealScalar prec=precision< Scalar >()) const
template<typename OtherDerived >
bool isMuchSmallerThan (const MatrixBase< OtherDerived > &other, RealScalar prec=precision< Scalar >()) const
bool isOnes (RealScalar prec=precision< Scalar >()) const
template<typename OtherDerived >
bool isOrthogonal (const MatrixBase< OtherDerived > &other, RealScalar prec=precision< Scalar >()) const
bool isUnitary (RealScalar prec=precision< Scalar >()) const
bool isUpperTriangular (RealScalar prec=precision< Scalar >()) const
bool isVector () const
bool isZero (RealScalar prec=precision< Scalar >()) const
const Flagged< Derived,
0, EvalBeforeNestingBit|EvalBeforeAssigningBit > 
lazy () const
template<typename Lhs , typename Rhs >
Derived & lazyAssign (const SparseProduct< Lhs, Rhs, SparseTimeDenseProduct > &product)
template<typename Lhs , typename Rhs >
Derived & lazyAssign (const SparseProduct< Lhs, Rhs, DenseTimeSparseProduct > &product)
template<typename Derived1 , typename Derived2 >
Derived & lazyAssign (const SparseProduct< Derived1, Derived2, SparseTimeDenseProduct > &product)
template<typename Derived1 , typename Derived2 >
Derived & lazyAssign (const SparseProduct< Derived1, Derived2, DenseTimeSparseProduct > &product)
template<typename Lhs , typename Rhs >
Derived & lazyAssign (const Product< Lhs, Rhs, CacheFriendlyProduct > &product)
const LDLT< PlainMatrixType > ldlt () const
const LLT< PlainMatrixType > llt () const
template<int p>
RealScalar lpNorm () const
const LU< PlainMatrixType > lu () const
template<unsigned int Added>
const Flagged< Derived, Added, 0 > marked () const
ei_traits< Derived >::Scalar maxCoeff () const
ei_traits< Derived >::Scalar maxCoeff (int *row, int *col) const
ei_traits< Derived >::Scalar maxCoeff (int *index) const
ei_traits< Derived >::Scalar minCoeff () const
ei_traits< Derived >::Scalar minCoeff (int *row, int *col) const
ei_traits< Derived >::Scalar minCoeff (int *index) const
Minor< Derived > minor (int row, int col)
const Minor< Derived > minor (int row, int col) const
const NestByValue< Derived > nestByValue () const
int nonZeros () const
RealScalar norm () const
void normalize ()
const PlainMatrixType normalized () const
template<typename OtherDerived >
bool operator!= (const MatrixBase< OtherDerived > &other) const
const Scalar operator() (int row, int col) const
Scalar & operator() (int row, int col)
const Scalar operator() (int index) const
Scalar & operator() (int index)
const ScalarMultipleReturnType operator* (const Scalar &scalar) const
template<typename OtherDerived >
const ProductReturnType
< Derived, OtherDerived >
::Type 
operator* (const MatrixBase< OtherDerived > &other) const
Derived & operator*= (const Scalar &other)
template<typename OtherDerived >
Derived & operator*= (const MatrixBase< OtherDerived > &other)
template<typename OtherDerived >
const CwiseBinaryOp
< ei_scalar_sum_op< typename
ei_traits< Derived >::Scalar >
, Derived, OtherDerived > 
operator+ (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived >
Derived & operator+= (const MatrixBase< OtherDerived > &other)
template<typename Lhs , typename Rhs >
Derived & operator+= (const Flagged< Product< Lhs, Rhs, CacheFriendlyProduct >, 0, EvalBeforeNestingBit|EvalBeforeAssigningBit > &other)
const CwiseUnaryOp
< ei_scalar_opposite_op
< typename ei_traits< Derived >
::Scalar >, Derived > 
operator- () const
template<typename OtherDerived >
const CwiseBinaryOp
< ei_scalar_difference_op
< typename ei_traits< Derived >
::Scalar >, Derived,
OtherDerived > 
operator- (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived >
Derived & operator-= (const MatrixBase< OtherDerived > &other)
const CwiseUnaryOp
< ei_scalar_quotient1_op
< typename ei_traits< Derived >
::Scalar >, Derived > 
operator/ (const Scalar &scalar) const
Derived & operator/= (const Scalar &other)
CommaInitializer< Derived > operator<< (const Scalar &s)
template<typename OtherDerived >
CommaInitializer< Derived > operator<< (const MatrixBase< OtherDerived > &other)
template<typename OtherDerived >
Derived & operator= (const MatrixBase< OtherDerived > &other)
Derived & operator= (const MatrixBase &other)
template<typename OtherDerived >
bool operator== (const MatrixBase< OtherDerived > &other) const
const Scalar operator[] (int index) const
Scalar & operator[] (int index)
RealScalar operatorNorm () const
int outerSize () const
template<int LoadMode>
PacketScalar packet (int row, int col) const
template<int LoadMode>
PacketScalar packet (int index) const
template<unsigned int Mode>
Part< Derived, Mode > part ()
template<unsigned int Mode>
const Part< Derived, Mode > part () const
const QR< PlainMatrixType > qr () const
const RealReturnType real () const
template<typename BinaryOp >
ei_result_of< BinaryOp(typename
ei_traits< Derived >::Scalar)>
::type 
redux (const BinaryOp &func) const
RowXpr row (int i)
const RowXpr row (int i) const
int rows () const
const PartialRedux< Derived,
Horizontal > 
rowwise () const
BlockReturnType< Derived >
::SubVectorType 
segment (int start, int size)
const BlockReturnType< Derived >
::SubVectorType 
segment (int start, int size) const
template<int Size>
BlockReturnType< Derived, Size >
::SubVectorType 
segment (int start)
template<int Size>
const BlockReturnType< Derived,
Size >::SubVectorType 
segment (int start) const
template<typename ThenDerived , typename ElseDerived >
const Select< Derived,
ThenDerived, ElseDerived > 
select (const MatrixBase< ThenDerived > &thenMatrix, const MatrixBase< ElseDerived > &elseMatrix) const
template<typename ThenDerived >
const Select< Derived,
ThenDerived, NestByValue
< typename
ThenDerived::ConstantReturnType > > 
select (const MatrixBase< ThenDerived > &thenMatrix, typename ThenDerived::Scalar elseScalar) const
template<typename ElseDerived >
const Select< Derived,
NestByValue< typename
ElseDerived::ConstantReturnType >
, ElseDerived > 
select (typename ElseDerived::Scalar thenScalar, const MatrixBase< ElseDerived > &elseMatrix) const
Derived & setConstant (const Scalar &value)
Derived & setIdentity ()
Derived & setOnes ()
Derived & setRandom ()
Derived & setZero ()
int size () const
template<typename OtherDerived >
ei_plain_matrix_type_column_major
< OtherDerived >::type 
solveTriangular (const MatrixBase< OtherDerived > &other) const
template<typename OtherDerived >
void solveTriangularInPlace (const MatrixBase< OtherDerived > &other) const
RealScalar squaredNorm () const
BlockReturnType< Derived,
Dynamic >::SubVectorType 
start (int size)
const BlockReturnType< Derived,
Dynamic >::SubVectorType 
start (int size) const
template<int Size>
BlockReturnType< Derived, Size >
::SubVectorType 
start (void)
template<int Size>
const BlockReturnType< Derived,
Size >::SubVectorType 
start () const
int stride (void) const
Scalar sum () const
SVD< PlainMatrixType > svd () const
template<typename OtherDerived >
void swap (const MatrixBase< OtherDerived > &other)
Scalar trace () const
Eigen::Transpose< Derived > transpose ()
const Eigen::Transpose< Derived > transpose () const
void transposeInPlace ()
template<typename CustomUnaryOp >
const CwiseUnaryOp
< CustomUnaryOp, Derived > 
unaryExpr (const CustomUnaryOp &func=CustomUnaryOp()) const
PlainMatrixType unitOrthogonal (void) const
template<typename Visitor >
void visit (Visitor &func) const
const Scalar w () const
Scalar & w ()
template<int StoreMode>
void writePacket (int row, int col, const typename ei_packet_traits< typename ei_traits< Derived >::Scalar >::type &x)
template<int StoreMode>
void writePacket (int row, int col, const PacketScalar &x)
template<int StoreMode>
void writePacket (int index, const PacketScalar &x)
template<int StoreMode>
void writePacket (int index, const typename ei_packet_traits< typename ei_traits< Derived >::Scalar >::type &x)
const Scalar x () const
Scalar & x ()
const Scalar y () const
Scalar & y ()
const Scalar z () const
Scalar & z ()

Static Public Member Functions

static const ConstantReturnType Constant (int rows, int cols, const Scalar &value)
static const ConstantReturnType Constant (int size, const Scalar &value)
static const ConstantReturnType Constant (const Scalar &value)
static const IdentityReturnType Identity ()
static const IdentityReturnType Identity (int rows, int cols)
template<typename CustomNullaryOp >
static const CwiseNullaryOp
< CustomNullaryOp, Derived > 
NullaryExpr (int rows, int cols, const CustomNullaryOp &func)
template<typename CustomNullaryOp >
static const CwiseNullaryOp
< CustomNullaryOp, Derived > 
NullaryExpr (int size, const CustomNullaryOp &func)
template<typename CustomNullaryOp >
static const CwiseNullaryOp
< CustomNullaryOp, Derived > 
NullaryExpr (const CustomNullaryOp &func)
static const ConstantReturnType Ones (int rows, int cols)
static const ConstantReturnType Ones (int size)
static const ConstantReturnType Ones ()
static const CwiseNullaryOp
< ei_scalar_random_op< Scalar >
, Derived > 
Random (int rows, int cols)
static const CwiseNullaryOp
< ei_scalar_random_op< Scalar >
, Derived > 
Random (int size)
static const CwiseNullaryOp
< ei_scalar_random_op< Scalar >
, Derived > 
Random ()
static const BasisReturnType Unit (int size, int i)
static const BasisReturnType Unit (int i)
static const BasisReturnType UnitW ()
static const BasisReturnType UnitX ()
static const BasisReturnType UnitY ()
static const BasisReturnType UnitZ ()
static const ConstantReturnType Zero (int rows, int cols)
static const ConstantReturnType Zero (int size)
static const ConstantReturnType Zero ()

Protected Member Functions

 MatrixBase ()

Friends

const CwiseUnaryOp
< ei_scalar_multiple_op
< typename ei_traits< Derived >
::Scalar >, Derived > 
operator* (const Scalar &scalar, const MatrixBase &matrix)

Related Functions

(Note that these are not member functions.)

template<typename Derived >
std::ostream & operator<< (std::ostream &s, const MatrixBase< Derived > &m)

Detailed Description

Base class for all matrices, vectors, and expressions.

This class is the base that is inherited by all matrix, vector, and expression types. Most of the Eigen API is contained in this class. Other important classes for the Eigen API are Matrix, Cwise, and PartialRedux.

Note that some methods are defined in the Array module.

Parameters:
Derivedis the derived type, e.g. a matrix type, or an expression, etc.

When writing a function taking Eigen objects as argument, if you want your function to take as argument any matrix, vector, or expression, just let it take a MatrixBase argument. As an example, here is a function printFirstRow which, given a matrix, vector, or expression x, prints the first row of x.

    template<typename Derived>
    void printFirstRow(const Eigen::MatrixBase<Derived>& x)
    {
      cout << x.row(0) << endl;
    }

Member Enumeration Documentation

anonymous enum
Enumerator:
RowsAtCompileTime 

The number of rows at compile-time. This is just a copy of the value provided by the Derived type. If a value is not known at compile-time, it is set to the Dynamic constant.

See also:
MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime
ColsAtCompileTime 

The number of columns at compile-time. This is just a copy of the value provided by the Derived type. If a value is not known at compile-time, it is set to the Dynamic constant.

See also:
MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime
SizeAtCompileTime 

This is equal to the number of coefficients, i.e. the number of rows times the number of columns, or to Dynamic if this is not known at compile-time.

See also:
RowsAtCompileTime, ColsAtCompileTime
MaxRowsAtCompileTime 

This value is equal to the maximum possible number of rows that this expression might have. If this expression might have an arbitrarily high number of rows, this value is set to Dynamic.

This value is useful to know when evaluating an expression, in order to determine whether it is possible to avoid doing a dynamic memory allocation.

See also:
RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime
MaxColsAtCompileTime 

This value is equal to the maximum possible number of columns that this expression might have. If this expression might have an arbitrarily high number of columns, this value is set to Dynamic.

This value is useful to know when evaluating an expression, in order to determine whether it is possible to avoid doing a dynamic memory allocation.

See also:
ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime
MaxSizeAtCompileTime 

This value is equal to the maximum possible number of coefficients that this expression might have. If this expression might have an arbitrarily high number of coefficients, this value is set to Dynamic.

This value is useful to know when evaluating an expression, in order to determine whether it is possible to avoid doing a dynamic memory allocation.

See also:
SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime
IsVectorAtCompileTime 

This is set to true if either the number of rows or the number of columns is known at compile-time to be equal to 1. Indeed, in that case, we are dealing with a column-vector (if there is only one column) or with a row-vector (if there is only one row).

Flags 

This stores expression flags flags which may or may not be inherited by new expressions constructed from this one. See the list of flags.

CoeffReadCost 

This is a rough measure of how expensive it is to read one coefficient from this expression.


Constructor & Destructor Documentation

MatrixBase ( ) [inline, protected]

Default constructor. Do nothing.


Member Function Documentation

const MatrixBase< Derived >::AdjointReturnType adjoint ( ) const [inline]
Returns:
an expression of the adjoint (i.e. conjugate transpose) of *this.

Example:

Matrix2cf m = Matrix2cf::Random();
cout << "Here is the 2x2 complex matrix m:" << endl << m << endl;
cout << "Here is the adjoint of m:" << endl << m.adjoint() << endl;

Output:

Here is the 2x2 complex matrix m:
 (-0.211,0.68) (-0.605,0.823)
 (0.597,0.566)  (0.536,-0.33)
Here is the adjoint of m:
(-0.211,-0.68) (0.597,-0.566)
(-0.605,-0.823)   (0.536,0.33)
Warning:
If you want to replace a matrix by its own adjoint, do NOT do this:
 m = m.adjoint(); // bug!!! caused by aliasing effect
Instead, do:
 m = m.adjoint().eval();
See also:
transpose(), conjugate(), class Transpose, class ei_scalar_conjugate_op
bool all ( void  ) const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 
Returns:
true if all coefficients are true

Example:

Vector3f boxMin(Vector3f::Zero()), boxMax(Vector3f::Ones());
Vector3f p0 = Vector3f::Random(), p1 = Vector3f::Random().cwise().abs();
// let's check if p0 and p1 are inside the axis aligned box defined by the corners boxMin,boxMax:
cout << "Is (" << p0.transpose() << ") inside the box: "
     << ((boxMin.cwise()<p0).all() && (boxMax.cwise()>p0).all()) << endl;
cout << "Is (" << p1.transpose() << ") inside the box: "
     << ((boxMin.cwise()<p1).all() && (boxMax.cwise()>p1).all()) << endl;

Output:

Is (  0.68 -0.211  0.566) inside the box: 0
Is (0.597 0.823 0.605) inside the box: 1
See also:
MatrixBase::any(), Cwise::operator<()
bool any ( void  ) const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 
Returns:
true if at least one coefficient is true
See also:
MatrixBase::all()
const DiagonalMatrix< Derived > asDiagonal ( ) const [inline]
Warning:
This is not considered to be part of the stable public API yet. Changes may happen in future releases. See Experimental parts of Eigen
Returns:
an expression of a diagonal matrix with *this as vector of diagonal coefficients

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Example:

cout << Vector3i(2,5,6).asDiagonal() << endl;

Output:

2 0 0
0 5 0
0 0 6
See also:
class DiagonalMatrix, isDiagonal()
const CwiseBinaryOp< CustomBinaryOp, Derived, OtherDerived > binaryExpr ( const MatrixBase< OtherDerived > &  other,
const CustomBinaryOp &  func = CustomBinaryOp() 
) const [inline]
Returns:
an expression of a custom coefficient-wise operator func of *this and other

The template parameter CustomBinaryOp is the type of the functor of the custom operator (see class CwiseBinaryOp for an example)

Here is an example illustrating the use of custom functors:

#include <Eigen/Core>
#include <Eigen/Array>
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;

// define a custom template binary functor
template<typename Scalar> struct MakeComplexOp EIGEN_EMPTY_STRUCT {
  typedef complex<Scalar> result_type;
  complex<Scalar> operator()(const Scalar& a, const Scalar& b) const { return complex<Scalar>(a,b); }
};

int main(int, char**)
{
  Matrix4d m1 = Matrix4d::Random(), m2 = Matrix4d::Random();
  cout << m1.binaryExpr(m2, MakeComplexOp<double>()) << endl;
  return 0;
}

Output:

   (0.68,0.271)  (0.823,-0.967) (-0.444,-0.687)   (-0.27,0.998)
 (-0.211,0.435) (-0.605,-0.514)  (0.108,-0.198) (0.0268,-0.563)
 (0.566,-0.717)  (-0.33,-0.726) (-0.0452,-0.74)  (0.904,0.0259)
  (0.597,0.214)   (0.536,0.608)  (0.258,-0.782)   (0.832,0.678)
See also:
class CwiseBinaryOp, MatrixBase::operator+, MatrixBase::operator-, Cwise::operator*, Cwise::operator/
BlockReturnType< Derived >::Type block ( int  startRow,
int  startCol,
int  blockRows,
int  blockCols 
) [inline]
Returns:
a dynamic-size expression of a block in *this.
Parameters:
startRowthe first row in the block
startColthe first column in the block
blockRowsthe number of rows in the block
blockColsthe number of columns in the block

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.block(1, 1, 2, 2):" << endl << m.block(1, 1, 2, 2) << endl;
m.block(1, 1, 2, 2).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.block(1, 1, 2, 2):
-6 1
-3 0
Now the matrix m is:
 7  9 -5 -3
-2  0  0  0
 6  0  0  9
 6  6  3  9
Note:
Even though the returned expression has dynamic size, in the case when it is applied to a fixed-size matrix, it inherits a fixed maximal size, which means that evaluating it does not cause a dynamic memory allocation.
See also:
class Block, block(int,int)
const BlockReturnType< Derived >::Type block ( int  startRow,
int  startCol,
int  blockRows,
int  blockCols 
) const [inline]

This is the const version of block(int,int,int,int).

BlockReturnType< Derived, BlockRows, BlockCols >::Type block ( int  startRow,
int  startCol 
) [inline]
Returns:
a fixed-size expression of a block in *this.

The template parameters BlockRows and BlockCols are the number of rows and columns in the block.

Parameters:
startRowthe first row in the block
startColthe first column in the block

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.block<2,2>(1,1):" << endl << m.block<2,2>(1,1) << endl;
m.block<2,2>(1,1).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is m.block<2,2>(1,1):
-6 1
-3 0
Now the matrix m is:
 7  9 -5 -3
-2  0  0  0
 6  0  0  9
 6  6  3  9
Note:
since block is a templated member, the keyword template has to be used if the matrix type is also a template parameter:
 m.template block<3,3>(1,1); 
See also:
class Block, block(int,int,int,int)
const BlockReturnType< Derived, BlockRows, BlockCols >::Type block ( int  startRow,
int  startCol 
) const [inline]

This is the const version of block<>(int, int).

const CwiseUnaryOp< ei_scalar_cast_op< typename ei_traits< Derived >::Scalar, NewType >, Derived > cast ( ) const [inline]
Returns:
an expression of *this with the Scalar type casted to NewScalar.

The template parameter NewScalar is the type we are casting the scalars to.

See also:
class CwiseUnaryOp
const ei_traits< Derived >::Scalar coeff ( int  row,
int  col 
) const [inline]

Short version: don't use this function, use operator()(int,int) const instead.

Long version: this function is similar to operator()(int,int) const , but without the assertion. Use this for limiting the performance cost of debugging code when doing repeated coefficient access. Only use this when it is guaranteed that the parameters row and col are in range.

If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this function equivalent to operator()(int,int) const .

See also:
operator()(int,int) const, coeffRef(int,int), coeff(int) const
const ei_traits< Derived >::Scalar coeff ( int  index) const [inline]

Short version: don't use this function, use operator[](int) const instead.

Long version: this function is similar to operator[](int) const , but without the assertion. Use this for limiting the performance cost of debugging code when doing repeated coefficient access. Only use this when it is guaranteed that the parameter index is in range.

If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this function equivalent to operator[](int) const .

See also:
operator[](int) const, coeffRef(int), coeff(int,int) const
ei_traits< Derived >::Scalar & coeffRef ( int  row,
int  col 
) [inline]

Short version: don't use this function, use operator()(int,int) instead.

Long version: this function is similar to operator()(int,int), but without the assertion. Use this for limiting the performance cost of debugging code when doing repeated coefficient access. Only use this when it is guaranteed that the parameters row and col are in range.

If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this function equivalent to operator()(int,int).

See also:
operator()(int,int), coeff(int, int) const, coeffRef(int)
ei_traits< Derived >::Scalar & coeffRef ( int  index) [inline]

Short version: don't use this function, use operator[](int) instead.

Long version: this function is similar to operator[](int), but without the assertion. Use this for limiting the performance cost of debugging code when doing repeated coefficient access. Only use this when it is guaranteed that the parameters row and col are in range.

If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this function equivalent to operator[](int).

See also:
operator[](int), coeff(int) const, coeffRef(int,int)
MatrixBase< Derived >::ColXpr col ( int  i) [inline]
Returns:
an expression of the i-th column of *this. Note that the numbering starts at 0.

Example:

Matrix3d m = Matrix3d::Identity();
m.col(1) = Vector3d(4,5,6);
cout << m << endl;

Output:

1 4 0
0 5 0
0 6 1
See also:
row(), class Block

Reimplemented in Part.

const MatrixBase< Derived >::ColXpr col ( int  i) const [inline]

This is the const version of col().

int cols ( ) const [inline]
const PartialRedux< Derived, Vertical > colwise ( ) const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 
Returns:
a PartialRedux wrapper of *this providing additional partial reduction operations

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the sum of each column:" << endl << m.colwise().sum() << endl;
cout << "Here is the maximum absolute value of each column:"
     << endl << m.cwise().abs().colwise().maxCoeff() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the sum of each column:
  1.04  0.815 -0.238
Here is the maximum absolute value of each column:
 0.68 0.823 0.536
See also:
rowwise(), class PartialRedux
void computeInverse ( MatrixBase< OtherDerived > *  result) const [inline]

This is defined in the LU module.

 #include <Eigen/LU> 

Computes the matrix inverse of this matrix.

Note:
This matrix must be invertible, otherwise the result is undefined.
Parameters:
resultPointer to the matrix in which to store the result.

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
Matrix3d inv;
m.computeInverse(&inv);
cout << "Its inverse is:" << endl << inv << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Its inverse is:
-0.199   2.23   2.84
  1.01 -0.555  -1.42
 -1.62   3.59   3.29
See also:
inverse()
MatrixBase< Derived >::ConjugateReturnType conjugate ( ) const [inline]
Returns:
an expression of the complex conjugate of *this.
See also:
adjoint()
const MatrixBase< Derived >::ConstantReturnType Constant ( int  rows,
int  cols,
const Scalar &  value 
) [inline, static]
Returns:
an expression of a constant matrix of value value

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this MatrixBase type.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so Zero() should be used instead.

The template parameter CustomNullaryOp is the type of the functor.

See also:
class CwiseNullaryOp
const MatrixBase< Derived >::ConstantReturnType Constant ( int  size,
const Scalar &  value 
) [inline, static]
Returns:
an expression of a constant matrix of value value

The parameter size is the size of the returned vector. Must be compatible with this MatrixBase type.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

This variant is meant to be used for dynamic-size vector types. For fixed-size types, it is redundant to pass size as argument, so Zero() should be used instead.

The template parameter CustomNullaryOp is the type of the functor.

See also:
class CwiseNullaryOp
const MatrixBase< Derived >::ConstantReturnType Constant ( const Scalar &  value) [inline, static]
Returns:
an expression of a constant matrix of value value

This variant is only for fixed-size MatrixBase types. For dynamic-size types, you need to use the variants taking size arguments.

The template parameter CustomNullaryOp is the type of the functor.

See also:
class CwiseNullaryOp
BlockReturnType< Derived >::Type corner ( CornerType  type,
int  cRows,
int  cCols 
) [inline]
Returns:
a dynamic-size expression of a corner of *this.
Parameters:
typethe type of corner. Can be Eigen::TopLeft, Eigen::TopRight, Eigen::BottomLeft, Eigen::BottomRight.
cRowsthe number of rows in the corner
cColsthe number of columns in the corner

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the bottom-right 2x3 corner in m:" << endl
     << m.corner(Eigen::BottomRight, 2, 3) << endl;
m.corner(Eigen::BottomRight, 2, 3).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is the bottom-right 2x3 corner in m:
-3 0 9
6 3 9
Now the matrix m is:
 7  9 -5 -3
-2 -6  1  0
 6  0  0  0
 6  0  0  0
Note:
Even though the returned expression has dynamic size, in the case when it is applied to a fixed-size matrix, it inherits a fixed maximal size, which means that evaluating it does not cause a dynamic memory allocation.
See also:
class Block, block(int,int,int,int)
const BlockReturnType< Derived >::Type corner ( CornerType  type,
int  cRows,
int  cCols 
) const [inline]

This is the const version of corner(CornerType, int, int).

BlockReturnType< Derived, CRows, CCols >::Type corner ( CornerType  type) [inline]
Returns:
a fixed-size expression of a corner of *this.
Parameters:
typethe type of corner. Can be Eigen::TopLeft, Eigen::TopRight, Eigen::BottomLeft, Eigen::BottomRight.

The template parameters CRows and CCols arethe number of rows and columns in the corner.

Example:

Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the bottom-right 2x3 corner in m:" << endl
     << m.corner<2,3>(Eigen::BottomRight) << endl;
m.corner<2,3>(Eigen::BottomRight).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  9 -5 -3
-2 -6  1  0
 6 -3  0  9
 6  6  3  9
Here is the bottom-right 2x3 corner in m:
-3 0 9
6 3 9
Now the matrix m is:
 7  9 -5 -3
-2 -6  1  0
 6  0  0  0
 6  0  0  0
See also:
class Block, block(int,int,int,int)
const BlockReturnType< Derived, CRows, CCols >::Type corner ( CornerType  type) const [inline]

This is the const version of corner<int, int>(CornerType).

int count ( ) const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 
Returns:
the number of coefficients which evaluate to true
See also:
MatrixBase::all(), MatrixBase::any()
MatrixBase< Derived >::PlainMatrixType cross ( const MatrixBase< OtherDerived > &  other) const [inline]

This is defined in the Geometry module.

 #include <Eigen/Geometry> 
Returns:
the cross product of *this and other

Here is a very good explanation of cross-product: http://xkcd.com/199/

const Cwise< Derived > cwise ( ) const [inline]
Returns:
a Cwise wrapper of *this providing additional coefficient-wise operations

Example:

Vector3d v(-1,2,-3);
cout << "the absolute values:" << endl << v.cwise().abs() << endl;
cout << "the absolute values plus one:" << endl << v.cwise().abs().cwise()+1 << endl;
cout << "sum of the squares: " << v.cwise().square().sum() << endl;

Output:

the absolute values:
1
2
3
the absolute values plus one:
2
3
4
sum of the squares: 14
See also:
class Cwise, cwise()
Cwise< Derived > cwise ( ) [inline]
Returns:
a Cwise wrapper of *this providing additional coefficient-wise operations

Example:

Vector3d v(1,2,3);
v.cwise() += 3;
v.cwise() -= 2;
cout << v << endl;

Output:

2
3
4
See also:
class Cwise, cwise() const
ei_traits< Derived >::Scalar determinant ( ) const [inline]

This is defined in the LU module.

 #include <Eigen/LU> 
Returns:
the determinant of this matrix
DiagonalCoeffs< Derived > diagonal ( ) [inline]
Returns:
an expression of the main diagonal of the matrix *this

*this is not required to be square.

Example:

Matrix3i m = Matrix3i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here are the coefficients on the main diagonal of m:" << endl
     << m.diagonal() << endl;

Output:

Here is the matrix m:
 7  6 -3
-2  9  6
 6 -6 -5
Here are the coefficients on the main diagonal of m:
7
9
-5
See also:
class DiagonalCoeffs
const DiagonalCoeffs< Derived > diagonal ( ) const [inline]

This is the const version of diagonal().

ei_traits< Derived >::Scalar dot ( const MatrixBase< OtherDerived > &  other) const
Returns:
the dot product of *this with other.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Note:
If the scalar type is complex numbers, then this function returns the hermitian (sesquilinear) dot product, linear in the first variable and conjugate-linear in the second variable.
See also:
squaredNorm(), norm()
Matrix< typename NumTraits< typename ei_traits< Derived >::Scalar >::Real, ei_traits< Derived >::ColsAtCompileTime, 1 > eigenvalues ( ) const [inline]

This is defined in the QR module.

 #include <Eigen/QR> 
Returns:
a vector listing the eigenvalues of this matrix.
BlockReturnType< Derived, Dynamic >::SubVectorType end ( int  size) [inline]
Returns:
a dynamic-size expression of the last coefficients of *this.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Parameters:
sizethe number of coefficients in the block

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.end(2):" << endl << v.end(2) << endl;
v.end(2).setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.end(2):
6 6
Now the vector v is:
 7 -2  0  0
Note:
Even though the returned expression has dynamic size, in the case when it is applied to a fixed-size vector, it inherits a fixed maximal size, which means that evaluating it does not cause a dynamic memory allocation.
See also:
class Block, block(int,int)
const BlockReturnType< Derived, Dynamic >::SubVectorType end ( int  size) const [inline]

This is the const version of end(int).

BlockReturnType< Derived, Size >::SubVectorType end ( ) [inline]
Returns:
a fixed-size expression of the last coefficients of *this.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

The template parameter Size is the number of coefficients in the block

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.end(2):" << endl << v.end<2>() << endl;
v.end<2>().setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.end(2):
6 6
Now the vector v is:
 7 -2  0  0
See also:
class Block
const BlockReturnType< Derived, Size >::SubVectorType end ( ) const [inline]

This is the const version of end<int>.

const ei_eval<Derived>::type eval ( ) const [inline]
Returns:
the matrix or vector obtained by evaluating this expression.

Notice that in the case of a plain matrix or vector (not an expression) this function just returns a const reference, in order to avoid a useless copy.

void fill ( const Scalar &  value) [inline]

Alias for setConstant(): sets all coefficients in this expression to value.

See also:
setConstant(), Constant(), class CwiseNullaryOp
const WithFormat< Derived > format ( const IOFormat fmt) const [inline]
Returns:
a WithFormat proxy object allowing to print a matrix the with given format fmt.

See class IOFormat for some examples.

See also:
class IOFormat, class WithFormat
const MatrixBase< Derived >::IdentityReturnType Identity ( ) [inline, static]
Returns:
an expression of the identity matrix (not necessarily square).

This variant is only for fixed-size MatrixBase types. For dynamic-size types, you need to use the variant taking size arguments.

Example:

cout << Matrix<double, 3, 4>::Identity() << endl;

Output:

1 0 0 0
0 1 0 0
0 0 1 0
See also:
Identity(int,int), setIdentity(), isIdentity()
const MatrixBase< Derived >::IdentityReturnType Identity ( int  rows,
int  cols 
) [inline, static]
Returns:
an expression of the identity matrix (not necessarily square).

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this MatrixBase type.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so Identity() should be used instead.

Example:

cout << MatrixXd::Identity(4, 3) << endl;

Output:

1 0 0
0 1 0
0 0 1
0 0 0
See also:
Identity(), setIdentity(), isIdentity()
const MatrixBase< Derived >::ImagReturnType imag ( ) const [inline]
Returns:
an expression of the imaginary part of *this.
See also:
real()
int innerSize ( ) const [inline]
Returns:
the size of the inner dimension according to the storage order, i.e., the number of rows for a columns major matrix, and the number of cols otherwise
const MatrixBase< Derived >::PlainMatrixType inverse ( ) const [inline]

This is defined in the LU module.

 #include <Eigen/LU> 
Returns:
the matrix inverse of this matrix.
Note:
This matrix must be invertible, otherwise the result is undefined.
This method returns a matrix by value, which can be inefficient. To avoid that overhead, use computeInverse() instead.

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Its inverse is:" << endl << m.inverse() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Its inverse is:
-0.199   2.23   2.84
  1.01 -0.555  -1.42
 -1.62   3.59   3.29
See also:
computeInverse()
bool isApprox ( const MatrixBase< OtherDerived > &  other,
typename NumTraits< Scalar >::Real  prec 
) const
Returns:
true if *this is approximately equal to other, within the precision determined by prec.
Note:
The fuzzy compares are done multiplicatively. Two vectors $ v $ and $ w $ are considered to be approximately equal within precision $ p $ if

\[ \Vert v - w \Vert \leqslant p\,\min(\Vert v\Vert, \Vert w\Vert). \]

For matrices, the comparison is done using the Hilbert-Schmidt norm (aka Frobenius norm L2 norm).
Because of the multiplicativeness of this comparison, one can't use this function to check whether *this is approximately equal to the zero matrix or vector. Indeed, isApprox(zero) returns false unless *this itself is exactly the zero matrix or vector. If you want to test whether *this is zero, use ei_isMuchSmallerThan(const RealScalar&, RealScalar) instead.
See also:
ei_isMuchSmallerThan(const RealScalar&, RealScalar) const
bool isApproxToConstant ( const Scalar &  value,
RealScalar  prec = precision<Scalar>() 
) const
Returns:
true if all coefficients in this matrix are approximately equal to value, to within precision prec
bool isConstant ( const Scalar &  value,
RealScalar  prec = precision<Scalar>() 
) const

This is just an alias for isApproxToConstant().

Returns:
true if all coefficients in this matrix are approximately equal to value, to within precision prec
bool isDiagonal ( RealScalar  prec = precision<Scalar>()) const
Warning:
This is not considered to be part of the stable public API yet. Changes may happen in future releases. See Experimental parts of Eigen
Returns:
true if *this is approximately equal to a diagonal matrix, within the precision given by prec.

Example:

Matrix3d m = 10000 * Matrix3d::Identity();
m(0,2) = 1;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isDiagonal() returns: " << m.isDiagonal() << endl;
cout << "m.isDiagonal(1e-3) returns: " << m.isDiagonal(1e-3) << endl;

Output:

Here's the matrix m:
1e+04     0     1
    0 1e+04     0
    0     0 1e+04
m.isDiagonal() returns: 0
m.isDiagonal(1e-3) returns: 1
See also:
asDiagonal()
bool isIdentity ( RealScalar  prec = precision<Scalar>()) const
Returns:
true if *this is approximately equal to the identity matrix (not necessarily square), within the precision given by prec.

Example:

Matrix3d m = Matrix3d::Identity();
m(0,2) = 1e-4;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isIdentity() returns: " << m.isIdentity() << endl;
cout << "m.isIdentity(1e-3) returns: " << m.isIdentity(1e-3) << endl;

Output:

Here's the matrix m:
     1      0 0.0001
     0      1      0
     0      0      1
m.isIdentity() returns: 0
m.isIdentity(1e-3) returns: 1
See also:
class CwiseNullaryOp, Identity(), Identity(int,int), setIdentity()
bool isLowerTriangular ( RealScalar  prec = precision<Scalar>()) const
Returns:
true if *this is approximately equal to a lower triangular matrix, within the precision given by prec.
See also:
isUpperTriangular(), extract(), part(), marked()
bool isMuchSmallerThan ( const typename NumTraits< Scalar >::Real &  other,
typename NumTraits< Scalar >::Real  prec 
) const
Returns:
true if the norm of *this is much smaller than other, within the precision determined by prec.
Note:
The fuzzy compares are done multiplicatively. A vector $ v $ is considered to be much smaller than $ x $ within precision $ p $ if

\[ \Vert v \Vert \leqslant p\,\vert x\vert. \]

For matrices, the comparison is done using the Hilbert-Schmidt norm. For this reason, the value of the reference scalar other should come from the Hilbert-Schmidt norm of a reference matrix of same dimensions.

See also:
isApprox(), isMuchSmallerThan(const MatrixBase<OtherDerived>&, RealScalar) const
bool isMuchSmallerThan ( const MatrixBase< OtherDerived > &  other,
typename NumTraits< Scalar >::Real  prec 
) const
Returns:
true if the norm of *this is much smaller than the norm of other, within the precision determined by prec.
Note:
The fuzzy compares are done multiplicatively. A vector $ v $ is considered to be much smaller than a vector $ w $ within precision $ p $ if

\[ \Vert v \Vert \leqslant p\,\Vert w\Vert. \]

For matrices, the comparison is done using the Hilbert-Schmidt norm.
See also:
isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const
bool isOnes ( RealScalar  prec = precision<Scalar>()) const
Returns:
true if *this is approximately equal to the matrix where all coefficients are equal to 1, within the precision given by prec.

Example:

Matrix3d m = Matrix3d::Ones();
m(0,2) += 1e-4;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isOnes() returns: " << m.isOnes() << endl;
cout << "m.isOnes(1e-3) returns: " << m.isOnes(1e-3) << endl;

Output:

Here's the matrix m:
1 1 1
1 1 1
1 1 1
m.isOnes() returns: 0
m.isOnes(1e-3) returns: 1
See also:
class CwiseNullaryOp, Ones()
bool isOrthogonal ( const MatrixBase< OtherDerived > &  other,
RealScalar  prec = precision<Scalar>() 
) const
Returns:
true if *this is approximately orthogonal to other, within the precision given by prec.

Example:

Vector3d v(1,0,0);
Vector3d w(1e-4,0,1);
cout << "Here's the vector v:" << endl << v << endl;
cout << "Here's the vector w:" << endl << w << endl;
cout << "v.isOrthogonal(w) returns: " << v.isOrthogonal(w) << endl;
cout << "v.isOrthogonal(w,1e-3) returns: " << v.isOrthogonal(w,1e-3) << endl;

Output:

Here's the vector v:
1
0
0
Here's the vector w:
0.0001
0
1
v.isOrthogonal(w) returns: 0
v.isOrthogonal(w,1e-3) returns: 1
bool isUnitary ( RealScalar  prec = precision<Scalar>()) const
Returns:
true if *this is approximately an unitary matrix, within the precision given by prec. In the case where the Scalar type is real numbers, a unitary matrix is an orthogonal matrix, whence the name.
Note:
This can be used to check whether a family of vectors forms an orthonormal basis. Indeed, m.isUnitary() returns true if and only if the columns (equivalently, the rows) of m form an orthonormal basis.

Example:

Matrix3d m = Matrix3d::Identity();
m(0,2) = 1e-4;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isUnitary() returns: " << m.isUnitary() << endl;
cout << "m.isUnitary(1e-3) returns: " << m.isUnitary(1e-3) << endl;

Output:

Here's the matrix m:
     1      0 0.0001
     0      1      0
     0      0      1
m.isUnitary() returns: 0
m.isUnitary(1e-3) returns: 1
bool isUpperTriangular ( RealScalar  prec = precision<Scalar>()) const
Returns:
true if *this is approximately equal to an upper triangular matrix, within the precision given by prec.
See also:
isLowerTriangular(), extract(), part(), marked()
bool isVector ( ) const [inline]
Returns:
true if either the number of rows or the number of columns is equal to 1. In other words, this function returns
 rows()==1 || cols()==1 
See also:
rows(), cols(), IsVectorAtCompileTime.
bool isZero ( RealScalar  prec = precision<Scalar>()) const
Returns:
true if *this is approximately equal to the zero matrix, within the precision given by prec.

Example:

Matrix3d m = Matrix3d::Zero();
m(0,2) = 1e-4;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isZero() returns: " << m.isZero() << endl;
cout << "m.isZero(1e-3) returns: " << m.isZero(1e-3) << endl;

Output:

Here's the matrix m:
     0      0 0.0001
     0      0      0
     0      0      0
m.isZero() returns: 0
m.isZero(1e-3) returns: 1
See also:
class CwiseNullaryOp, Zero()
const Flagged< Derived, 0, EvalBeforeNestingBit|EvalBeforeAssigningBit > lazy ( ) const [inline]
Returns:
an expression of *this with the following flags removed: EvalBeforeNestingBit and EvalBeforeAssigningBit.

Example:

Matrix2d m; m << 1,2,3,4;
cout << (m*m).lazy().row(0) << endl;
 // this computes only one row of the product. By contrast,
 // if we did "(m*m).row(0);" then m*m would first be evaluated into
 // a temporary, because the Product expression has the EvalBeforeNestingBit.

Output:

 7 10
See also:
class Flagged, marked()
const LDLT< typename MatrixBase< Derived >::PlainMatrixType > ldlt ( ) const [inline]

This is defined in the Cholesky module.

 #include <Eigen/Cholesky> 
Returns:
the Cholesky decomposition without square root of *this
const LLT< typename MatrixBase< Derived >::PlainMatrixType > llt ( ) const [inline]

This is defined in the Cholesky module.

 #include <Eigen/Cholesky> 
Returns:
the LLT decomposition of *this
NumTraits< typename ei_traits< Derived >::Scalar >::Real lpNorm ( ) const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 
Returns:
the $ \ell^p $ norm of *this, that is, returns the p-th root of the sum of the p-th powers of the absolute values of the coefficients of *this. If p is the special value Eigen::Infinity, this function returns the $ \ell^p\infty $ norm, that is the maximum of the absolute values of the coefficients of *this.
See also:
norm()
const LU< typename MatrixBase< Derived >::PlainMatrixType > lu ( ) const [inline]

This is defined in the LU module.

 #include <Eigen/LU> 
Returns:
the LU decomposition of *this.
See also:
class LU
const Flagged< Derived, Added, 0 > marked ( ) const [inline]
Returns:
an expression of *this with added flags

Example:

Matrix3d m = Matrix3d::Zero();
m.part<Eigen::UpperTriangular>().setOnes();
cout << "Here is the matrix m:" << endl << m << endl;
Matrix3d n = Matrix3d::Ones();
n.part<Eigen::LowerTriangular>() *= 2;
cout << "Here is the matrix n:" << endl << n << endl;
cout << "And now here is m.inverse()*n, taking advantage of the fact that"
        " m is upper-triangular:" << endl
     << m.marked<Eigen::UpperTriangular>().solveTriangular(n);

Output:

Here is the matrix m:
1 1 1
0 1 1
0 0 1
Here is the matrix n:
2 1 1
2 2 1
2 2 2
And now here is m.inverse()*n, taking advantage of the fact that m is upper-triangular:
 0 -1  0
 0  0 -1
 2  2  2
See also:
class Flagged, extract(), part()
ei_traits< Derived >::Scalar maxCoeff ( ) const [inline]
Returns:
the maximum of all coefficients of *this
ei_traits< Derived >::Scalar maxCoeff ( int *  row,
int *  col 
) const
Returns:
the maximum of all coefficients of *this and puts in *row and *col its location.
See also:
MatrixBase::minCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::maxCoeff()
ei_traits< Derived >::Scalar maxCoeff ( int *  index) const
Returns:
the maximum of all coefficients of *this and puts in *index its location.
See also:
MatrixBase::maxCoeff(int*,int*), MatrixBase::minCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::maxCoeff()
ei_traits< Derived >::Scalar minCoeff ( ) const [inline]
Returns:
the minimum of all coefficients of *this
ei_traits< Derived >::Scalar minCoeff ( int *  row,
int *  col 
) const
Returns:
the minimum of all coefficients of *this and puts in *row and *col its location.
See also:
MatrixBase::minCoeff(int*), MatrixBase::maxCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::minCoeff()
ei_traits< Derived >::Scalar minCoeff ( int *  index) const
Returns:
the minimum of all coefficients of *this and puts in *index its location.
See also:
MatrixBase::minCoeff(int*,int*), MatrixBase::maxCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::minCoeff()
Minor< Derived > minor ( int  row,
int  col 
) [inline]
Warning:
This is not considered to be part of the stable public API yet. Changes may happen in future releases. See Experimental parts of Eigen
Returns:
an expression of the (row, col)-minor of *this, i.e. an expression constructed from *this by removing the specified row and column.

Example:

Matrix3i m = Matrix3i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.minor(1,1):" << endl << m.minor(1,1) << endl;

Output:

Here is the matrix m:
 7  6 -3
-2  9  6
 6 -6 -5
Here is m.minor(1,1):
 7 -3
 6 -5
See also:
class Minor
const Minor< Derived > minor ( int  row,
int  col 
) const [inline]
Warning:
This is not considered to be part of the stable public API yet. Changes may happen in future releases. See Experimental parts of Eigen This is the const version of minor().
const NestByValue< Derived > nestByValue ( ) const [inline]
Returns:
an expression of the temporary version of *this.
int nonZeros ( ) const [inline]
Returns:
the number of nonzero coefficients which is in practice the number of stored coefficients.
NumTraits< typename ei_traits< Derived >::Scalar >::Real norm ( ) const [inline]
Returns:
the l2 norm of *this, i.e., for vectors, the square root of the dot product of *this with itself.
See also:
dot(), squaredNorm()
void normalize ( ) [inline]

Normalizes the vector, i.e. divides it by its own norm.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also:
norm(), normalized()
const MatrixBase< Derived >::PlainMatrixType normalized ( ) const [inline]
Returns:
an expression of the quotient of *this by its own norm.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also:
norm(), normalize()
const CwiseNullaryOp< CustomNullaryOp, Derived > NullaryExpr ( int  rows,
int  cols,
const CustomNullaryOp &  func 
) [inline, static]
Returns:
an expression of a matrix defined by a custom functor func

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this MatrixBase type.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so Zero() should be used instead.

The template parameter CustomNullaryOp is the type of the functor.

See also:
class CwiseNullaryOp
const CwiseNullaryOp< CustomNullaryOp, Derived > NullaryExpr ( int  size,
const CustomNullaryOp &  func 
) [inline, static]
Returns:
an expression of a matrix defined by a custom functor func

The parameter size is the size of the returned vector. Must be compatible with this MatrixBase type.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

This variant is meant to be used for dynamic-size vector types. For fixed-size types, it is redundant to pass size as argument, so Zero() should be used instead.

The template parameter CustomNullaryOp is the type of the functor.

See also:
class CwiseNullaryOp
const CwiseNullaryOp< CustomNullaryOp, Derived > NullaryExpr ( const CustomNullaryOp &  func) [inline, static]
Returns:
an expression of a matrix defined by a custom functor func

This variant is only for fixed-size MatrixBase types. For dynamic-size types, you need to use the variants taking size arguments.

The template parameter CustomNullaryOp is the type of the functor.

See also:
class CwiseNullaryOp
const MatrixBase< Derived >::ConstantReturnType Ones ( int  rows,
int  cols 
) [inline, static]
Returns:
an expression of a matrix where all coefficients equal one.

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this MatrixBase type.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so Ones() should be used instead.

Example:

cout << MatrixXi::Ones(2,3) << endl;

Output:

1 1 1
1 1 1
See also:
Ones(), Ones(int), isOnes(), class Ones
const MatrixBase< Derived >::ConstantReturnType Ones ( int  size) [inline, static]
Returns:
an expression of a vector where all coefficients equal one.

The parameter size is the size of the returned vector. Must be compatible with this MatrixBase type.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

This variant is meant to be used for dynamic-size vector types. For fixed-size types, it is redundant to pass size as argument, so Ones() should be used instead.

Example:

cout << 6 * RowVectorXi::Ones(4) << endl;
cout << VectorXf::Ones(2) << endl;

Output:

6 6 6 6
1
1
See also:
Ones(), Ones(int,int), isOnes(), class Ones
const MatrixBase< Derived >::ConstantReturnType Ones ( ) [inline, static]
Returns:
an expression of a fixed-size matrix or vector where all coefficients equal one.

This variant is only for fixed-size MatrixBase types. For dynamic-size types, you need to use the variants taking size arguments.

Example:

cout << Matrix2d::Ones() << endl;
cout << 6 * RowVector4i::Ones() << endl;

Output:

1 1
1 1
6 6 6 6
See also:
Ones(int), Ones(int,int), isOnes(), class Ones
const ei_traits< Derived >::Scalar operator() ( int  row,
int  col 
) const [inline]
Returns:
the coefficient at given the given row and column.
See also:
operator()(int,int), operator[](int) const
ei_traits< Derived >::Scalar & operator() ( int  row,
int  col 
) [inline]
Returns:
a reference to the coefficient at given the given row and column.
See also:
operator()(int,int) const, operator[](int)
const ei_traits< Derived >::Scalar operator() ( int  index) const [inline]
Returns:
the coefficient at given index.

This is synonymous to operator[](int) const.

This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.

See also:
operator[](int), operator()(int,int) const, x() const, y() const, z() const, w() const
ei_traits< Derived >::Scalar & operator() ( int  index) [inline]
Returns:
a reference to the coefficient at given index.

This is synonymous to operator[](int).

This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.

See also:
operator[](int) const, operator()(int,int), x(), y(), z(), w()
const ProductReturnType< Derived, OtherDerived >::Type operator* ( const MatrixBase< OtherDerived > &  other) const [inline]
Returns:
the matrix product of *this and other.
Note:
If instead of the matrix product you want the coefficient-wise product, see Cwise::operator*().
See also:
lazy(), operator*=(const MatrixBase&), Cwise::operator*()
Derived & operator*= ( const MatrixBase< OtherDerived > &  other) [inline]

replaces *this by *this * other.

Returns:
a reference to *this
Derived & operator+= ( const MatrixBase< OtherDerived > &  other) [inline]

replaces *this by *this + other.

Returns:
a reference to *this
const CwiseUnaryOp< ei_scalar_opposite_op< typename ei_traits< Derived >::Scalar >, Derived > operator- ( ) const [inline]
Returns:
an expression of the opposite of *this
const CwiseBinaryOp< ei_scalar_difference_op< typename ei_traits< Derived >::Scalar >, Derived, OtherDerived > operator- ( const MatrixBase< OtherDerived > &  other) const [inline]
Returns:
an expression of the difference of *this and other
Note:
If you want to substract a given scalar from all coefficients, see Cwise::operator-().
See also:
class CwiseBinaryOp, MatrixBase::operator-=(), Cwise::operator-()
Derived & operator-= ( const MatrixBase< OtherDerived > &  other) [inline]

replaces *this by *this - other.

Returns:
a reference to *this
CommaInitializer< Derived > operator<< ( const Scalar &  s) [inline]

Convenient operator to set the coefficients of a matrix.

The coefficients must be provided in a row major order and exactly match the size of the matrix. Otherwise an assertion is raised.

Example:

Matrix3i m1;
m1 << 1, 2, 3,
      4, 5, 6,
      7, 8, 9;
cout << m1 << endl << endl;
Matrix3i m2 = Matrix3i::Identity();
m2.block(0,0, 2,2) << 10, 11, 12, 13;
cout << m2 << endl << endl;
Vector2i v1;
v1 << 14, 15;
m2 << v1.transpose(), 16,
      v1, m1.block(1,1,2,2);
cout << m2 << endl;

Output:

1 2 3
4 5 6
7 8 9

10 11  0
12 13  0
 0  0  1

14 15 16
14  5  6
15  8  9
See also:
CommaInitializer::finished(), class CommaInitializer
CommaInitializer< Derived > operator<< ( const MatrixBase< OtherDerived > &  other) [inline]
Derived& operator= ( const MatrixBase< OtherDerived > &  other)

Copies other into *this.

Returns:
a reference to *this.

Reimplemented in Matrix, and MapBase.

Derived& operator= ( const MatrixBase other) [inline]

Special case of the template operator=, in order to prevent the compiler from generating a default operator= (issue hit with g++ 4.1)

const ei_traits< Derived >::Scalar operator[] ( int  index) const [inline]
Returns:
the coefficient at given index.

This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.

See also:
operator[](int), operator()(int,int) const, x() const, y() const, z() const, w() const
ei_traits< Derived >::Scalar & operator[] ( int  index) [inline]
Returns:
a reference to the coefficient at given index.

This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.

See also:
operator[](int) const, operator()(int,int), x(), y(), z(), w()
NumTraits< typename ei_traits< Derived >::Scalar >::Real operatorNorm ( ) const [inline]

This is defined in the QR module.

 #include <Eigen/QR> 
Returns:
the matrix norm of this matrix.
int outerSize ( ) const [inline]
Returns:
the size of the storage major dimension, i.e., the number of columns for a columns major matrix, and the number of rows otherwise
ei_packet_traits< typename ei_traits< Derived >::Scalar >::type packet ( int  row,
int  col 
) const [inline]
Returns:
the packet of coefficients starting at the given row and column. It is your responsibility to ensure that a packet really starts there. This method is only available on expressions having the PacketAccessBit.

The LoadMode parameter may have the value Aligned or Unaligned. Its effect is to select the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets starting at an address which is a multiple of the packet size.

ei_packet_traits< typename ei_traits< Derived >::Scalar >::type packet ( int  index) const [inline]
Returns:
the packet of coefficients starting at the given index. It is your responsibility to ensure that a packet really starts there. This method is only available on expressions having the PacketAccessBit and the LinearAccessBit.

The LoadMode parameter may have the value Aligned or Unaligned. Its effect is to select the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets starting at an address which is a multiple of the packet size.

Part< Derived, Mode > part ( ) [inline]
Warning:
This is not considered to be part of the stable public API yet. Changes may happen in future releases. See Experimental parts of Eigen
Returns:
a lvalue pseudo-expression allowing to perform special operations on *this.

The Mode parameter can have the following values: UpperTriangular, StrictlyUpperTriangular, LowerTriangular, StrictlyLowerTriangular, SelfAdjoint.

Example:

Matrix3d m = Matrix3d::Zero();
m.part<Eigen::StrictlyUpperTriangular>().setOnes();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "And let us now compute m*m.adjoint() in a very optimized way" << endl
     << "taking advantage of the symmetry." << endl;
Matrix3d n;
n.part<Eigen::SelfAdjoint>() = (m*m.adjoint()).lazy();
cout << "The result is:" << endl << n << endl;

Output:

Here is the matrix m:
0 1 1
0 0 1
0 0 0
And let us now compute m*m.adjoint() in a very optimized way
taking advantage of the symmetry.
The result is:
2 1 0
1 1 0
0 0 0
See also:
class Part, MatrixBase::extract(), MatrixBase::marked()
const Part< Derived, Mode > part ( ) const
Warning:
This is not considered to be part of the stable public API yet. Changes may happen in future releases. See Experimental parts of Eigen
Returns:
an expression of a triangular matrix extracted from the current matrix

The parameter Mode can have the following values: UpperTriangular, StrictlyUpperTriangular, UnitUpperTriangular, LowerTriangular, StrictlyLowerTriangular, UnitLowerTriangular.

Example:

Matrix3i m = Matrix3i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the upper-triangular matrix extracted from m:" << endl
     << m.part<Eigen::UpperTriangular>() << endl;
cout << "Here is the strictly-upper-triangular matrix extracted from m:" << endl
     << m.part<Eigen::StrictlyUpperTriangular>() << endl;
cout << "Here is the unit-lower-triangular matrix extracted from m:" << endl
     << m.part<Eigen::UnitLowerTriangular>() << endl;

Output:

Here is the matrix m:
 7  6 -3
-2  9  6
 6 -6 -5
Here is the upper-triangular matrix extracted from m:
 7  6 -3
 0  9  6
 0  0 -5
Here is the strictly-upper-triangular matrix extracted from m:
 0  6 -3
 0  0  6
 0  0  0
Here is the unit-lower-triangular matrix extracted from m:
 1  0  0
-2  1  0
 6 -6  1
See also:
class Part, part(), marked()
const QR< typename MatrixBase< Derived >::PlainMatrixType > qr ( ) const
Returns:
the QR decomposition of *this.
See also:
class QR
const CwiseNullaryOp< ei_scalar_random_op< typename ei_traits< Derived >::Scalar >, Derived > Random ( int  rows,
int  cols 
) [inline, static]

This is defined in the Array module.

 #include <Eigen/Array> 
Returns:
a random matrix (not an expression, the matrix is immediately evaluated).

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this MatrixBase type.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so ei_random() should be used instead.

Example:

cout << MatrixXi::Random(2,3) << endl;

Output:

 7  6  9
-2  6 -6
See also:
MatrixBase::setRandom(), MatrixBase::Random(int), MatrixBase::Random()
const CwiseNullaryOp< ei_scalar_random_op< typename ei_traits< Derived >::Scalar >, Derived > Random ( int  size) [inline, static]

This is defined in the Array module.

 #include <Eigen/Array> 
Returns:
a random vector (not an expression, the vector is immediately evaluated).

The parameter size is the size of the returned vector. Must be compatible with this MatrixBase type.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

This variant is meant to be used for dynamic-size vector types. For fixed-size types, it is redundant to pass size as argument, so ei_random() should be used instead.

Example:

cout << VectorXi::Random(2) << endl;

Output:

7
-2
See also:
MatrixBase::setRandom(), MatrixBase::Random(int,int), MatrixBase::Random()
const CwiseNullaryOp< ei_scalar_random_op< typename ei_traits< Derived >::Scalar >, Derived > Random ( ) [inline, static]

This is defined in the Array module.

 #include <Eigen/Array> 
Returns:
a fixed-size random matrix or vector (not an expression, the matrix is immediately evaluated).

This variant is only for fixed-size MatrixBase types. For dynamic-size types, you need to use the variants taking size arguments.

Example:

cout << 100 * Matrix2i::Random() << endl;

Output:

700 600
-200 600
See also:
MatrixBase::setRandom(), MatrixBase::Random(int,int), MatrixBase::Random(int)
const MatrixBase< Derived >::RealReturnType real ( ) const [inline]
Returns:
an expression of the real part of *this.
See also:
imag()
ei_result_of< BinaryOp(typename ei_traits< Derived >::Scalar)>::type redux ( const BinaryOp &  func) const
Returns:
the result of a full redux operation on the whole matrix or vector using func

The template parameter BinaryOp is the type of the functor func which must be an assiociative operator. Both current STL and TR1 functor styles are handled.

See also:
MatrixBase::sum(), MatrixBase::minCoeff(), MatrixBase::maxCoeff(), MatrixBase::colwise(), MatrixBase::rowwise()
MatrixBase< Derived >::RowXpr row ( int  i) [inline]
Returns:
an expression of the i-th row of *this. Note that the numbering starts at 0.

Example:

Matrix3d m = Matrix3d::Identity();
m.row(1) = Vector3d(4,5,6);
cout << m << endl;

Output:

1 0 0
4 5 6
0 0 1
See also:
col(), class Block

Reimplemented in Part.

const MatrixBase< Derived >::RowXpr row ( int  i) const [inline]

This is the const version of row().

int rows ( ) const [inline]
const PartialRedux< Derived, Horizontal > rowwise ( ) const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 
Returns:
a PartialRedux wrapper of *this providing additional partial reduction operations

Example:

Matrix3d m = Matrix3d::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the sum of each row:" << endl << m.rowwise().sum() << endl;
cout << "Here is the maximum absolute value of each row:"
     << endl << m.cwise().abs().rowwise().maxCoeff() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the sum of each row:
0.948
1.15
-0.483
Here is the maximum absolute value of each row:
0.68
0.823
0.605
See also:
colwise(), class PartialRedux
BlockReturnType< Derived >::SubVectorType segment ( int  start,
int  size 
) [inline]
Returns:
a dynamic-size expression of a segment (i.e. a vector block) in *this.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Parameters:
startthe first coefficient in the segment
sizethe number of coefficients in the segment

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.segment(1, 2):" << endl << v.segment(1, 2) << endl;
v.segment(1, 2).setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.segment(1, 2):
-2 6
Now the vector v is:
7 0 0 6
Note:
Even though the returned expression has dynamic size, in the case when it is applied to a fixed-size vector, it inherits a fixed maximal size, which means that evaluating it does not cause a dynamic memory allocation.
See also:
class Block, segment(int)
const BlockReturnType< Derived >::SubVectorType segment ( int  start,
int  size 
) const [inline]

This is the const version of segment(int,int).

BlockReturnType< Derived, Size >::SubVectorType segment ( int  start) [inline]
Returns:
a fixed-size expression of a segment (i.e. a vector block) in *this

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

The template parameter Size is the number of coefficients in the block

Parameters:
startthe index of the first element of the sub-vector

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.segment<2>(1):" << endl << v.segment<2>(1) << endl;
v.segment<2>(2).setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.segment<2>(1):
-2 6
Now the vector v is:
 7 -2  0  0
See also:
class Block
const BlockReturnType< Derived, Size >::SubVectorType segment ( int  start) const [inline]

This is the const version of segment<int>(int).

const Select< Derived, ThenDerived, ElseDerived > select ( const MatrixBase< ThenDerived > &  thenMatrix,
const MatrixBase< ElseDerived > &  elseMatrix 
) const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 
Returns:
a matrix where each coefficient (i,j) is equal to thenMatrix(i,j) if *this(i,j), and elseMatrix(i,j) otherwise.

Example:

Output:

See also:
class Select
const Select< Derived, ThenDerived, NestByValue< typename ThenDerived::ConstantReturnType > > select ( const MatrixBase< ThenDerived > &  thenMatrix,
typename ThenDerived::Scalar  elseScalar 
) const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with the else expression being a scalar value.

See also:
MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const, class Select
const Select< Derived, NestByValue< typename ElseDerived::ConstantReturnType >, ElseDerived > select ( typename ElseDerived::Scalar  thenScalar,
const MatrixBase< ElseDerived > &  elseMatrix 
) const [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with the then expression being a scalar value.

See also:
MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const, class Select
Derived & setConstant ( const Scalar &  value) [inline]

Sets all coefficients in this expression to value.

See also:
fill(), setConstant(int,const Scalar&), setConstant(int,int,const Scalar&), setZero(), setOnes(), Constant(), class CwiseNullaryOp, setZero(), setOnes()
Derived & setIdentity ( ) [inline]

Writes the identity expression (not necessarily square) into *this.

Example:

Matrix4i m = Matrix4i::Zero();
m.block<3,3>(1,0).setIdentity();
cout << m << endl;

Output:

0 0 0 0
1 0 0 0
0 1 0 0
0 0 1 0
See also:
class CwiseNullaryOp, Identity(), Identity(int,int), isIdentity()
Derived & setOnes ( ) [inline]

Sets all coefficients in this expression to one.

Example:

Matrix4i m = Matrix4i::Random();
m.row(1).setOnes();
cout << m << endl;

Output:

 7  9 -5 -3
 1  1  1  1
 6 -3  0  9
 6  6  3  9
See also:
class CwiseNullaryOp, Ones()
Derived & setRandom ( ) [inline]

This is defined in the Array module.

 #include <Eigen/Array> 

Sets all coefficients in this expression to random values.

Example:

Matrix4i m = Matrix4i::Zero();
m.col(1).setRandom();
cout << m << endl;

Output:

 0  7  0  0
 0 -2  0  0
 0  6  0  0
 0  6  0  0
See also:
class CwiseNullaryOp, setRandom(int), setRandom(int,int)
Derived & setZero ( ) [inline]

Sets all coefficients in this expression to zero.

Example:

Matrix4i m = Matrix4i::Random();
m.row(1).setZero();
cout << m << endl;

Output:

 7  9 -5 -3
 0  0  0  0
 6 -3  0  9
 6  6  3  9
See also:
class CwiseNullaryOp, Zero()
int size ( ) const [inline]
Returns:
the number of coefficients, which is rows()*cols().
See also:
rows(), cols(), SizeAtCompileTime.
ei_plain_matrix_type_column_major< OtherDerived >::type solveTriangular ( const MatrixBase< OtherDerived > &  other) const
Returns:
the product of the inverse of *this with other, *this being triangular.
Warning:
This is not considered to be part of the stable public API yet. Changes may happen in future releases. See Experimental parts of Eigen

This function computes the inverse-matrix matrix product inverse(*this) * other. The matrix *this must be triangular and invertible (i.e., all the coefficients of the diagonal must be non zero). It works as a forward (resp. backward) substitution if *this is an upper (resp. lower) triangular matrix.

It is required that *this be marked as either an upper or a lower triangular matrix, which can be done by marked(), and that is automatically the case with expressions such as those returned by extract().

Example:

Matrix3d m = Matrix3d::Zero();
m.part<Eigen::UpperTriangular>().setOnes();
cout << "Here is the matrix m:" << endl << m << endl;
Matrix3d n = Matrix3d::Ones();
n.part<Eigen::LowerTriangular>() *= 2;
cout << "Here is the matrix n:" << endl << n << endl;
cout << "And now here is m.inverse()*n, taking advantage of the fact that"
        " m is upper-triangular:" << endl
     << m.marked<Eigen::UpperTriangular>().solveTriangular(n);

Output:

Here is the matrix m:
1 1 1
0 1 1
0 0 1
Here is the matrix n:
2 1 1
2 2 1
2 2 2
And now here is m.inverse()*n, taking advantage of the fact that m is upper-triangular:
 0 -1  0
 0  0 -1
 2  2  2

This function is essentially a wrapper to the faster solveTriangularInPlace() function creating a temporary copy of other, calling solveTriangularInPlace() on the copy and returning it. Therefore, if other is not needed anymore, it is quite faster to call solveTriangularInPlace() instead of solveTriangular().

For users coming from BLAS, this function (and more specifically solveTriangularInPlace()) offer all the operations supported by the *TRSV and *TRSM BLAS routines.

Tips: to perform a "right-inverse-multiply" you can simply transpose the operation, e.g.:

 M * T^1  <=>  T.transpose().solveTriangularInPlace(M.transpose());
See also:
solveTriangularInPlace(), marked(), extract()
void solveTriangularInPlace ( const MatrixBase< OtherDerived > &  _other) const

"in-place" version of MatrixBase::solveTriangular() where the result is written in other

Warning:
This is not considered to be part of the stable public API yet. Changes may happen in future releases. See Experimental parts of Eigen

The parameter is only marked 'const' to make the C++ compiler accept a temporary expression here. This function will const_cast it, so constness isn't honored here.

See MatrixBase:solveTriangular() for the details.

NumTraits< typename ei_traits< Derived >::Scalar >::Real squaredNorm ( ) const [inline]
Returns:
the squared l2 norm of *this, i.e., for vectors, the dot product of *this with itself.
See also:
dot(), norm()
BlockReturnType< Derived, Dynamic >::SubVectorType start ( int  size) [inline]
Returns:
a dynamic-size expression of the first coefficients of *this.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Parameters:
sizethe number of coefficients in the block

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.start(2):" << endl << v.start(2) << endl;
v.start(2).setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.start(2):
 7 -2
Now the vector v is:
0 0 6 6
Note:
Even though the returned expression has dynamic size, in the case when it is applied to a fixed-size vector, it inherits a fixed maximal size, which means that evaluating it does not cause a dynamic memory allocation.
See also:
class Block, block(int,int)
const BlockReturnType< Derived, Dynamic >::SubVectorType start ( int  size) const [inline]

This is the const version of start(int).

const BlockReturnType< Derived, Size >::SubVectorType start ( void  ) [inline]
Returns:
a fixed-size expression of the first coefficients of *this.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

The template parameter Size is the number of coefficients in the block

Example:

RowVector4i v = RowVector4i::Random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.start(2):" << endl << v.start<2>() << endl;
v.start<2>().setZero();
cout << "Now the vector v is:" << endl << v << endl;

Output:

Here is the vector v:
 7 -2  6  6
Here is v.start(2):
 7 -2
Now the vector v is:
0 0 6 6
See also:
class Block

This is the const version of start<int>().

int stride ( void  ) const [inline]
Returns:
number of elements to skip to pass from one row (resp. column) to another for a row-major (resp. column-major) matrix. Combined with coeffRef() and the flags flags, it allows a direct access to the data of the underlying matrix.

Reimplemented in Matrix, Part, Transpose, MapBase, Flagged, and NestByValue.

ei_traits< Derived >::Scalar sum ( ) const [inline]
Returns:
the sum of all coefficients of *this
See also:
trace()
SVD< typename MatrixBase< Derived >::PlainMatrixType > svd ( ) const [inline]

This is defined in the SVD module.

 #include <Eigen/SVD> 
Returns:
the SVD decomposition of *this
void swap ( const MatrixBase< OtherDerived > &  other)

swaps *this with the expression other.

Note:
other is only marked for internal reasons, but of course it gets const-casted. One reason is that one will often call swap on temporary objects (hence non-const references are forbidden). Another reason is that lazyAssign takes a const argument anyway.

Reimplemented in Matrix.

ei_traits< Derived >::Scalar trace ( ) const [inline]
Returns:
the trace of *this, i.e. the sum of the coefficients on the main diagonal.

*this can be any matrix, not necessarily square.

See also:
diagonal(), sum()
Transpose< Derived > transpose ( ) [inline]
Returns:
an expression of the transpose of *this.

Example:

Matrix2i m = Matrix2i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the transpose of m:" << endl << m.transpose() << endl;
cout << "Here is the coefficient (1,0) in the transpose of m:" << endl
     << m.transpose()(1,0) << endl;
cout << "Let us overwrite this coefficient with the value 0." << endl;
m.transpose()(1,0) = 0;
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
7 6
-2 6
Here is the transpose of m:
 7 -2
 6  6
Here is the coefficient (1,0) in the transpose of m:
6
Let us overwrite this coefficient with the value 0.
Now the matrix m is:
7 0
-2 6
Warning:
If you want to replace a matrix by its own transpose, do NOT do this:
 m = m.transpose(); // bug!!! caused by aliasing effect
Instead, use the transposeInPlace() method:
 m.transposeInPlace();
which gives Eigen good opportunities for optimization, or alternatively you can also do:
 m = m.transpose().eval();
See also:
transposeInPlace(), adjoint()
const Transpose< Derived > transpose ( ) const [inline]

This is the const version of transpose().

Make sure you read the warning for transpose() !

See also:
transposeInPlace(), adjoint()
void transposeInPlace ( ) [inline]

This is the "in place" version of transpose: it transposes *this.

In most cases it is probably better to simply use the transposed expression of a matrix. However, when transposing the matrix data itself is really needed, then this "in-place" version is probably the right choice because it provides the following additional features:

  • less error prone: doing the same operation with .transpose() requires special care:
     m = m.transpose().eval(); 
    
  • no temporary object is created (currently only for squared matrices)
  • it allows future optimizations (cache friendliness, etc.)
Note:
if the matrix is not square, then *this must be a resizable matrix.
See also:
transpose(), adjoint()
const CwiseUnaryOp< CustomUnaryOp, Derived > unaryExpr ( const CustomUnaryOp &  func = CustomUnaryOp()) const [inline]
Returns:
an expression of a custom coefficient-wise unary operator func of *this

The template parameter CustomUnaryOp is the type of the functor of the custom unary operator.

Example:

#include <Eigen/Core>
#include <Eigen/Array>
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;

// define a custom template unary functor
template<typename Scalar>
struct CwiseClampOp {
  CwiseClampOp(const Scalar& inf, const Scalar& sup) : m_inf(inf), m_sup(sup) {}
  const Scalar operator()(const Scalar& x) const { return x<m_inf ? m_inf : (x>m_sup ? m_sup : x); }
  Scalar m_inf, m_sup;
};

int main(int, char**)
{
  Matrix4d m1 = Matrix4d::Random();
  cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(CwiseClampOp<double>(-0.5,0.5)) << endl;
  return 0;
}

Output:

   0.68   0.823  -0.444   -0.27
 -0.211  -0.605   0.108  0.0268
  0.566   -0.33 -0.0452   0.904
  0.597   0.536   0.258   0.832
becomes: 
    0.5     0.5  -0.444   -0.27
 -0.211    -0.5   0.108  0.0268
    0.5   -0.33 -0.0452     0.5
    0.5     0.5   0.258     0.5
See also:
class CwiseUnaryOp, class CwiseBinarOp, MatrixBase::operator-, Cwise::abs
const MatrixBase< Derived >::BasisReturnType Unit ( int  size,
int  i 
) [inline, static]
Returns:
an expression of the i-th unit (basis) vector.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also:
MatrixBase::Unit(int), MatrixBase::UnitX(), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
const MatrixBase< Derived >::BasisReturnType Unit ( int  i) [inline, static]
Returns:
an expression of the i-th unit (basis) vector.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

This variant is for fixed-size vector only.

See also:
MatrixBase::Unit(int,int), MatrixBase::UnitX(), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
MatrixBase< Derived >::PlainMatrixType unitOrthogonal ( void  ) const
Returns:
a unit vector which is orthogonal to *this

The size of *this must be at least 2. If the size is exactly 2, then the returned vector is a counter clock wise rotation of *this, i.e., (-y,x).normalized().

See also:
cross()
const MatrixBase< Derived >::BasisReturnType UnitW ( ) [inline, static]
Returns:
an expression of the W axis unit vector (0,0,0,1)

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also:
MatrixBase::Unit(int,int), MatrixBase::Unit(int), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
const MatrixBase< Derived >::BasisReturnType UnitX ( ) [inline, static]
Returns:
an expression of the X axis unit vector (1{,0}^*)

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also:
MatrixBase::Unit(int,int), MatrixBase::Unit(int), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
const MatrixBase< Derived >::BasisReturnType UnitY ( ) [inline, static]
Returns:
an expression of the Y axis unit vector (0,1{,0}^*)

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also:
MatrixBase::Unit(int,int), MatrixBase::Unit(int), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
const MatrixBase< Derived >::BasisReturnType UnitZ ( ) [inline, static]
Returns:
an expression of the Z axis unit vector (0,0,1{,0}^*)

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also:
MatrixBase::Unit(int,int), MatrixBase::Unit(int), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
void visit ( Visitor &  visitor) const

Applies the visitor visitor to the whole coefficients of the matrix or vector.

The template parameter Visitor is the type of the visitor and provides the following interface:

 struct MyVisitor {
   // called for the first coefficient
   void init(const Scalar& value, int i, int j);
   // called for all other coefficients
   void operator() (const Scalar& value, int i, int j);
 };
Note:
compared to one or two for loops, visitors offer automatic unrolling for small fixed size matrix.
See also:
minCoeff(int*,int*), maxCoeff(int*,int*), MatrixBase::redux()
const ei_traits< Derived >::Scalar w ( ) const [inline]

equivalent to operator[](3).

ei_traits< Derived >::Scalar & w ( ) [inline]

equivalent to operator[](3).

void writePacket ( int  row,
int  col,
const typename ei_packet_traits< typename ei_traits< Derived >::Scalar >::type &  x 
) [inline]

Stores the given packet of coefficients, at the given row and column of this expression. It is your responsibility to ensure that a packet really starts there. This method is only available on expressions having the PacketAccessBit.

The LoadMode parameter may have the value Aligned or Unaligned. Its effect is to select the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets starting at an address which is a multiple of the packet size.

void writePacket ( int  index,
const typename ei_packet_traits< typename ei_traits< Derived >::Scalar >::type &  x 
) [inline]

Stores the given packet of coefficients, at the given index in this expression. It is your responsibility to ensure that a packet really starts there. This method is only available on expressions having the PacketAccessBit and the LinearAccessBit.

The LoadMode parameter may have the value Aligned or Unaligned. Its effect is to select the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets starting at an address which is a multiple of the packet size.

const ei_traits< Derived >::Scalar x ( ) const [inline]

equivalent to operator[](0).

ei_traits< Derived >::Scalar & x ( ) [inline]

equivalent to operator[](0).

const ei_traits< Derived >::Scalar y ( ) const [inline]

equivalent to operator[](1).

ei_traits< Derived >::Scalar & y ( ) [inline]

equivalent to operator[](1).

const ei_traits< Derived >::Scalar z ( ) const [inline]

equivalent to operator[](2).

ei_traits< Derived >::Scalar & z ( ) [inline]

equivalent to operator[](2).

const MatrixBase< Derived >::ConstantReturnType Zero ( int  rows,
int  cols 
) [inline, static]
Returns:
an expression of a zero matrix.

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this MatrixBase type.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so Zero() should be used instead.

Example:

cout << MatrixXi::Zero(2,3) << endl;

Output:

0 0 0
0 0 0
See also:
Zero(), Zero(int)
const MatrixBase< Derived >::ConstantReturnType Zero ( int  size) [inline, static]
Returns:
an expression of a zero vector.

The parameter size is the size of the returned vector. Must be compatible with this MatrixBase type.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

This variant is meant to be used for dynamic-size vector types. For fixed-size types, it is redundant to pass size as argument, so Zero() should be used instead.

Example:

cout << RowVectorXi::Zero(4) << endl;
cout << VectorXf::Zero(2) << endl;

Output:

0 0 0 0
0
0
See also:
Zero(), Zero(int,int)
const MatrixBase< Derived >::ConstantReturnType Zero ( ) [inline, static]
Returns:
an expression of a fixed-size zero matrix or vector.

This variant is only for fixed-size MatrixBase types. For dynamic-size types, you need to use the variants taking size arguments.

Example:

cout << Matrix2d::Zero() << endl;
cout << RowVector4i::Zero() << endl;

Output:

0 0
0 0
0 0 0 0
See also:
Zero(int), Zero(int,int)

Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  s,
const MatrixBase< Derived > &  m 
) [related]

Outputs the matrix, to the given stream.

If you wish to print the matrix with a format different than the default, use MatrixBase::format().

It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers. If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default parameters.

See also:
MatrixBase::format()

The documentation for this class was generated from the following files: