mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-26 06:44:27 +08:00
some cleanup
This commit is contained in:
parent
1dab53d300
commit
3b727ef939
@ -25,7 +25,6 @@ int main(int, char **)
|
|||||||
m2.block(2,3,2,3) = m - m;
|
m2.block(2,3,2,3) = m - m;
|
||||||
cout << "Now the 4x4 matrix m2 is:" << endl << m2 << endl;
|
cout << "Now the 4x4 matrix m2 is:" << endl << m2 << endl;
|
||||||
|
|
||||||
// here we don't need to use .xpr() because we only need read access.
|
|
||||||
cout << "The central 2x2 block of m2 is:" << endl << m2.block(1,2,1,2) << endl;
|
cout << "The central 2x2 block of m2 is:" << endl << m2.block(1,2,1,2) << endl;
|
||||||
cout << "Row 0 of m2, written as a column vector, is:" << endl << m2.row(0) << endl;
|
cout << "Row 0 of m2, written as a column vector, is:" << endl << m2.row(0) << endl;
|
||||||
cout << "Column 1 of m2 is:" << endl << m2.col(1) << endl;
|
cout << "Column 1 of m2 is:" << endl << m2.col(1) << endl;
|
||||||
|
@ -247,6 +247,11 @@ template<typename Derived> class MatrixAlias
|
|||||||
m_aliased.xpr() = m_tmp;
|
m_aliased.xpr() = m_tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref ref()
|
||||||
|
{
|
||||||
|
return Ref(*this);
|
||||||
|
}
|
||||||
|
|
||||||
Xpr xpr()
|
Xpr xpr()
|
||||||
{
|
{
|
||||||
return Xpr(ref());
|
return Xpr(ref());
|
||||||
@ -270,11 +275,6 @@ template<typename Derived> class MatrixAlias
|
|||||||
return m_tmp.write(row, col);
|
return m_tmp.write(row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref ref()
|
|
||||||
{
|
|
||||||
return Ref(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
MatrixXpr<MatrixRow<Xpr> > row(int i) { return xpr().row(i); };
|
MatrixXpr<MatrixRow<Xpr> > row(int i) { return xpr().row(i); };
|
||||||
MatrixXpr<MatrixCol<Xpr> > col(int i) { return xpr().col(i); };
|
MatrixXpr<MatrixCol<Xpr> > col(int i) { return xpr().col(i); };
|
||||||
MatrixXpr<MatrixMinor<Xpr> > minor(int row, int col) { return xpr().minor(row, col); };
|
MatrixXpr<MatrixMinor<Xpr> > minor(int row, int col) { return xpr().minor(row, col); };
|
||||||
@ -285,21 +285,21 @@ template<typename Derived> class MatrixAlias
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename XprContent>
|
template<typename XprContent>
|
||||||
void operator=(const MatrixXpr<XprContent> &xpr)
|
void operator=(const MatrixXpr<XprContent> &other)
|
||||||
{
|
{
|
||||||
ref().xpr() = xpr;
|
xpr() = other;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename XprContent>
|
template<typename XprContent>
|
||||||
void operator+=(const MatrixXpr<XprContent> &xpr)
|
void operator+=(const MatrixXpr<XprContent> &other)
|
||||||
{
|
{
|
||||||
ref().xpr() += xpr;
|
xpr() += other;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename XprContent>
|
template<typename XprContent>
|
||||||
void operator-=(const MatrixXpr<XprContent> &xpr)
|
void operator-=(const MatrixXpr<XprContent> &other)
|
||||||
{
|
{
|
||||||
ref().xpr() -= xpr;
|
xpr() -= other;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -70,6 +70,8 @@ template<typename Content> class MatrixXpr
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//special case of the above template operator=. Strangely, g++ 4.1 failed to use
|
||||||
|
//that template when OtherContent == Content
|
||||||
MatrixXpr& operator=(const MatrixXpr& other)
|
MatrixXpr& operator=(const MatrixXpr& other)
|
||||||
{
|
{
|
||||||
assert(rows() == other.rows() && cols() == other.cols());
|
assert(rows() == other.rows() && cols() == other.cols());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user