remove the Triangular suffix to Upper, Lower, UnitLower, etc,

and remove the respective bit flags
This commit is contained in:
Gael Guennebaud
2010-01-07 21:15:32 +01:00
parent 82ec250a0f
commit c5d7c9f0de
58 changed files with 591 additions and 563 deletions

View File

@@ -76,9 +76,9 @@ cholmod_sparse SparseMatrixBase<Derived>::asCholmodMatrix()
if (Derived::Flags & SelfAdjoint)
{
if (Derived::Flags & UpperTriangular)
if (Derived::Flags & Upper)
res.stype = 1;
else if (Derived::Flags & LowerTriangular)
else if (Derived::Flags & Lower)
res.stype = -1;
else
res.stype = 0;

View File

@@ -179,8 +179,8 @@ class RandomSetter
SwapStorage = 1 - MapTraits<ScalarWrapper>::IsSorted,
TargetRowMajor = (SparseMatrixType::Flags & RowMajorBit) ? 1 : 0,
SetterRowMajor = SwapStorage ? 1-TargetRowMajor : TargetRowMajor,
IsUpperTriangular = SparseMatrixType::Flags & UpperTriangularBit,
IsLowerTriangular = SparseMatrixType::Flags & LowerTriangularBit
IsUpper = SparseMatrixType::Flags & Upper,
IsLower = SparseMatrixType::Flags & Lower
};
public:
@@ -303,8 +303,8 @@ class RandomSetter
/** \returns a reference to the coefficient at given coordinates \a row, \a col */
Scalar& operator() (int row, int col)
{
ei_assert(((!IsUpperTriangular) || (row<=col)) && "Invalid access to an upper triangular matrix");
ei_assert(((!IsLowerTriangular) || (col<=row)) && "Invalid access to an upper triangular matrix");
ei_assert(((!IsUpper) || (row<=col)) && "Invalid access to an upper triangular matrix");
ei_assert(((!IsLower) || (col<=row)) && "Invalid access to an upper triangular matrix");
const int outer = SetterRowMajor ? row : col;
const int inner = SetterRowMajor ? col : row;
const int outerMajor = outer >> OuterPacketBits; // index of the packet/map

View File

@@ -333,12 +333,12 @@ bool SparseLDLT<MatrixType, Backend>::solveInPlace(MatrixBase<Derived> &b) const
return false;
if (m_matrix.nonZeros()>0) // otherwise L==I
m_matrix.template triangularView<UnitLowerTriangular>().solveInPlace(b);
m_matrix.template triangularView<UnitLower>().solveInPlace(b);
b = b.cwiseQuotient(m_diag);
// FIXME should be .adjoint() but it fails to compile...
if (m_matrix.nonZeros()>0) // otherwise L==I
m_matrix.transpose().template triangularView<UnitUpperTriangular>().solveInPlace(b);
m_matrix.transpose().template triangularView<UnitUpper>().solveInPlace(b);
return true;
}

View File

@@ -41,7 +41,7 @@ class SparseLLT
protected:
typedef typename MatrixType::Scalar Scalar;
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
typedef SparseMatrix<Scalar,LowerTriangular> CholMatrixType;
typedef SparseMatrix<Scalar> CholMatrixType;
enum {
SupernodalFactorIsDirty = 0x10000,
@@ -193,15 +193,15 @@ bool SparseLLT<MatrixType, Backend>::solveInPlace(MatrixBase<Derived> &b) const
const int size = m_matrix.rows();
ei_assert(size==b.rows());
m_matrix.template triangularView<LowerTriangular>().solveInPlace(b);
m_matrix.template triangularView<Lower>().solveInPlace(b);
// FIXME should be simply .adjoint() but it fails to compile...
if (NumTraits<Scalar>::IsComplex)
{
CholMatrixType aux = m_matrix.conjugate();
aux.transpose().template triangularView<UpperTriangular>().solveInPlace(b);
aux.transpose().template triangularView<Upper>().solveInPlace(b);
}
else
m_matrix.transpose().template triangularView<UpperTriangular>().solveInPlace(b);
m_matrix.transpose().template triangularView<Upper>().solveInPlace(b);
return true;
}

View File

