mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-03-19 18:40:38 +08:00
the min/max macros to detect unprotected min/max were undefined by some std header,
so let's declare them after and do the respective fixes ;)
This commit is contained in:
parent
5734ee6df4
commit
42e2578ef9
@ -566,7 +566,7 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
|
||||
|
||||
// map the matrix coefficients to [-1:1] to avoid over- and underflow.
|
||||
Scalar scale = mat.cwiseAbs().maxCoeff();
|
||||
scale = std::max(scale,Scalar(1));
|
||||
scale = (std::max)(scale,Scalar(1));
|
||||
MatrixType scaledMat = mat / scale;
|
||||
|
||||
// Compute the eigenvalues
|
||||
@ -646,7 +646,7 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,2
|
||||
|
||||
// map the matrix coefficients to [-1:1] to avoid over- and underflow.
|
||||
Scalar scale = mat.cwiseAbs().maxCoeff();
|
||||
scale = std::max(scale,Scalar(1));
|
||||
scale = (std::max)(scale,Scalar(1));
|
||||
MatrixType scaledMat = mat / scale;
|
||||
|
||||
// Compute the eigenvalues
|
||||
|
@ -48,7 +48,7 @@ template<typename MatrixType> void householder(const MatrixType& m)
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, Dynamic> VBlockMatrixType;
|
||||
typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, MatrixType::RowsAtCompileTime> TMatrixType;
|
||||
|
||||
Matrix<Scalar, EIGEN_SIZE_MAX(MatrixType::RowsAtCompileTime,MatrixType::ColsAtCompileTime), 1> _tmp(std::max(rows,cols));
|
||||
Matrix<Scalar, EIGEN_SIZE_MAX(MatrixType::RowsAtCompileTime,MatrixType::ColsAtCompileTime), 1> _tmp((std::max)(rows,cols));
|
||||
Scalar* tmp = &_tmp.coeffRef(0,0);
|
||||
|
||||
Scalar beta;
|
||||
|
@ -66,7 +66,7 @@ void jacobisvd_compare_to_full(const MatrixType& m,
|
||||
typedef typename MatrixType::Index Index;
|
||||
Index rows = m.rows();
|
||||
Index cols = m.cols();
|
||||
Index diagSize = std::min(rows, cols);
|
||||
Index diagSize = (std::min)(rows, cols);
|
||||
|
||||
JacobiSVD<MatrixType, QRPreconditioner> svd(m, computationOptions);
|
||||
|
||||
|
@ -64,7 +64,7 @@ template<typename MatrixType> void lu_non_invertible()
|
||||
typedef Matrix<typename MatrixType::Scalar, RowsAtCompileTime, RowsAtCompileTime>
|
||||
RMatrixType;
|
||||
|
||||
Index rank = internal::random<Index>(1, std::min(rows, cols)-1);
|
||||
Index rank = internal::random<Index>(1, (std::min)(rows, cols)-1);
|
||||
|
||||
// The image of the zero matrix should consist of a single (zero) column vector
|
||||
VERIFY((MatrixType::Zero(rows,cols).fullPivLu().image(MatrixType::Zero(rows,cols)).cols() == 1));
|
||||
@ -84,8 +84,8 @@ template<typename MatrixType> void lu_non_invertible()
|
||||
MatrixType u(rows,cols);
|
||||
u = lu.matrixLU().template triangularView<Upper>();
|
||||
RMatrixType l = RMatrixType::Identity(rows,rows);
|
||||
l.block(0,0,rows,std::min(rows,cols)).template triangularView<StrictlyLower>()
|
||||
= lu.matrixLU().block(0,0,rows,std::min(rows,cols));
|
||||
l.block(0,0,rows,(std::min)(rows,cols)).template triangularView<StrictlyLower>()
|
||||
= lu.matrixLU().block(0,0,rows,(std::min)(rows,cols));
|
||||
|
||||
VERIFY_IS_APPROX(lu.permutationP() * m1 * lu.permutationQ(), l*u);
|
||||
|
||||
|
12
test/main.h
12
test/main.h
@ -23,9 +23,6 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define min(A,B) please_protect_your_min_with_parentheses
|
||||
#define max(A,B) please_protect_your_max_with_parentheses
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cerrno>
|
||||
#include <ctime>
|
||||
@ -33,6 +30,15 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <typeinfo>
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <complex>
|
||||
#include <deque>
|
||||
#include <queue>
|
||||
|
||||
#define min(A,B) please_protect_your_min_with_parentheses
|
||||
#define max(A,B) please_protect_your_max_with_parentheses
|
||||
|
||||
// the following file is automatically generated by cmake
|
||||
#include "split_test_helper.h"
|
||||
|
@ -38,7 +38,7 @@ bool equalsIdentity(const MatrixType& A)
|
||||
}
|
||||
}
|
||||
for (Index i = 0; i < A.rows(); ++i) {
|
||||
for (Index j = 0; j < std::min(i, A.cols()); ++j) {
|
||||
for (Index j = 0; j < (std::min)(i, A.cols()); ++j) {
|
||||
offDiagOK = offDiagOK && (A(i,j) == zero);
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ template<typename Scalar> void packetmath()
|
||||
{
|
||||
data1[i] = internal::random<Scalar>()/RealScalar(PacketSize);
|
||||
data2[i] = internal::random<Scalar>()/RealScalar(PacketSize);
|
||||
refvalue = std::max(refvalue,internal::abs(data1[i]));
|
||||
refvalue = (std::max)(refvalue,internal::abs(data1[i]));
|
||||
}
|
||||
|
||||
internal::pstore(data2, internal::pload<Packet>(data1));
|
||||
@ -264,16 +264,16 @@ template<typename Scalar> void packetmath_real()
|
||||
|
||||
ref[0] = data1[0];
|
||||
for (int i=0; i<PacketSize; ++i)
|
||||
ref[0] = std::min(ref[0],data1[i]);
|
||||
ref[0] = (std::min)(ref[0],data1[i]);
|
||||
VERIFY(internal::isApprox(ref[0], internal::predux_min(internal::pload<Packet>(data1))) && "internal::predux_min");
|
||||
|
||||
CHECK_CWISE2(std::min, internal::pmin);
|
||||
CHECK_CWISE2(std::max, internal::pmax);
|
||||
CHECK_CWISE2((std::min), internal::pmin);
|
||||
CHECK_CWISE2((std::max), internal::pmax);
|
||||
CHECK_CWISE1(internal::abs, internal::pabs);
|
||||
|
||||
ref[0] = data1[0];
|
||||
for (int i=0; i<PacketSize; ++i)
|
||||
ref[0] = std::max(ref[0],data1[i]);
|
||||
ref[0] = (std::max)(ref[0],data1[i]);
|
||||
VERIFY(internal::isApprox(ref[0], internal::predux_max(internal::pload<Packet>(data1))) && "internal::predux_max");
|
||||
|
||||
for (int i=0; i<PacketSize; ++i)
|
||||
|
@ -58,7 +58,7 @@ template<typename MatrixType> void inverse_general_4x4(int repeat)
|
||||
MatrixType inv = m.inverse();
|
||||
double error = double( (m*inv-MatrixType::Identity()).norm() * absdet / NumTraits<Scalar>::epsilon() );
|
||||
error_sum += error;
|
||||
error_max = std::max(error_max, error);
|
||||
error_max = (std::max)(error_max, error);
|
||||
}
|
||||
std::cerr << "inverse_general_4x4, Scalar = " << type_name<Scalar>() << std::endl;
|
||||
double error_avg = error_sum / repeat;
|
||||
|
@ -29,7 +29,7 @@ template<typename Derived1, typename Derived2>
|
||||
bool areNotApprox(const MatrixBase<Derived1>& m1, const MatrixBase<Derived2>& m2, typename Derived1::RealScalar epsilon = NumTraits<typename Derived1::RealScalar>::dummy_precision())
|
||||
{
|
||||
return !((m1-m2).cwiseAbs2().maxCoeff() < epsilon * epsilon
|
||||
* std::max(m1.cwiseAbs2().maxCoeff(), m2.cwiseAbs2().maxCoeff()));
|
||||
* (std::max)(m1.cwiseAbs2().maxCoeff(), m2.cwiseAbs2().maxCoeff()));
|
||||
}
|
||||
|
||||
template<typename MatrixType> void product(const MatrixType& m)
|
||||
@ -102,7 +102,7 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
|
||||
// test the previous tests were not screwed up because operator* returns 0
|
||||
// (we use the more accurate default epsilon)
|
||||
if (!NumTraits<Scalar>::IsInteger && std::min(rows,cols)>1)
|
||||
if (!NumTraits<Scalar>::IsInteger && (std::min)(rows,cols)>1)
|
||||
{
|
||||
VERIFY(areNotApprox(m1.transpose()*m2,m2.transpose()*m1));
|
||||
}
|
||||
@ -111,7 +111,7 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
res = square;
|
||||
res.noalias() += m1 * m2.transpose();
|
||||
VERIFY_IS_APPROX(res, square + m1 * m2.transpose());
|
||||
if (!NumTraits<Scalar>::IsInteger && std::min(rows,cols)>1)
|
||||
if (!NumTraits<Scalar>::IsInteger && (std::min)(rows,cols)>1)
|
||||
{
|
||||
VERIFY(areNotApprox(res,square + m2 * m1.transpose()));
|
||||
}
|
||||
@ -123,7 +123,7 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
res = square;
|
||||
res.noalias() -= m1 * m2.transpose();
|
||||
VERIFY_IS_APPROX(res, square - (m1 * m2.transpose()));
|
||||
if (!NumTraits<Scalar>::IsInteger && std::min(rows,cols)>1)
|
||||
if (!NumTraits<Scalar>::IsInteger && (std::min)(rows,cols)>1)
|
||||
{
|
||||
VERIFY(areNotApprox(res,square - m2 * m1.transpose()));
|
||||
}
|
||||
@ -147,7 +147,7 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
res2 = square2;
|
||||
res2.noalias() += m1.transpose() * m2;
|
||||
VERIFY_IS_APPROX(res2, square2 + m1.transpose() * m2);
|
||||
if (!NumTraits<Scalar>::IsInteger && std::min(rows,cols)>1)
|
||||
if (!NumTraits<Scalar>::IsInteger && (std::min)(rows,cols)>1)
|
||||
{
|
||||
VERIFY(areNotApprox(res2,square2 + m2.transpose() * m1));
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ template<typename MatrixType> void qr()
|
||||
typedef typename MatrixType::Index Index;
|
||||
|
||||
Index rows = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE), cols = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE), cols2 = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE);
|
||||
Index rank = internal::random<Index>(1, std::min(rows, cols)-1);
|
||||
Index rank = internal::random<Index>(1, (std::min)(rows, cols)-1);
|
||||
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename MatrixType::RealScalar RealScalar;
|
||||
@ -64,7 +64,7 @@ template<typename MatrixType, int Cols2> void qr_fixedsize()
|
||||
{
|
||||
enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime };
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
int rank = internal::random<int>(1, std::min(int(Rows), int(Cols))-1);
|
||||
int rank = internal::random<int>(1, (std::min)(int(Rows), int(Cols))-1);
|
||||
Matrix<Scalar,Rows,Cols> m1;
|
||||
createRandomPIMatrixOfRank(rank,Rows,Cols,m1);
|
||||
ColPivHouseholderQR<Matrix<Scalar,Rows,Cols> > qr(m1);
|
||||
|
@ -31,7 +31,7 @@ template<typename MatrixType> void qr()
|
||||
typedef typename MatrixType::Index Index;
|
||||
|
||||
Index rows = internal::random<Index>(20,200), cols = internal::random<int>(20,200), cols2 = internal::random<int>(20,200);
|
||||
Index rank = internal::random<Index>(1, std::min(rows, cols)-1);
|
||||
Index rank = internal::random<Index>(1, (std::min)(rows, cols)-1);
|
||||
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> MatrixQType;
|
||||
|
@ -43,8 +43,8 @@ template<typename MatrixType> void matrixRedux(const MatrixType& m)
|
||||
{
|
||||
s += m1(i,j);
|
||||
p *= m1(i,j);
|
||||
minc = std::min(internal::real(minc), internal::real(m1(i,j)));
|
||||
maxc = std::max(internal::real(maxc), internal::real(m1(i,j)));
|
||||
minc = (std::min)(internal::real(minc), internal::real(m1(i,j)));
|
||||
maxc = (std::max)(internal::real(maxc), internal::real(m1(i,j)));
|
||||
}
|
||||
const Scalar mean = s/Scalar(RealScalar(rows*cols));
|
||||
|
||||
@ -86,8 +86,8 @@ template<typename VectorType> void vectorRedux(const VectorType& w)
|
||||
{
|
||||
s += v[j];
|
||||
p *= v[j];
|
||||
minc = std::min(minc, internal::real(v[j]));
|
||||
maxc = std::max(maxc, internal::real(v[j]));
|
||||
minc = (std::min)(minc, internal::real(v[j]));
|
||||
maxc = (std::max)(maxc, internal::real(v[j]));
|
||||
}
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(internal::abs(s - v.head(i).sum()), Scalar(1));
|
||||
VERIFY_IS_APPROX(p, v.head(i).prod());
|
||||
@ -103,8 +103,8 @@ template<typename VectorType> void vectorRedux(const VectorType& w)
|
||||
{
|
||||
s += v[j];
|
||||
p *= v[j];
|
||||
minc = std::min(minc, internal::real(v[j]));
|
||||
maxc = std::max(maxc, internal::real(v[j]));
|
||||
minc = (std::min)(minc, internal::real(v[j]));
|
||||
maxc = (std::max)(maxc, internal::real(v[j]));
|
||||
}
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(internal::abs(s - v.tail(size-i).sum()), Scalar(1));
|
||||
VERIFY_IS_APPROX(p, v.tail(size-i).prod());
|
||||
@ -120,8 +120,8 @@ template<typename VectorType> void vectorRedux(const VectorType& w)
|
||||
{
|
||||
s += v[j];
|
||||
p *= v[j];
|
||||
minc = std::min(minc, internal::real(v[j]));
|
||||
maxc = std::max(maxc, internal::real(v[j]));
|
||||
minc = (std::min)(minc, internal::real(v[j]));
|
||||
maxc = (std::max)(maxc, internal::real(v[j]));
|
||||
}
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(internal::abs(s - v.segment(i, size-2*i).sum()), Scalar(1));
|
||||
VERIFY_IS_APPROX(p, v.segment(i, size-2*i).prod());
|
||||
@ -140,7 +140,7 @@ template<typename VectorType> void vectorRedux(const VectorType& w)
|
||||
void test_redux()
|
||||
{
|
||||
// the max size cannot be too large, otherwise reduxion operations obviously generate large errors.
|
||||
int maxsize = std::min(100,EIGEN_TEST_MAX_SIZE);
|
||||
int maxsize = (std::min)(100,EIGEN_TEST_MAX_SIZE);
|
||||
EIGEN_UNUSED_VARIABLE(maxsize);
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_1( matrixRedux(Matrix<float, 1, 1>()) );
|
||||
|
@ -29,6 +29,15 @@
|
||||
#include "main.h"
|
||||
|
||||
#if EIGEN_GNUC_AT_LEAST(4,0) && !defined __ICC && !defined(__clang__)
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#include <tr1/unordered_map>
|
||||
#define EIGEN_UNORDERED_MAP_SUPPORT
|
||||
namespace std {
|
||||
|
@ -34,7 +34,7 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
||||
typedef typename SparseMatrixType::Scalar Scalar;
|
||||
enum { Flags = SparseMatrixType::Flags };
|
||||
|
||||
double density = std::max(8./(rows*cols), 0.01);
|
||||
double density = (std::max)(8./(rows*cols), 0.01);
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
|
||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||
Scalar eps = 1e-6;
|
||||
@ -207,7 +207,7 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
||||
initSparse<Scalar>(density, refMat2, m2);
|
||||
int j0 = internal::random<int>(0,rows-2);
|
||||
int j1 = internal::random<int>(0,rows-2);
|
||||
int n0 = internal::random<int>(1,rows-std::max(j0,j1));
|
||||
int n0 = internal::random<int>(1,rows-(std::max)(j0,j1));
|
||||
VERIFY_IS_APPROX(m2.innerVectors(j0,n0), refMat2.block(0,j0,rows,n0));
|
||||
VERIFY_IS_APPROX(m2.innerVectors(j0,n0)+m2.innerVectors(j1,n0),
|
||||
refMat2.block(0,j0,rows,n0)+refMat2.block(0,j1,rows,n0));
|
||||
|
@ -58,7 +58,7 @@ template<typename SparseMatrixType> void sparse_product()
|
||||
typedef typename SparseMatrixType::Scalar Scalar;
|
||||
enum { Flags = SparseMatrixType::Flags };
|
||||
|
||||
double density = std::max(8./(rows*cols), 0.01);
|
||||
double density = (std::max)(8./(rows*cols), 0.01);
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
|
||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||
|
||||
|
@ -47,7 +47,7 @@ initSPD(double density,
|
||||
|
||||
template<typename Scalar> void sparse_solvers(int rows, int cols)
|
||||
{
|
||||
double density = std::max(8./(rows*cols), 0.01);
|
||||
double density = (std::max)(8./(rows*cols), 0.01);
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
|
||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||
// Scalar eps = 1e-6;
|
||||
|
@ -26,8 +26,8 @@
|
||||
|
||||
template<typename Scalar> void sparse_vector(int rows, int cols)
|
||||
{
|
||||
double densityMat = std::max(8./(rows*cols), 0.01);
|
||||
double densityVec = std::max(8./float(rows), 0.1);
|
||||
double densityMat = (std::max)(8./(rows*cols), 0.01);
|
||||
double densityVec = (std::max)(8./float(rows), 0.1);
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
|
||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||
typedef SparseVector<Scalar> SparseVectorType;
|
||||
|
@ -68,8 +68,8 @@ template<typename MatrixType> void stable_norm(const MatrixType& m)
|
||||
Index rows = m.rows();
|
||||
Index cols = m.cols();
|
||||
|
||||
Scalar big = internal::random<Scalar>() * (std::numeric_limits<RealScalar>::max() * RealScalar(1e-4));
|
||||
Scalar small = internal::random<Scalar>() * (std::numeric_limits<RealScalar>::min() * RealScalar(1e4));
|
||||
Scalar big = internal::random<Scalar>() * ((std::numeric_limits<RealScalar>::max)() * RealScalar(1e-4));
|
||||
Scalar small = internal::random<Scalar>() * ((std::numeric_limits<RealScalar>::min)() * RealScalar(1e4));
|
||||
|
||||
MatrixType vzero = MatrixType::Zero(rows, cols),
|
||||
vrand = MatrixType::Random(rows, cols),
|
||||
|
@ -242,7 +242,7 @@ void bug_159()
|
||||
|
||||
void test_triangular()
|
||||
{
|
||||
int maxsize = std::min(EIGEN_TEST_MAX_SIZE,20);
|
||||
int maxsize = (std::min)(EIGEN_TEST_MAX_SIZE,20);
|
||||
for(int i = 0; i < g_repeat ; i++)
|
||||
{
|
||||
int r = internal::random<int>(2,maxsize); EIGEN_UNUSED_VARIABLE(r);
|
||||
|
@ -331,7 +331,7 @@ class FFT
|
||||
// if the vector is strided, then we need to copy it to a packed temporary
|
||||
Matrix<src_type,1,Dynamic> tmp;
|
||||
if ( resize_input ) {
|
||||
size_t ncopy = std::min(src.size(),src.size() + resize_input);
|
||||
size_t ncopy = (std::min)(src.size(),src.size() + resize_input);
|
||||
tmp.setZero(src.size() + resize_input);
|
||||
if ( realfft && HasFlag(HalfSpectrum) ) {
|
||||
// pad at the Nyquist bin
|
||||
|
@ -231,7 +231,7 @@ private:
|
||||
template<typename BVH, typename Minimizer>
|
||||
typename Minimizer::Scalar BVMinimize(const BVH &tree, Minimizer &minimizer)
|
||||
{
|
||||
return internal::minimize_helper(tree, minimizer, tree.getRootIndex(), std::numeric_limits<typename Minimizer::Scalar>::max());
|
||||
return internal::minimize_helper(tree, minimizer, tree.getRootIndex(), (std::numeric_limits<typename Minimizer::Scalar>::max)());
|
||||
}
|
||||
|
||||
/** Given two BVH's, runs the query on their cartesian product encapsulated by \a minimizer.
|
||||
@ -264,7 +264,7 @@ typename Minimizer::Scalar BVMinimize(const BVH1 &tree1, const BVH2 &tree2, Mini
|
||||
ObjIter2 oBegin2 = ObjIter2(), oEnd2 = ObjIter2(), oCur2 = ObjIter2();
|
||||
std::priority_queue<QueueElement, std::vector<QueueElement>, std::greater<QueueElement> > todo; //smallest is at the top
|
||||
|
||||
Scalar minimum = std::numeric_limits<Scalar>::max();
|
||||
Scalar minimum = (std::numeric_limits<Scalar>::max)();
|
||||
todo.push(std::make_pair(Scalar(), std::make_pair(tree1.getRootIndex(), tree2.getRootIndex())));
|
||||
|
||||
while(!todo.empty()) {
|
||||
|
@ -259,7 +259,7 @@ void MatrixExponential<MatrixType>::computeUV(float)
|
||||
pade5(m_M);
|
||||
} else {
|
||||
const float maxnorm = 3.925724783138660f;
|
||||
m_squarings = max(0, (int)ceil(log2(m_l1norm / maxnorm)));
|
||||
m_squarings = (max)(0, (int)ceil(log2(m_l1norm / maxnorm)));
|
||||
MatrixType A = m_M / pow(Scalar(2), Scalar(static_cast<RealScalar>(m_squarings)));
|
||||
pade7(A);
|
||||
}
|
||||
@ -281,7 +281,7 @@ void MatrixExponential<MatrixType>::computeUV(double)
|
||||
pade9(m_M);
|
||||
} else {
|
||||
const double maxnorm = 5.371920351148152;
|
||||
m_squarings = max(0, (int)ceil(log2(m_l1norm / maxnorm)));
|
||||
m_squarings = (max)(0, (int)ceil(log2(m_l1norm / maxnorm)));
|
||||
MatrixType A = m_M / pow(Scalar(2), Scalar(m_squarings));
|
||||
pade13(A);
|
||||
}
|
||||
|
@ -90,13 +90,13 @@ struct BallPointStuff //this class provides functions to be both an intersector
|
||||
}
|
||||
|
||||
double minimumOnVolume(const BoxType &r) { ++calls; return r.squaredExteriorDistance(p); }
|
||||
double minimumOnObject(const BallType &b) { ++calls; return std::max(0., (b.center - p).squaredNorm() - SQR(b.radius)); }
|
||||
double minimumOnObject(const BallType &b) { ++calls; return (std::max)(0., (b.center - p).squaredNorm() - SQR(b.radius)); }
|
||||
double minimumOnVolumeVolume(const BoxType &r1, const BoxType &r2) { ++calls; return r1.squaredExteriorDistance(r2); }
|
||||
double minimumOnVolumeObject(const BoxType &r, const BallType &b) { ++calls; return SQR(std::max(0., r.exteriorDistance(b.center) - b.radius)); }
|
||||
double minimumOnObjectVolume(const BallType &b, const BoxType &r) { ++calls; return SQR(std::max(0., r.exteriorDistance(b.center) - b.radius)); }
|
||||
double minimumOnObjectObject(const BallType &b1, const BallType &b2){ ++calls; return SQR(std::max(0., (b1.center - b2.center).norm() - b1.radius - b2.radius)); }
|
||||
double minimumOnVolumeObject(const BoxType &r, const BallType &b) { ++calls; return SQR((std::max)(0., r.exteriorDistance(b.center) - b.radius)); }
|
||||
double minimumOnObjectVolume(const BallType &b, const BoxType &r) { ++calls; return SQR((std::max)(0., r.exteriorDistance(b.center) - b.radius)); }
|
||||
double minimumOnObjectObject(const BallType &b1, const BallType &b2){ ++calls; return SQR((std::max)(0., (b1.center - b2.center).norm() - b1.radius - b2.radius)); }
|
||||
double minimumOnVolumeObject(const BoxType &r, const VectorType &v) { ++calls; return r.squaredExteriorDistance(v); }
|
||||
double minimumOnObjectObject(const BallType &b, const VectorType &v){ ++calls; return SQR(std::max(0., (b.center - v).norm() - b.radius)); }
|
||||
double minimumOnObjectObject(const BallType &b, const VectorType &v){ ++calls; return SQR((std::max)(0., (b.center - v).norm() - b.radius)); }
|
||||
|
||||
VectorType p;
|
||||
int calls;
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
template<typename Scalar,typename Index> void cg(int size)
|
||||
{
|
||||
double density = std::max(8./(size*size), 0.01);
|
||||
double density = (std::max)(8./(size*size), 0.01);
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
|
||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||
typedef SparseMatrix<Scalar,ColMajor,Index> SparseMatrixType;
|
||||
|
@ -36,7 +36,7 @@ double binom(int n, int k)
|
||||
template <typename Derived, typename OtherDerived>
|
||||
double relerr(const MatrixBase<Derived>& A, const MatrixBase<OtherDerived>& B)
|
||||
{
|
||||
return std::sqrt((A - B).cwiseAbs2().sum() / std::min(A.cwiseAbs2().sum(), B.cwiseAbs2().sum()));
|
||||
return std::sqrt((A - B).cwiseAbs2().sum() / (std::min)(A.cwiseAbs2().sum(), B.cwiseAbs2().sum()));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -67,7 +67,7 @@ template<typename SparseMatrixType> void sparse_extra(const SparseMatrixType& re
|
||||
typedef typename SparseMatrixType::Scalar Scalar;
|
||||
enum { Flags = SparseMatrixType::Flags };
|
||||
|
||||
double density = std::max(8./(rows*cols), 0.01);
|
||||
double density = (std::max)(8./(rows*cols), 0.01);
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
|
||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||
Scalar eps = 1e-6;
|
||||
|
@ -33,7 +33,7 @@ template<typename Scalar,typename Index> void sparse_ldlt(int rows, int cols)
|
||||
{
|
||||
static bool odd = true;
|
||||
odd = !odd;
|
||||
double density = std::max(8./(rows*cols), 0.01);
|
||||
double density = (std::max)(8./(rows*cols), 0.01);
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
|
||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||
typedef SparseMatrix<Scalar,ColMajor,Index> SparseMatrixType;
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
template<typename Scalar,typename Index> void sparse_llt(int rows, int cols)
|
||||
{
|
||||
double density = std::max(8./(rows*cols), 0.01);
|
||||
double density = (std::max)(8./(rows*cols), 0.01);
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
|
||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||
typedef SparseMatrix<Scalar,ColMajor,Index> SparseMatrixType;
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
template<typename Scalar> void sparse_lu(int rows, int cols)
|
||||
{
|
||||
double density = std::max(8./(rows*cols), 0.01);
|
||||
double density = (std::max)(8./(rows*cols), 0.01);
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
|
||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user