mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-24 02:29:33 +08:00
compilation fixes
This commit is contained in:
parent
0590c18555
commit
94cc30180e
@ -76,9 +76,6 @@ struct ei_selfadjoint_product<Scalar,MatStorageOrder, ColMajor, AAT, UpLo>
|
||||
Scalar* blockA = ei_aligned_stack_new(Scalar, kc*mc);
|
||||
Scalar* blockB = ei_aligned_stack_new(Scalar, kc*size*Blocking::PacketSize);
|
||||
|
||||
// number of columns which can be processed by packet of nr columns
|
||||
int packet_cols = (size/Blocking::nr)*Blocking::nr;
|
||||
|
||||
// note that the actual rhs is the transpose/adjoint of mat
|
||||
typedef ei_conj_helper<NumTraits<Scalar>::IsComplex && !AAT, NumTraits<Scalar>::IsComplex && AAT> Conj;
|
||||
|
||||
|
@ -92,7 +92,7 @@ template<typename MatrixType> class LU
|
||||
MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns.
|
||||
> ImageResultType;
|
||||
|
||||
/**
|
||||
/**
|
||||
* \brief Default Constructor.
|
||||
*
|
||||
* The default constructor is useful in cases in which the user intends to
|
||||
@ -227,7 +227,7 @@ template<typename MatrixType> class LU
|
||||
* Example: \include LU_solve.cpp
|
||||
* Output: \verbinclude LU_solve.out
|
||||
*
|
||||
* \sa MatrixBase::solveTriangular(), kernel(), computeKernel(), inverse(), computeInverse()
|
||||
* \sa TriangularView::solve(), kernel(), computeKernel(), inverse(), computeInverse()
|
||||
*/
|
||||
template<typename OtherDerived, typename ResultType>
|
||||
bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const;
|
||||
@ -380,7 +380,7 @@ void LU<MatrixType>::compute(const MatrixType& matrix)
|
||||
const int size = matrix.diagonalSize();
|
||||
const int rows = matrix.rows();
|
||||
const int cols = matrix.cols();
|
||||
|
||||
|
||||
// this formula comes from experimenting (see "LU precision tuning" thread on the list)
|
||||
// and turns out to be identical to Higham's formula used already in LDLt.
|
||||
m_precision = machine_epsilon<Scalar>() * size;
|
||||
@ -486,8 +486,7 @@ void LU<MatrixType>::computeKernel(KernelMatrixType *result) const
|
||||
y(-m_lu.corner(TopRight, m_rank, dimker));
|
||||
|
||||
m_lu.corner(TopLeft, m_rank, m_rank)
|
||||
.template marked<UpperTriangular>()
|
||||
.solveTriangularInPlace(y);
|
||||
.template triangularView<UpperTriangular>().solveInPlace(y);
|
||||
|
||||
for(int i = 0; i < m_rank; ++i) result->row(m_q.coeff(i)) = y.row(i);
|
||||
for(int i = m_rank; i < cols; ++i) result->row(m_q.coeff(i)).setZero();
|
||||
@ -552,9 +551,8 @@ bool LU<MatrixType>::solve(
|
||||
for(int i = 0; i < rows; ++i) c.row(m_p.coeff(i)) = b.row(i);
|
||||
|
||||
// Step 2
|
||||
m_lu.corner(Eigen::TopLeft,smalldim,smalldim).template marked<UnitLowerTriangular>()
|
||||
.solveTriangularInPlace(
|
||||
c.corner(Eigen::TopLeft, smalldim, c.cols()));
|
||||
m_lu.corner(Eigen::TopLeft,smalldim,smalldim).template triangularView<UnitLowerTriangular>()
|
||||
.solveInPlace(c.corner(Eigen::TopLeft, smalldim, c.cols()));
|
||||
if(rows>cols)
|
||||
{
|
||||
c.corner(Eigen::BottomLeft, rows-cols, c.cols())
|
||||
@ -572,8 +570,8 @@ bool LU<MatrixType>::solve(
|
||||
return false;
|
||||
}
|
||||
m_lu.corner(TopLeft, m_rank, m_rank)
|
||||
.template marked<UpperTriangular>()
|
||||
.solveTriangularInPlace(c.corner(TopLeft, m_rank, c.cols()));
|
||||
.template triangularView<UpperTriangular>()
|
||||
.solveInPlace(c.corner(TopLeft, m_rank, c.cols()));
|
||||
|
||||
// Step 4
|
||||
result->resize(m_lu.cols(), b.cols());
|
||||
|
@ -70,7 +70,7 @@ template<typename MatrixType> class PartialLU
|
||||
MatrixType::MaxRowsAtCompileTime)
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* \brief Default Constructor.
|
||||
*
|
||||
* The default constructor is useful in cases in which the user intends to
|
||||
@ -99,7 +99,7 @@ template<typename MatrixType> class PartialLU
|
||||
{
|
||||
ei_assert(m_isInitialized && "PartialLU is not initialized.");
|
||||
return m_lu;
|
||||
}
|
||||
}
|
||||
|
||||
/** \returns a vector of integers, whose size is the number of rows of the matrix being decomposed,
|
||||
* representing the P permutation i.e. the permutation of the rows. For its precise meaning,
|
||||
@ -127,7 +127,7 @@ template<typename MatrixType> class PartialLU
|
||||
* Example: \include PartialLU_solve.cpp
|
||||
* Output: \verbinclude PartialLU_solve.out
|
||||
*
|
||||
* \sa MatrixBase::solveTriangular(), inverse(), computeInverse()
|
||||
* \sa TriangularView::solve(), inverse(), computeInverse()
|
||||
*/
|
||||
template<typename OtherDerived, typename ResultType>
|
||||
void solve(const MatrixBase<OtherDerived>& b, ResultType *result) const;
|
||||
@ -235,7 +235,7 @@ void PartialLU<MatrixType>::compute(const MatrixType& matrix)
|
||||
* one path
|
||||
*/
|
||||
for(int col = k + 1; col < size; ++col)
|
||||
m_lu.col(col).end(size-k-1) -= m_lu.col(k).end(size-k-1) * m_lu.coeff(k,col);
|
||||
m_lu.col(col).end(size-k-1) -= m_lu.col(k).end(size-k-1) * m_lu.coeff(k,col);
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,12 +280,10 @@ void PartialLU<MatrixType>::solve(
|
||||
for(int i = 0; i < size; ++i) result->row(m_p.coeff(i)) = b.row(i);
|
||||
|
||||
// Step 2
|
||||
m_lu.template marked<UnitLowerTriangular>()
|
||||
.solveTriangularInPlace(*result);
|
||||
m_lu.template triangularView<UnitLowerTriangular>().solveInPlace(*result);
|
||||
|
||||
// Step 3
|
||||
m_lu.template marked<UpperTriangular>()
|
||||
.solveTriangularInPlace(*result);
|
||||
m_lu.template triangularView<UpperTriangular>().solveInPlace(*result);
|
||||
}
|
||||
|
||||
/** \lu_module
|
||||
|
@ -243,7 +243,7 @@ HessenbergDecomposition<MatrixType>::matrixH(void) const
|
||||
int n = m_matrix.rows();
|
||||
MatrixType matH = m_matrix;
|
||||
if (n>2)
|
||||
matH.corner(BottomLeft,n-2, n-2).template part<LowerTriangular>().setZero();
|
||||
matH.corner(BottomLeft,n-2, n-2).template triangularView<LowerTriangular>().setZero();
|
||||
return matH;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ template<typename MatrixType> class HouseholderQR
|
||||
typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> MatrixTypeR;
|
||||
typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> VectorType;
|
||||
|
||||
/**
|
||||
/**
|
||||
* \brief Default Constructor.
|
||||
*
|
||||
* The default constructor is useful in cases in which the user intends to
|
||||
@ -66,14 +66,14 @@ template<typename MatrixType> class HouseholderQR
|
||||
{
|
||||
compute(matrix);
|
||||
}
|
||||
|
||||
|
||||
/** \returns a read-only expression of the matrix R of the actual the QR decomposition */
|
||||
const TriangularView<NestByValue<MatrixRBlockType>, UpperTriangular>
|
||||
matrixR(void) const
|
||||
{
|
||||
ei_assert(m_isInitialized && "HouseholderQR is not initialized.");
|
||||
int cols = m_qr.cols();
|
||||
return MatrixRBlockType(m_qr, 0, 0, cols, cols).nestByValue().template part<UpperTriangular>();
|
||||
return MatrixRBlockType(m_qr, 0, 0, cols, cols).nestByValue().template triangularView<UpperTriangular>();
|
||||
}
|
||||
|
||||
/** This method finds a solution x to the equation Ax=b, where A is the matrix of which
|
||||
@ -95,7 +95,7 @@ template<typename MatrixType> class HouseholderQR
|
||||
void solve(const MatrixBase<OtherDerived>& b, ResultType *result) const;
|
||||
|
||||
MatrixType matrixQ(void) const;
|
||||
|
||||
|
||||
/** \returns a reference to the matrix where the Householder QR decomposition is stored
|
||||
* in a LAPACK-compatible way.
|
||||
*/
|
||||
@ -113,7 +113,7 @@ template<typename MatrixType> class HouseholderQR
|
||||
|
||||
template<typename MatrixType>
|
||||
void HouseholderQR<MatrixType>::compute(const MatrixType& matrix)
|
||||
{
|
||||
{
|
||||
m_qr = matrix;
|
||||
m_hCoeffs.resize(matrix.cols());
|
||||
|
||||
@ -185,15 +185,15 @@ void HouseholderQR<MatrixType>::solve(
|
||||
const int rows = m_qr.rows();
|
||||
ei_assert(b.rows() == rows);
|
||||
result->resize(rows, b.cols());
|
||||
|
||||
|
||||
// TODO(keir): There is almost certainly a faster way to multiply by
|
||||
// Q^T without explicitly forming matrixQ(). Investigate.
|
||||
*result = matrixQ().transpose()*b;
|
||||
|
||||
|
||||
const int rank = std::min(result->rows(), result->cols());
|
||||
m_qr.corner(TopLeft, rank, rank)
|
||||
.template marked<UpperTriangular>()
|
||||
.solveTriangularInPlace(result->corner(TopLeft, rank, result->cols()));
|
||||
.template triangularView<UpperTriangular>()
|
||||
.solveInPlace(result->corner(TopLeft, rank, result->cols()));
|
||||
}
|
||||
|
||||
/** \returns the matrix Q */
|
||||
|
@ -173,8 +173,8 @@ Tridiagonalization<MatrixType>::matrixT(void) const
|
||||
matT.corner(TopRight,n-1, n-1).diagonal() = subDiagonal().template cast<Scalar>().conjugate();
|
||||
if (n>2)
|
||||
{
|
||||
matT.corner(TopRight,n-2, n-2).template part<UpperTriangular>().setZero();
|
||||
matT.corner(BottomLeft,n-2, n-2).template part<LowerTriangular>().setZero();
|
||||
matT.corner(TopRight,n-2, n-2).template triangularView<UpperTriangular>().setZero();
|
||||
matT.corner(BottomLeft,n-2, n-2).template triangularView<LowerTriangular>().setZero();
|
||||
}
|
||||
return matT;
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ template<typename MatrixType> void syrk(const MatrixType& m)
|
||||
Rhs2 rhs2 = Rhs2::Random(rows, ei_random<int>(1,320));
|
||||
Rhs3 rhs3 = Rhs3::Random(ei_random<int>(1,320), rows);
|
||||
|
||||
Scalar s1 = ei_random<Scalar>(),
|
||||
s2 = ei_random<Scalar>();
|
||||
Scalar s1 = ei_random<Scalar>();
|
||||
|
||||
m2.setZero();
|
||||
VERIFY_IS_APPROX((m2.template selfadjointView<LowerTriangular>().rankUpdate(rhs2,s1)._expression()),
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
template<typename MatrixType> void product_triangular(const MatrixType& m)
|
||||
template<typename MatrixType> void trmv(const MatrixType& m)
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
@ -79,14 +79,14 @@ template<typename MatrixType> void product_triangular(const MatrixType& m)
|
||||
// TODO check with sub-matrices
|
||||
}
|
||||
|
||||
void test_product_triangular()
|
||||
void test_product_trmv()
|
||||
{
|
||||
for(int i = 0; i < g_repeat ; i++) {
|
||||
CALL_SUBTEST( product_triangular(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( product_triangular(Matrix<float, 2, 2>()) );
|
||||
CALL_SUBTEST( product_triangular(Matrix3d()) );
|
||||
CALL_SUBTEST( product_triangular(Matrix<std::complex<float>,23, 23>()) );
|
||||
CALL_SUBTEST( product_triangular(MatrixXcd(17,17)) );
|
||||
CALL_SUBTEST( product_triangular(Matrix<float,Dynamic,Dynamic,RowMajor>(19, 19)) );
|
||||
CALL_SUBTEST( trmv(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( trmv(Matrix<float, 2, 2>()) );
|
||||
CALL_SUBTEST( trmv(Matrix3d()) );
|
||||
CALL_SUBTEST( trmv(Matrix<std::complex<float>,23, 23>()) );
|
||||
CALL_SUBTEST( trmv(MatrixXcd(17,17)) );
|
||||
CALL_SUBTEST( trmv(Matrix<float,Dynamic,Dynamic,RowMajor>(19, 19)) );
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user