@@ -47,7 +47,7 @@ class SparseLU
protected:
typedef typename MatrixType::Scalar Scalar;
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
typedef SparseMatrix<Scalar,LowerTriangular> LUMatrixType;
typedef SparseMatrix<Scalar> LUMatrixType;
enum {
MatrixLUIsDirty = 0x10000

View File

@@ -532,8 +532,8 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
// bool isIdentity(RealScalar prec = dummy_precision<Scalar>()) const;
// bool isDiagonal(RealScalar prec = dummy_precision<Scalar>()) const;
// bool isUpperTriangular(RealScalar prec = dummy_precision<Scalar>()) const;
// bool isLowerTriangular(RealScalar prec = dummy_precision<Scalar>()) const;
// bool isUpper(RealScalar prec = dummy_precision<Scalar>()) const;
// bool isLower(RealScalar prec = dummy_precision<Scalar>()) const;
// template<typename OtherDerived>
// bool isOrthogonal(const MatrixBase<OtherDerived>& other,

View File

@@ -31,7 +31,7 @@
* \brief Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
*
* \param MatrixType the type of the dense matrix storing the coefficients
* \param UpLo can be either \c LowerTriangular or \c UpperTriangular
* \param UpLo can be either \c Lower or \c Upper
*
* This class is an expression of a sefladjoint matrix from a triangular part of a matrix
* with given dense storage of the coefficients. It is the return type of MatrixBase::selfadjointView()
@@ -168,9 +168,9 @@ class SparseSelfAdjointTimeDenseProduct
enum {
LhsIsRowMajor = (_Lhs::Flags&RowMajorBit)==RowMajorBit,
ProcessFirstHalf =
((UpLo&(UpperTriangularBit|LowerTriangularBit))==(UpperTriangularBit|LowerTriangularBit))
|| ( (UpLo&UpperTriangularBit) && !LhsIsRowMajor)
|| ( (UpLo&LowerTriangularBit) && LhsIsRowMajor),
((UpLo&(Upper|Lower))==(Upper|Lower))
|| ( (UpLo&Upper) && !LhsIsRowMajor)
|| ( (UpLo&Lower) && LhsIsRowMajor),
ProcessSecondHalf = !ProcessFirstHalf
};
for (int j=0; j<m_lhs.outerSize(); ++j)

View File

@@ -33,8 +33,8 @@ struct ei_traits<SparseTriangularView<MatrixType,Mode> >
template<typename MatrixType, int Mode> class SparseTriangularView
: public SparseMatrixBase<SparseTriangularView<MatrixType,Mode> >
{
enum { SkipFirst = (Mode==LowerTriangular && !(MatrixType::Flags&RowMajorBit))
|| (Mode==UpperTriangular && (MatrixType::Flags&RowMajorBit)) };
enum { SkipFirst = (Mode==Lower && !(MatrixType::Flags&RowMajorBit))
|| (Mode==Upper && (MatrixType::Flags&RowMajorBit)) };
public:
class InnerIterator;

View File

@@ -193,9 +193,9 @@ struct SluMatrix : SuperMatrix
res.setScalarType<typename MatrixType::Scalar>();
// FIXME the following is not very accurate
if (MatrixType::Flags & UpperTriangular)
if (MatrixType::Flags & Upper)
res.Mtype = SLU_TRU;
if (MatrixType::Flags & LowerTriangular)
if (MatrixType::Flags & Lower)
res.Mtype = SLU_TRL;
if (MatrixType::Flags & SelfAdjoint)
ei_assert(false && "SelfAdjoint matrix shape not supported by SuperLU");
@@ -251,9 +251,9 @@ struct SluMatrixMapHelper<SparseMatrixBase<Derived> >
res.setScalarType<typename MatrixType::Scalar>();
// FIXME the following is not very accurate
if (MatrixType::Flags & UpperTriangular)
if (MatrixType::Flags & Upper)
res.Mtype = SLU_TRU;
if (MatrixType::Flags & LowerTriangular)
if (MatrixType::Flags & Lower)
res.Mtype = SLU_TRL;
if (MatrixType::Flags & SelfAdjoint)
ei_assert(false && "SelfAdjoint matrix shape not supported by SuperLU");
@@ -298,8 +298,8 @@ class SparseLU<MatrixType,SuperLU> : public SparseLU<MatrixType>
typedef Matrix<Scalar,Dynamic,1> Vector;
typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> IntRowVectorType;
typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType;
typedef SparseMatrix<Scalar,LowerTriangular|UnitDiagBit> LMatrixType;
typedef SparseMatrix<Scalar,UpperTriangular> UMatrixType;
typedef SparseMatrix<Scalar,Lower|UnitDiag> LMatrixType;
typedef SparseMatrix<Scalar,Upper> UMatrixType;
using Base::m_flags;
using Base::m_status;

View File

@@ -50,13 +50,13 @@ taucs_ccs_matrix SparseMatrixBase<Derived>::asTaucsMatrix()
ei_assert(false && "Scalar type not supported by TAUCS");
}
if (Flags & UpperTriangular)
if (Flags & Upper)
res.flags |= TAUCS_UPPER;
if (Flags & LowerTriangular)
if (Flags & Lower)
res.flags |= TAUCS_LOWER;
if (Flags & SelfAdjoint)
res.flags |= (NumTraits<Scalar>::IsComplex ? TAUCS_HERMITIAN : TAUCS_SYMMETRIC);
else if ((Flags & UpperTriangular) || (Flags & LowerTriangular))
else if ((Flags & Upper) || (Flags & Lower))
res.flags |= TAUCS_TRIANGULAR;
return res;

View File

@@ -26,17 +26,17 @@
#define EIGEN_SPARSETRIANGULARSOLVER_H
template<typename Lhs, typename Rhs, int Mode,
int UpLo = (Mode & LowerTriangularBit)
? LowerTriangular
: (Mode & UpperTriangularBit)
? UpperTriangular
int UpLo = (Mode & Lower)
? Lower
: (Mode & Upper)
? Upper
: -1,
int StorageOrder = int(ei_traits<Lhs>::Flags) & RowMajorBit>
struct ei_sparse_solve_triangular_selector;
// forward substitution, row-major
template<typename Lhs, typename Rhs, int Mode>
struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,LowerTriangular,RowMajor>
struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,Lower,RowMajor>
{
typedef typename Rhs::Scalar Scalar;
static void run(const Lhs& lhs, Rhs& other)
@@ -56,7 +56,7 @@ struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,LowerTriangular,RowMajor
break;
tmp -= lastVal * other.coeff(lastIndex,col);
}
if (Mode & UnitDiagBit)
if (Mode & UnitDiag)
other.coeffRef(i,col) = tmp;
else
{
@@ -70,7 +70,7 @@ struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,LowerTriangular,RowMajor
// backward substitution, row-major
template<typename Lhs, typename Rhs, int Mode>
struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,UpperTriangular,RowMajor>
struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,Upper,RowMajor>
{
typedef typename Rhs::Scalar Scalar;
static void run(const Lhs& lhs, Rhs& other)
@@ -88,7 +88,7 @@ struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,UpperTriangular,RowMajor
tmp -= it.value() * other.coeff(it.index(),col);
}
if (Mode & UnitDiagBit)
if (Mode & UnitDiag)
other.coeffRef(i,col) = tmp;
else
{
@@ -103,7 +103,7 @@ struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,UpperTriangular,RowMajor
// forward substitution, col-major
template<typename Lhs, typename Rhs, int Mode>
struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,LowerTriangular,ColMajor>
struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,Lower,ColMajor>
{
typedef typename Rhs::Scalar Scalar;
static void run(const Lhs& lhs, Rhs& other)
@@ -116,7 +116,7 @@ struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,LowerTriangular,ColMajor
if (tmp!=Scalar(0)) // optimization when other is actually sparse
{
typename Lhs::InnerIterator it(lhs, i);
if(!(Mode & UnitDiagBit))
if(!(Mode & UnitDiag))
{
ei_assert(it.index()==i);
tmp /= it.value();
@@ -133,7 +133,7 @@ struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,LowerTriangular,ColMajor
// backward substitution, col-major
template<typename Lhs, typename Rhs, int Mode>
struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,UpperTriangular,ColMajor>
struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,Upper,ColMajor>
{
typedef typename Rhs::Scalar Scalar;
static void run(const Lhs& lhs, Rhs& other)
@@ -145,7 +145,7 @@ struct ei_sparse_solve_triangular_selector<Lhs,Rhs,Mode,UpperTriangular,ColMajor
Scalar& tmp = other.coeffRef(i,col);
if (tmp!=Scalar(0)) // optimization when other is actually sparse
{
if(!(Mode & UnitDiagBit))
if(!(Mode & UnitDiag))
{
// FIXME lhs.coeff(i,i) might not be always efficient while it must simply be the
// last element of the column !
@@ -166,8 +166,8 @@ void SparseTriangularView<ExpressionType,Mode>::solveInPlace(MatrixBase<OtherDer
{
ei_assert(m_matrix.cols() == m_matrix.rows());
ei_assert(m_matrix.cols() == other.rows());
ei_assert(!(Mode & ZeroDiagBit));
ei_assert(Mode & (UpperTriangularBit|LowerTriangularBit));
ei_assert(!(Mode & ZeroDiag));
ei_assert(Mode & (Upper|Lower));
enum { copy = ei_traits<OtherDerived>::Flags & RowMajorBit };
@@ -194,10 +194,10 @@ SparseTriangularView<ExpressionType,Mode>::solve(const MatrixBase<OtherDerived>&
// pure sparse path
template<typename Lhs, typename Rhs, int Mode,
int UpLo = (Mode & LowerTriangularBit)
? LowerTriangular
: (Mode & UpperTriangularBit)
? UpperTriangular
int UpLo = (Mode & Lower)
? Lower
: (Mode & Upper)
? Upper
: -1,
int StorageOrder = int(Lhs::Flags) & (RowMajorBit)>
struct ei_sparse_solve_triangular_sparse_selector;
@@ -209,7 +209,7 @@ struct ei_sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
typedef typename Rhs::Scalar Scalar;
static void run(const Lhs& lhs, Rhs& other)
{
const bool IsLowerTriangular = (UpLo==LowerTriangular);
const bool IsLower = (UpLo==Lower);
AmbiVector<Scalar> tempVector(other.rows()*2);
tempVector.setBounds(0,other.rows());
@@ -227,9 +227,9 @@ struct ei_sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
tempVector.coeffRef(rhsIt.index()) = rhsIt.value();
}
for(int i=IsLowerTriangular?0:lhs.cols()-1;
IsLowerTriangular?i<lhs.cols():i>=0;
i+=IsLowerTriangular?1:-1)
for(int i=IsLower?0:lhs.cols()-1;
IsLower?i<lhs.cols():i>=0;
i+=IsLower?1:-1)
{
tempVector.restart();
Scalar& ci = tempVector.coeffRef(i);
@@ -237,9 +237,9 @@ struct ei_sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
{
// find
typename Lhs::InnerIterator it(lhs, i);
if(!(Mode & UnitDiagBit))
if(!(Mode & UnitDiag))
{
if (IsLowerTriangular)
if (IsLower)
{
ei_assert(it.index()==i);
ci /= it.value();
@@ -248,7 +248,7 @@ struct ei_sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
ci /= lhs.coeff(i,i);
}
tempVector.restart();
if (IsLowerTriangular)
if (IsLower)
{
if (it.index()==i)
++it;
@@ -287,8 +287,8 @@ void SparseTriangularView<ExpressionType,Mode>::solveInPlace(SparseMatrixBase<Ot
{
ei_assert(m_matrix.cols() == m_matrix.rows());
ei_assert(m_matrix.cols() == other.rows());
ei_assert(!(Mode & ZeroDiagBit));
ei_assert(Mode & (UpperTriangularBit|LowerTriangularBit));
ei_assert(!(Mode & ZeroDiag));
ei_assert(Mode & (Upper|Lower));
// enum { copy = ei_traits<OtherDerived>::Flags & RowMajorBit };
@@ -311,7 +311,7 @@ template<typename Derived>
template<typename OtherDerived>
void SparseMatrixBase<Derived>::solveTriangularInPlace(MatrixBase<OtherDerived>& other) const
{
this->template triangular<Flags&(UpperTriangularBit|LowerTriangularBit)>().solveInPlace(other);
this->template triangular<Flags&(Upper|Lower)>().solveInPlace(other);
}
/** \deprecated */

View File

@@ -127,8 +127,8 @@ class SparseLU<MatrixType,UmfPack> : public SparseLU<MatrixType>
typedef Matrix<Scalar,Dynamic,1> Vector;
typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> IntRowVectorType;
typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType;
typedef SparseMatrix<Scalar,LowerTriangular|UnitDiagBit> LMatrixType;
typedef SparseMatrix<Scalar,UpperTriangular> UMatrixType;
typedef SparseMatrix<Scalar,Lower|UnitDiagBit> LMatrixType;
typedef SparseMatrix<Scalar,Upper> UMatrixType;
using Base::m_flags;
using Base::m_status;