mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8dd23c4ffd | ||
|
|
d65a6aeb20 | ||
|
|
395214bcc3 | ||
|
|
696bee033b | ||
|
|
59bd03457a | ||
|
|
088e8fcfef | ||
|
|
0e2efbddd3 | ||
|
|
12b9b92c40 | ||
|
|
0952ab2ac4 | ||
|
|
38229a3d23 | ||
|
|
b18f9427a8 | ||
|
|
a6fbf2c202 | ||
|
|
2034af6db9 | ||
|
|
fbe1d5fb2c | ||
|
|
560877016a | ||
|
|
c7ba7f59d6 | ||
|
|
5dca39eb8b | ||
|
|
21826e9e53 | ||
|
|
97c08b43b4 | ||
|
|
8f67e02ee2 | ||
|
|
93c329445c | ||
|
|
575255bc1f | ||
|
|
d29654fb4e |
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
qrc_*cxx
|
||||||
|
*.orig
|
||||||
|
*.pyc
|
||||||
|
*.diff
|
||||||
|
diff
|
||||||
|
*.save
|
||||||
|
save
|
||||||
|
*.old
|
||||||
|
*.gmo
|
||||||
|
*.qm
|
||||||
|
core
|
||||||
|
core.*
|
||||||
|
*.bak
|
||||||
|
*~
|
||||||
|
*.build*
|
||||||
|
*.moc.*
|
||||||
|
*.moc
|
||||||
|
ui_*
|
||||||
|
CMakeCache.txt
|
||||||
|
tags
|
||||||
|
.*.swp
|
||||||
|
activity.png
|
||||||
|
*.out
|
||||||
|
*.php*
|
||||||
|
*.log
|
||||||
|
*.orig
|
||||||
|
*.rej
|
||||||
|
log
|
||||||
|
patch
|
||||||
|
*.patch
|
||||||
|
a
|
||||||
|
a.*
|
||||||
|
lapack/testing
|
||||||
|
lapack/reference
|
||||||
|
.*project
|
||||||
|
.settings
|
||||||
|
Makefile
|
||||||
|
!ci/build.gitlab-ci.yml
|
||||||
|
!scripts/buildtests.in
|
||||||
|
!Eigen/Core
|
||||||
|
!Eigen/src/Core
|
||||||
28
.gitlab-ci.yml
Normal file
28
.gitlab-ci.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# This file is part of Eigen, a lightweight C++ template library
|
||||||
|
# for linear algebra.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2023, The Eigen Authors
|
||||||
|
#
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla
|
||||||
|
# Public License v. 2.0. If a copy of the MPL was not distributed
|
||||||
|
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
variables:
|
||||||
|
# CMake build directory.
|
||||||
|
EIGEN_CI_BUILDDIR: .build
|
||||||
|
# Specify the CMake build target.
|
||||||
|
EIGEN_CI_BUILD_TARGET: ""
|
||||||
|
# If a test regex is specified, that will be selected.
|
||||||
|
# Otherwise, we will try a label if specified.
|
||||||
|
EIGEN_CI_CTEST_REGEX: ""
|
||||||
|
EIGEN_CI_CTEST_LABEL: ""
|
||||||
|
EIGEN_CI_CTEST_ARGS: ""
|
||||||
|
|
||||||
|
include:
|
||||||
|
- "/ci/common.gitlab-ci.yml"
|
||||||
|
- "/ci/build.linux.gitlab-ci.yml"
|
||||||
|
- "/ci/deploy.gitlab-ci.yml"
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#define EIGEN_SPARSECHOLESKY_MODULE_H
|
#define EIGEN_SPARSECHOLESKY_MODULE_H
|
||||||
|
|
||||||
#include "SparseCore"
|
#include "SparseCore"
|
||||||
|
#include "OrderingMethods"
|
||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
|
|||||||
@@ -277,15 +277,13 @@ template<> struct ldlt_inplace<Lower>
|
|||||||
// are compared; if any diagonal is negligible compared
|
// are compared; if any diagonal is negligible compared
|
||||||
// to the largest overall, the algorithm bails.
|
// to the largest overall, the algorithm bails.
|
||||||
cutoff = abs(NumTraits<Scalar>::epsilon() * biggest_in_corner);
|
cutoff = abs(NumTraits<Scalar>::epsilon() * biggest_in_corner);
|
||||||
|
|
||||||
if(sign)
|
|
||||||
*sign = real(mat.diagonal().coeff(index_of_biggest_in_corner)) > 0 ? 1 : -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finish early if the matrix is not full rank.
|
// Finish early if the matrix is not full rank.
|
||||||
if(biggest_in_corner < cutoff)
|
if(biggest_in_corner < cutoff)
|
||||||
{
|
{
|
||||||
for(Index i = k; i < size; i++) transpositions.coeffRef(i) = i;
|
for(Index i = k; i < size; i++) transpositions.coeffRef(i) = i;
|
||||||
|
if(sign) *sign = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,6 +324,16 @@ template<> struct ldlt_inplace<Lower>
|
|||||||
}
|
}
|
||||||
if((rs>0) && (abs(mat.coeffRef(k,k)) > cutoff))
|
if((rs>0) && (abs(mat.coeffRef(k,k)) > cutoff))
|
||||||
A21 /= mat.coeffRef(k,k);
|
A21 /= mat.coeffRef(k,k);
|
||||||
|
|
||||||
|
if(sign)
|
||||||
|
{
|
||||||
|
// LDLT is not guaranteed to work for indefinite matrices, but let's try to get the sign right
|
||||||
|
int newSign = real(mat.diagonal().coeff(index_of_biggest_in_corner)) > 0;
|
||||||
|
if(k == 0)
|
||||||
|
*sign = newSign;
|
||||||
|
else if(*sign != newSign)
|
||||||
|
*sign = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
|
|||||||
inline Index outerStride() const { return m_expression.outerStride(); }
|
inline Index outerStride() const { return m_expression.outerStride(); }
|
||||||
inline Index innerStride() const { return m_expression.innerStride(); }
|
inline Index innerStride() const { return m_expression.innerStride(); }
|
||||||
|
|
||||||
inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
|
inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); }
|
||||||
inline const Scalar* data() const { return m_expression.data(); }
|
inline const Scalar* data() const { return m_expression.data(); }
|
||||||
|
|
||||||
inline CoeffReturnType coeff(Index row, Index col) const
|
inline CoeffReturnType coeff(Index row, Index col) const
|
||||||
@@ -175,7 +175,7 @@ class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
|
|||||||
inline Index outerStride() const { return m_expression.outerStride(); }
|
inline Index outerStride() const { return m_expression.outerStride(); }
|
||||||
inline Index innerStride() const { return m_expression.innerStride(); }
|
inline Index innerStride() const { return m_expression.innerStride(); }
|
||||||
|
|
||||||
inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
|
inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); }
|
||||||
inline const Scalar* data() const { return m_expression.data(); }
|
inline const Scalar* data() const { return m_expression.data(); }
|
||||||
|
|
||||||
inline CoeffReturnType coeff(Index row, Index col) const
|
inline CoeffReturnType coeff(Index row, Index col) const
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(sqrt, Sqrt)
|
|||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(square, Sqr)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(square, Sqr)
|
||||||
|
|
||||||
// The vm*powx functions are not avaibale in the windows version of MKL.
|
// The vm*powx functions are not avaibale in the windows version of MKL.
|
||||||
#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmspowx_, float, float)
|
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmspowx_, float, float)
|
||||||
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmdpowx_, double, double)
|
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmdpowx_, double, double)
|
||||||
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmcpowx_, scomplex, MKL_Complex8)
|
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmcpowx_, scomplex, MKL_Complex8)
|
||||||
|
|||||||
@@ -56,8 +56,7 @@ template<typename ViewOp, typename MatrixType, typename StorageKind>
|
|||||||
class CwiseUnaryViewImpl;
|
class CwiseUnaryViewImpl;
|
||||||
|
|
||||||
template<typename ViewOp, typename MatrixType>
|
template<typename ViewOp, typename MatrixType>
|
||||||
class CwiseUnaryView : internal::no_assignment_operator,
|
class CwiseUnaryView : public CwiseUnaryViewImpl<ViewOp, MatrixType, typename internal::traits<MatrixType>::StorageKind>
|
||||||
public CwiseUnaryViewImpl<ViewOp, MatrixType, typename internal::traits<MatrixType>::StorageKind>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -99,6 +98,10 @@ class CwiseUnaryViewImpl<ViewOp,MatrixType,Dense>
|
|||||||
typedef typename internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type Base;
|
typedef typename internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type Base;
|
||||||
|
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
|
EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
|
||||||
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryViewImpl)
|
||||||
|
|
||||||
|
inline Scalar* data() { return &coeffRef(0); }
|
||||||
|
inline const Scalar* data() const { return &coeff(0); }
|
||||||
|
|
||||||
inline Index innerStride() const
|
inline Index innerStride() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Dense>
|
|||||||
|
|
||||||
typedef typename internal::TransposeImpl_base<MatrixType>::type Base;
|
typedef typename internal::TransposeImpl_base<MatrixType>::type Base;
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(Transpose<MatrixType>)
|
EIGEN_DENSE_PUBLIC_INTERFACE(Transpose<MatrixType>)
|
||||||
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(TransposeImpl)
|
||||||
|
|
||||||
inline Index innerStride() const { return derived().nestedExpression().innerStride(); }
|
inline Index innerStride() const { return derived().nestedExpression().innerStride(); }
|
||||||
inline Index outerStride() const { return derived().nestedExpression().outerStride(); }
|
inline Index outerStride() const { return derived().nestedExpression().outerStride(); }
|
||||||
@@ -252,7 +253,7 @@ struct inplace_transpose_selector;
|
|||||||
template<typename MatrixType>
|
template<typename MatrixType>
|
||||||
struct inplace_transpose_selector<MatrixType,true> { // square matrix
|
struct inplace_transpose_selector<MatrixType,true> { // square matrix
|
||||||
static void run(MatrixType& m) {
|
static void run(MatrixType& m) {
|
||||||
m.template triangularView<StrictlyUpper>().swap(m.transpose());
|
m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -260,7 +261,7 @@ template<typename MatrixType>
|
|||||||
struct inplace_transpose_selector<MatrixType,false> { // non square matrix
|
struct inplace_transpose_selector<MatrixType,false> { // non square matrix
|
||||||
static void run(MatrixType& m) {
|
static void run(MatrixType& m) {
|
||||||
if (m.rows()==m.cols())
|
if (m.rows()==m.cols())
|
||||||
m.template triangularView<StrictlyUpper>().swap(m.transpose());
|
m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose());
|
||||||
else
|
else
|
||||||
m = m.transpose().eval();
|
m = m.transpose().eval();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ Packet4f psqrt<Packet4f>(const Packet4f& _x)
|
|||||||
Packet4f half = pmul(_x, pset1<Packet4f>(.5f));
|
Packet4f half = pmul(_x, pset1<Packet4f>(.5f));
|
||||||
|
|
||||||
/* select only the inverse sqrt of non-zero inputs */
|
/* select only the inverse sqrt of non-zero inputs */
|
||||||
Packet4f non_zero_mask = _mm_cmpgt_ps(_x, pset1<Packet4f>(std::numeric_limits<float>::epsilon()));
|
Packet4f non_zero_mask = _mm_cmpgt_ps(_x, pset1<Packet4f>((std::numeric_limits<float>::min)()));
|
||||||
Packet4f x = _mm_and_ps(non_zero_mask, _mm_rsqrt_ps(_x));
|
Packet4f x = _mm_and_ps(non_zero_mask, _mm_rsqrt_ps(_x));
|
||||||
|
|
||||||
x = pmul(x, psub(pset1<Packet4f>(1.5f), pmul(half, pmul(x,x))));
|
x = pmul(x, psub(pset1<Packet4f>(1.5f), pmul(half, pmul(x,x))));
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#define EIGEN_WORLD_VERSION 3
|
#define EIGEN_WORLD_VERSION 3
|
||||||
#define EIGEN_MAJOR_VERSION 1
|
#define EIGEN_MAJOR_VERSION 1
|
||||||
#define EIGEN_MINOR_VERSION 3
|
#define EIGEN_MINOR_VERSION 4
|
||||||
|
|
||||||
#define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
|
#define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
|
||||||
(EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
|
(EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
|
||||||
|
|||||||
@@ -451,7 +451,6 @@ template<typename T, bool Align> inline void conditional_aligned_delete_auto(T *
|
|||||||
template<typename Scalar, typename Index>
|
template<typename Scalar, typename Index>
|
||||||
static inline Index first_aligned(const Scalar* array, Index size)
|
static inline Index first_aligned(const Scalar* array, Index size)
|
||||||
{
|
{
|
||||||
typedef typename packet_traits<Scalar>::type Packet;
|
|
||||||
enum { PacketSize = packet_traits<Scalar>::size,
|
enum { PacketSize = packet_traits<Scalar>::size,
|
||||||
PacketAlignedMask = PacketSize-1
|
PacketAlignedMask = PacketSize-1
|
||||||
};
|
};
|
||||||
@@ -710,15 +709,6 @@ public:
|
|||||||
::new( p ) T( value );
|
::new( p ) T( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support for c++11
|
|
||||||
#if (__cplusplus >= 201103L)
|
|
||||||
template<typename... Args>
|
|
||||||
void construct(pointer p, Args&&... args)
|
|
||||||
{
|
|
||||||
::new(p) T(std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void destroy( pointer p )
|
void destroy( pointer p )
|
||||||
{
|
{
|
||||||
p->~T();
|
p->~T();
|
||||||
|
|||||||
@@ -512,8 +512,7 @@ template<typename MatrixType>
|
|||||||
template<typename OtherDerived, typename ResultType>
|
template<typename OtherDerived, typename ResultType>
|
||||||
bool SVD<MatrixType>::solve(const MatrixBase<OtherDerived> &b, ResultType* result) const
|
bool SVD<MatrixType>::solve(const MatrixBase<OtherDerived> &b, ResultType* result) const
|
||||||
{
|
{
|
||||||
const int rows = m_matU.rows();
|
ei_assert(b.rows() == m_matU.rows());
|
||||||
ei_assert(b.rows() == rows);
|
|
||||||
|
|
||||||
Scalar maxVal = m_sigma.cwise().abs().maxCoeff();
|
Scalar maxVal = m_sigma.cwise().abs().maxCoeff();
|
||||||
for (int j=0; j<b.cols(); ++j)
|
for (int j=0; j<b.cols(); ++j)
|
||||||
|
|||||||
@@ -63,9 +63,10 @@ template<typename _MatrixType> class FullPivHouseholderQR
|
|||||||
typedef typename MatrixType::Index Index;
|
typedef typename MatrixType::Index Index;
|
||||||
typedef internal::FullPivHouseholderQRMatrixQReturnType<MatrixType> MatrixQReturnType;
|
typedef internal::FullPivHouseholderQRMatrixQReturnType<MatrixType> MatrixQReturnType;
|
||||||
typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;
|
typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;
|
||||||
typedef Matrix<Index, 1, ColsAtCompileTime, RowMajor, 1, MaxColsAtCompileTime> IntRowVectorType;
|
typedef Matrix<Index, 1,
|
||||||
|
EIGEN_SIZE_MIN_PREFER_DYNAMIC(ColsAtCompileTime,RowsAtCompileTime), RowMajor, 1,
|
||||||
|
EIGEN_SIZE_MIN_PREFER_FIXED(MaxColsAtCompileTime,MaxRowsAtCompileTime)> IntDiagSizeVectorType;
|
||||||
typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationType;
|
typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationType;
|
||||||
typedef typename internal::plain_col_type<MatrixType, Index>::type IntColVectorType;
|
|
||||||
typedef typename internal::plain_row_type<MatrixType>::type RowVectorType;
|
typedef typename internal::plain_row_type<MatrixType>::type RowVectorType;
|
||||||
typedef typename internal::plain_col_type<MatrixType>::type ColVectorType;
|
typedef typename internal::plain_col_type<MatrixType>::type ColVectorType;
|
||||||
|
|
||||||
@@ -158,7 +159,7 @@ template<typename _MatrixType> class FullPivHouseholderQR
|
|||||||
return m_cols_permutation;
|
return m_cols_permutation;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IntColVectorType& rowsTranspositions() const
|
const IntDiagSizeVectorType& rowsTranspositions() const
|
||||||
{
|
{
|
||||||
eigen_assert(m_isInitialized && "FullPivHouseholderQR is not initialized.");
|
eigen_assert(m_isInitialized && "FullPivHouseholderQR is not initialized.");
|
||||||
return m_rows_transpositions;
|
return m_rows_transpositions;
|
||||||
@@ -348,8 +349,8 @@ template<typename _MatrixType> class FullPivHouseholderQR
|
|||||||
protected:
|
protected:
|
||||||
MatrixType m_qr;
|
MatrixType m_qr;
|
||||||
HCoeffsType m_hCoeffs;
|
HCoeffsType m_hCoeffs;
|
||||||
IntColVectorType m_rows_transpositions;
|
IntDiagSizeVectorType m_rows_transpositions;
|
||||||
IntRowVectorType m_cols_transpositions;
|
IntDiagSizeVectorType m_cols_transpositions;
|
||||||
PermutationType m_cols_permutation;
|
PermutationType m_cols_permutation;
|
||||||
RowVectorType m_temp;
|
RowVectorType m_temp;
|
||||||
bool m_isInitialized, m_usePrescribedThreshold;
|
bool m_isInitialized, m_usePrescribedThreshold;
|
||||||
@@ -389,8 +390,8 @@ FullPivHouseholderQR<MatrixType>& FullPivHouseholderQR<MatrixType>::compute(cons
|
|||||||
|
|
||||||
m_precision = NumTraits<Scalar>::epsilon() * size;
|
m_precision = NumTraits<Scalar>::epsilon() * size;
|
||||||
|
|
||||||
m_rows_transpositions.resize(matrix.rows());
|
m_rows_transpositions.resize(size);
|
||||||
m_cols_transpositions.resize(matrix.cols());
|
m_cols_transpositions.resize(size);
|
||||||
Index number_of_transpositions = 0;
|
Index number_of_transpositions = 0;
|
||||||
|
|
||||||
RealScalar biggest(0);
|
RealScalar biggest(0);
|
||||||
@@ -520,14 +521,14 @@ template<typename MatrixType> struct FullPivHouseholderQRMatrixQReturnType
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Index Index;
|
typedef typename MatrixType::Index Index;
|
||||||
typedef typename internal::plain_col_type<MatrixType, Index>::type IntColVectorType;
|
typedef typename FullPivHouseholderQR<MatrixType>::IntDiagSizeVectorType IntDiagSizeVectorType;
|
||||||
typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;
|
typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;
|
||||||
typedef Matrix<typename MatrixType::Scalar, 1, MatrixType::RowsAtCompileTime, RowMajor, 1,
|
typedef Matrix<typename MatrixType::Scalar, 1, MatrixType::RowsAtCompileTime, RowMajor, 1,
|
||||||
MatrixType::MaxRowsAtCompileTime> WorkVectorType;
|
MatrixType::MaxRowsAtCompileTime> WorkVectorType;
|
||||||
|
|
||||||
FullPivHouseholderQRMatrixQReturnType(const MatrixType& qr,
|
FullPivHouseholderQRMatrixQReturnType(const MatrixType& qr,
|
||||||
const HCoeffsType& hCoeffs,
|
const HCoeffsType& hCoeffs,
|
||||||
const IntColVectorType& rowsTranspositions)
|
const IntDiagSizeVectorType& rowsTranspositions)
|
||||||
: m_qr(qr),
|
: m_qr(qr),
|
||||||
m_hCoeffs(hCoeffs),
|
m_hCoeffs(hCoeffs),
|
||||||
m_rowsTranspositions(rowsTranspositions)
|
m_rowsTranspositions(rowsTranspositions)
|
||||||
@@ -566,7 +567,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
typename MatrixType::Nested m_qr;
|
typename MatrixType::Nested m_qr;
|
||||||
typename HCoeffsType::Nested m_hCoeffs;
|
typename HCoeffsType::Nested m_hCoeffs;
|
||||||
typename IntColVectorType::Nested m_rowsTranspositions;
|
typename IntDiagSizeVectorType::Nested m_rowsTranspositions;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|||||||
@@ -833,17 +833,13 @@ struct solve_retval<JacobiSVD<_MatrixType, QRPreconditioner>, Rhs>
|
|||||||
// A = U S V^*
|
// A = U S V^*
|
||||||
// So A^{-1} = V S^{-1} U^*
|
// So A^{-1} = V S^{-1} U^*
|
||||||
|
|
||||||
|
Matrix<Scalar, Dynamic, Rhs::ColsAtCompileTime, 0, _MatrixType::MaxRowsAtCompileTime, Rhs::MaxColsAtCompileTime> tmp;
|
||||||
Index diagSize = (std::min)(dec().rows(), dec().cols());
|
Index diagSize = (std::min)(dec().rows(), dec().cols());
|
||||||
typename JacobiSVDType::SingularValuesType invertedSingVals(diagSize);
|
|
||||||
|
|
||||||
Index nonzeroSingVals = dec().nonzeroSingularValues();
|
Index nonzeroSingVals = dec().nonzeroSingularValues();
|
||||||
invertedSingVals.head(nonzeroSingVals) = dec().singularValues().head(nonzeroSingVals).array().inverse();
|
|
||||||
invertedSingVals.tail(diagSize - nonzeroSingVals).setZero();
|
tmp.noalias() = dec().matrixU().leftCols(nonzeroSingVals).adjoint() * rhs();
|
||||||
|
tmp = dec().singularValues().head(nonzeroSingVals).asDiagonal().inverse() * tmp;
|
||||||
dst = dec().matrixV().leftCols(diagSize)
|
dst = dec().matrixV().leftCols(nonzeroSingVals) * tmp;
|
||||||
* invertedSingVals.asDiagonal()
|
|
||||||
* dec().matrixU().leftCols(diagSize).adjoint()
|
|
||||||
* rhs();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|||||||
30
ci/build.linux.gitlab-ci.yml
Normal file
30
ci/build.linux.gitlab-ci.yml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Base configuration for linux cross-compilation.
|
||||||
|
.build:linux:cross:
|
||||||
|
extends: .common:linux:cross
|
||||||
|
stage: build
|
||||||
|
variables:
|
||||||
|
EIGEN_CI_BUILD_TARGET: buildtests
|
||||||
|
script:
|
||||||
|
- . ci/scripts/build.linux.script.sh
|
||||||
|
tags:
|
||||||
|
- saas-linux-2xlarge-amd64
|
||||||
|
rules:
|
||||||
|
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_PROJECT_NAMESPACE == "libeigen"
|
||||||
|
- if: $CI_PIPELINE_SOURCE == "web" && $CI_PROJECT_NAMESPACE == "libeigen"
|
||||||
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_NAMESPACE == "libeigen" && $CI_MERGE_REQUEST_LABELS =~ "/all-tests/"
|
||||||
|
cache:
|
||||||
|
key: "$CI_JOB_NAME_SLUG-$CI_COMMIT_REF_SLUG-BUILD"
|
||||||
|
paths:
|
||||||
|
- ${EIGEN_CI_BUILDDIR}/
|
||||||
|
|
||||||
|
build:linux:docs:
|
||||||
|
extends: .build:linux:cross
|
||||||
|
variables:
|
||||||
|
EIGEN_CI_TARGET_ARCH: any
|
||||||
|
EIGEN_CI_BUILD_TARGET: doc
|
||||||
|
EIGEN_CI_INSTALL: ca-certificates clang flex python3 bison graphviz
|
||||||
|
EIGEN_CI_C_COMPILER: clang
|
||||||
|
EIGEN_CI_CXX_COMPILER: clang++
|
||||||
|
EIGEN_CI_BEFORE_SCRIPT: ". ci/scripts/build_and_install_doxygen.sh Release_1_13_2"
|
||||||
|
rules:
|
||||||
|
- if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "libeigen"
|
||||||
24
ci/common.gitlab-ci.yml
Normal file
24
ci/common.gitlab-ci.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Base configuration for linux builds and tests.
|
||||||
|
.common:linux:cross:
|
||||||
|
image: ubuntu:20.04
|
||||||
|
variables:
|
||||||
|
EIGEN_CI_TARGET_ARCH: ""
|
||||||
|
EIGEN_CI_ADDITIONAL_ARGS: ""
|
||||||
|
# If host matches target, use the following:
|
||||||
|
EIGEN_CI_C_COMPILER: ""
|
||||||
|
EIGEN_CI_CXX_COMPILER: ""
|
||||||
|
EIGEN_CI_INSTALL: "${EIGEN_CI_C_COMPILER} ${EIGEN_CI_CXX_COMPILER}"
|
||||||
|
# If host does not match the target, use the following:
|
||||||
|
EIGEN_CI_CROSS_TARGET_TRIPLE: ""
|
||||||
|
EIGEN_CI_CROSS_C_COMPILER: ${EIGEN_CI_C_COMPILER}
|
||||||
|
EIGEN_CI_CROSS_CXX_COMPILER: ${EIGEN_CI_CXX_COMPILER}
|
||||||
|
EIGEN_CI_CROSS_INSTALL: "${EIGEN_CI_CROSS_C_COMPILER} ${EIGEN_CI_CROSS_CXX_COMPILER}"
|
||||||
|
before_script:
|
||||||
|
# Call script in current shell - it sets up some environment variables.
|
||||||
|
- . ci/scripts/common.linux.before_script.sh
|
||||||
|
artifacts:
|
||||||
|
when: always
|
||||||
|
name: "$CI_JOB_NAME_SLUG-$CI_COMMIT_REF_SLUG"
|
||||||
|
paths:
|
||||||
|
- ${EIGEN_CI_BUILDDIR}/
|
||||||
|
expire_in: 5 days
|
||||||
25
ci/deploy.gitlab-ci.yml
Normal file
25
ci/deploy.gitlab-ci.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Upload docs if pipeline succeeded.
|
||||||
|
deploy:docs:
|
||||||
|
stage: deploy
|
||||||
|
image: busybox
|
||||||
|
dependencies: [ build:linux:docs ]
|
||||||
|
variables:
|
||||||
|
PAGES_PREFIX: docs-nightly
|
||||||
|
script:
|
||||||
|
- echo "Deploying site to $CI_PAGES_URL"
|
||||||
|
- mv ${EIGEN_CI_BUILDDIR}/doc/html public
|
||||||
|
pages:
|
||||||
|
path_prefix: $PAGES_PREFIX
|
||||||
|
expire_in: never
|
||||||
|
artifacts:
|
||||||
|
name: "$CI_JOB_NAME_SLUG-$CI_COMMIT_REF_SLUG"
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
tags:
|
||||||
|
- saas-linux-small-amd64
|
||||||
|
rules:
|
||||||
|
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_PROJECT_NAMESPACE == "libeigen"
|
||||||
|
- if: $CI_PIPELINE_SOURCE == "web" && $CI_PROJECT_NAMESPACE == "libeigen"
|
||||||
|
- if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "libeigen"
|
||||||
|
variables:
|
||||||
|
PAGES_PREFIX: docs-$CI_COMMIT_REF_NAME
|
||||||
31
ci/scripts/build.linux.script.sh
Executable file
31
ci/scripts/build.linux.script.sh
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
# Create and enter build directory.
|
||||||
|
rootdir=`pwd`
|
||||||
|
mkdir -p ${EIGEN_CI_BUILDDIR}
|
||||||
|
cd ${EIGEN_CI_BUILDDIR}
|
||||||
|
|
||||||
|
# Configure build.
|
||||||
|
cmake -G Ninja \
|
||||||
|
-DCMAKE_CXX_COMPILER=${EIGEN_CI_CXX_COMPILER} \
|
||||||
|
-DCMAKE_C_COMPILER=${EIGEN_CI_C_COMPILER} \
|
||||||
|
-DCMAKE_CXX_COMPILER_TARGET=${EIGEN_CI_CXX_COMPILER_TARGET} \
|
||||||
|
${EIGEN_CI_ADDITIONAL_ARGS} ${rootdir}
|
||||||
|
|
||||||
|
target=""
|
||||||
|
if [[ ${EIGEN_CI_BUILD_TARGET} ]]; then
|
||||||
|
target="--target ${EIGEN_CI_BUILD_TARGET}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Builds (particularly gcc) sometimes get killed, potentially when running
|
||||||
|
# out of resources. In that case, keep trying to build the remaining
|
||||||
|
# targets (k0), then try to build again with a single thread (j1) to minimize
|
||||||
|
# resource use.
|
||||||
|
cmake --build . ${target} -- -k0 || cmake --build . ${target} -- -k0 -j1
|
||||||
|
|
||||||
|
# Return to root directory.
|
||||||
|
cd ${rootdir}
|
||||||
|
|
||||||
|
set +x
|
||||||
6
ci/scripts/build_and_install_doxygen.sh
Normal file
6
ci/scripts/build_and_install_doxygen.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
git clone --depth 1 --branch $1 https://github.com/doxygen/doxygen.git
|
||||||
|
cmake -B doxygen/.build -G Ninja \
|
||||||
|
-DCMAKE_CXX_COMPILER=${EIGEN_CI_CXX_COMPILER} \
|
||||||
|
-DCMAKE_C_COMPILER=${EIGEN_CI_C_COMPILER} \
|
||||||
|
doxygen
|
||||||
|
cmake --build doxygen/.build -t install
|
||||||
46
ci/scripts/common.linux.before_script.sh
Executable file
46
ci/scripts/common.linux.before_script.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
echo "Running ${CI_JOB_NAME}"
|
||||||
|
|
||||||
|
# Get architecture and display CI configuration.
|
||||||
|
export ARCH=`uname -m`
|
||||||
|
export NPROC=`nproc`
|
||||||
|
echo "arch=$ARCH, target=${EIGEN_CI_TARGET_ARCH}"
|
||||||
|
echo "Processors: ${NPROC}"
|
||||||
|
echo "CI Variables:"
|
||||||
|
export | grep EIGEN
|
||||||
|
|
||||||
|
# Set noninteractive, otherwise tzdata may be installed and prompt for a
|
||||||
|
# geographical region.
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update -y > /dev/null
|
||||||
|
apt-get install -y --no-install-recommends ninja-build cmake git > /dev/null
|
||||||
|
|
||||||
|
# Install required dependencies and set up compilers.
|
||||||
|
# These are required even for testing to ensure that dynamic runtime libraries
|
||||||
|
# are available.
|
||||||
|
if [[ "$ARCH" == "${EIGEN_CI_TARGET_ARCH}" || "${EIGEN_CI_TARGET_ARCH}" == "any" ]]; then
|
||||||
|
apt-get install -y --no-install-recommends ${EIGEN_CI_INSTALL} > /dev/null;
|
||||||
|
export EIGEN_CI_CXX_IMPLICIT_INCLUDE_DIRECTORIES="";
|
||||||
|
export EIGEN_CI_CXX_COMPILER_TARGET="";
|
||||||
|
else
|
||||||
|
apt-get install -y --no-install-recommends ${EIGEN_CI_CROSS_INSTALL} > /dev/null;
|
||||||
|
export EIGEN_CI_C_COMPILER=${EIGEN_CI_CROSS_C_COMPILER};
|
||||||
|
export EIGEN_CI_CXX_COMPILER=${EIGEN_CI_CROSS_CXX_COMPILER};
|
||||||
|
export EIGEN_CI_CXX_COMPILER_TARGET=${EIGEN_CI_CROSS_TARGET_TRIPLE};
|
||||||
|
# Tell the compiler where to find headers and libraries if using clang.
|
||||||
|
# NOTE: this breaks GCC since it messes with include path order
|
||||||
|
# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129)
|
||||||
|
if [[ "${EIGEN_CI_CROSS_CXX_COMPILER}" == *"clang"* ]]; then
|
||||||
|
export CPLUS_INCLUDE_PATH="/usr/${EIGEN_CI_CROSS_TARGET_TRIPLE}/include";
|
||||||
|
export LIBRARY_PATH="/usr/${EIGEN_CI_CROSS_TARGET_TRIPLE}/lib64";
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Compilers: ${EIGEN_CI_C_COMPILER} ${EIGEN_CI_CXX_COMPILER}"
|
||||||
|
|
||||||
|
if [ -n "$EIGEN_CI_BEFORE_SCRIPT" ]; then eval "$EIGEN_CI_BEFORE_SCRIPT"; fi
|
||||||
|
|
||||||
|
set +x
|
||||||
@@ -98,8 +98,8 @@ Matrix3f a;
|
|||||||
MatrixXf b;
|
MatrixXf b;
|
||||||
\endcode
|
\endcode
|
||||||
Here,
|
Here,
|
||||||
\li \c a is a 3x3 matrix, with a static float[9] array of uninitialized coefficients,
|
\li \c a is a 3-by-3 matrix, with a plain float[9] array of uninitialized coefficients,
|
||||||
\li \c b is a dynamic-size matrix whose size is currently 0x0, and whose array of
|
\li \c b is a dynamic-size matrix whose size is currently 0-by-0, and whose array of
|
||||||
coefficients hasn't yet been allocated at all.
|
coefficients hasn't yet been allocated at all.
|
||||||
|
|
||||||
Constructors taking sizes are also available. For matrices, the number of rows is always passed first.
|
Constructors taking sizes are also available. For matrices, the number of rows is always passed first.
|
||||||
@@ -216,7 +216,7 @@ The simple answer is: use fixed
|
|||||||
sizes for very small sizes where you can, and use dynamic sizes for larger sizes or where you have to. For small sizes,
|
sizes for very small sizes where you can, and use dynamic sizes for larger sizes or where you have to. For small sizes,
|
||||||
especially for sizes smaller than (roughly) 16, using fixed sizes is hugely beneficial
|
especially for sizes smaller than (roughly) 16, using fixed sizes is hugely beneficial
|
||||||
to performance, as it allows Eigen to avoid dynamic memory allocation and to unroll
|
to performance, as it allows Eigen to avoid dynamic memory allocation and to unroll
|
||||||
loops. Internally, a fixed-size Eigen matrix is just a plain static array, i.e. doing
|
loops. Internally, a fixed-size Eigen matrix is just a plain array, i.e. doing
|
||||||
\code Matrix4f mymatrix; \endcode
|
\code Matrix4f mymatrix; \endcode
|
||||||
really amounts to just doing
|
really amounts to just doing
|
||||||
\code float mymatrix[16]; \endcode
|
\code float mymatrix[16]; \endcode
|
||||||
@@ -231,8 +231,9 @@ member variables.
|
|||||||
The limitation of using fixed sizes, of course, is that this is only possible
|
The limitation of using fixed sizes, of course, is that this is only possible
|
||||||
when you know the sizes at compile time. Also, for large enough sizes, say for sizes
|
when you know the sizes at compile time. Also, for large enough sizes, say for sizes
|
||||||
greater than (roughly) 32, the performance benefit of using fixed sizes becomes negligible.
|
greater than (roughly) 32, the performance benefit of using fixed sizes becomes negligible.
|
||||||
Worse, trying to create a very large matrix using fixed sizes could result in a stack overflow,
|
Worse, trying to create a very large matrix using fixed sizes inside a function could result in a
|
||||||
since Eigen will try to allocate the array as a static array, which by default goes on the stack.
|
stack overflow, since Eigen will try to allocate the array automatically as a local variable, and
|
||||||
|
this is normally done on the stack.
|
||||||
Finally, depending on circumstances, Eigen can also be more aggressive trying to vectorize
|
Finally, depending on circumstances, Eigen can also be more aggressive trying to vectorize
|
||||||
(use SIMD instructions) when dynamic sizes are used, see \ref TopicVectorization "Vectorization".
|
(use SIMD instructions) when dynamic sizes are used, see \ref TopicVectorization "Vectorization".
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ Describing the \a buildProblem and \a save functions is out of the scope of this
|
|||||||
|
|
||||||
The SparseMatrix and SparseVector classes take three template arguments:
|
The SparseMatrix and SparseVector classes take three template arguments:
|
||||||
* the scalar type (e.g., double)
|
* the scalar type (e.g., double)
|
||||||
* the storage order (ColMajor or RowMajor, the default is RowMajor)
|
* the storage order (ColMajor or RowMajor, the default is ColMajor)
|
||||||
* the inner index type (default is \c int).
|
* the inner index type (default is \c int).
|
||||||
|
|
||||||
As for dense Matrix objects, constructors takes the size of the object.
|
As for dense Matrix objects, constructors takes the size of the object.
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ All combinations are allowed: you can have a matrix with a fixed number of rows
|
|||||||
Matrix<double, 6, Dynamic> // Dynamic number of columns (heap allocation)
|
Matrix<double, 6, Dynamic> // Dynamic number of columns (heap allocation)
|
||||||
Matrix<double, Dynamic, 2> // Dynamic number of rows (heap allocation)
|
Matrix<double, Dynamic, 2> // Dynamic number of rows (heap allocation)
|
||||||
Matrix<double, Dynamic, Dynamic, RowMajor> // Fully dynamic, row major (heap allocation)
|
Matrix<double, Dynamic, Dynamic, RowMajor> // Fully dynamic, row major (heap allocation)
|
||||||
Matrix<double, 13, 3> // Fully fixed (static allocation)
|
Matrix<double, 13, 3> // Fully fixed (usually allocated on stack)
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
In most cases, you can simply use one of the convenience typedefs for \ref matrixtypedefs "matrices" and \ref arraytypedefs "arrays". Some examples:
|
In most cases, you can simply use one of the convenience typedefs for \ref matrixtypedefs "matrices" and \ref arraytypedefs "arrays". Some examples:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// This file is part of Eugenio, a lightweight C++ template library
|
// This file is part of Eigen, a lightweight C++ template library
|
||||||
// for linear algebra.
|
// for linear algebra.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2009 Thomas Capricelli <orzel@freehackers.org>
|
// Copyright (C) 2009 Thomas Capricelli <orzel@freehackers.org>
|
||||||
|
|||||||
@@ -62,7 +62,9 @@ void pseudo_inverse(const CMatrix &C, CINVMatrix &CINV)
|
|||||||
Scalar rho, rho_1, alpha;
|
Scalar rho, rho_1, alpha;
|
||||||
d.setZero();
|
d.setZero();
|
||||||
|
|
||||||
CINV.startFill(); // FIXME estimate the number of non-zeros
|
typedef Triplet<double> T;
|
||||||
|
std::vector<T> tripletList;
|
||||||
|
|
||||||
for (Index i = 0; i < rows; ++i)
|
for (Index i = 0; i < rows; ++i)
|
||||||
{
|
{
|
||||||
d[i] = 1.0;
|
d[i] = 1.0;
|
||||||
@@ -88,11 +90,12 @@ void pseudo_inverse(const CMatrix &C, CINVMatrix &CINV)
|
|||||||
// FIXME add a generic "prune/filter" expression for both dense and sparse object to sparse
|
// FIXME add a generic "prune/filter" expression for both dense and sparse object to sparse
|
||||||
for (Index j=0; j<l.size(); ++j)
|
for (Index j=0; j<l.size(); ++j)
|
||||||
if (l[j]<1e-15)
|
if (l[j]<1e-15)
|
||||||
CINV.fill(i,j) = l[j];
|
tripletList.push_back(T(i,j,l(j)));
|
||||||
|
|
||||||
|
|
||||||
d[i] = 0.0;
|
d[i] = 0.0;
|
||||||
}
|
}
|
||||||
CINV.endFill();
|
CINV.setFromTriplets(tripletList.begin(), tripletList.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -107,6 +110,7 @@ template<typename TMatrix, typename CMatrix,
|
|||||||
void constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x,
|
void constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x,
|
||||||
const VectorB& b, const VectorF& f, IterationController &iter)
|
const VectorB& b, const VectorF& f, IterationController &iter)
|
||||||
{
|
{
|
||||||
|
using std::sqrt;
|
||||||
typedef typename TMatrix::Scalar Scalar;
|
typedef typename TMatrix::Scalar Scalar;
|
||||||
typedef typename TMatrix::Index Index;
|
typedef typename TMatrix::Index Index;
|
||||||
typedef Matrix<Scalar,Dynamic,1> TmpVec;
|
typedef Matrix<Scalar,Dynamic,1> TmpVec;
|
||||||
|
|||||||
Reference in New Issue
Block a user