aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2011-07-21 11:19:36 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2011-07-21 11:19:36 +0200
commit22bff949c898e7c340a415d771145c0bd22317d6 (patch)
treebe0fc956a220db15d4d7622fc580777f563ea643 /test
parentd4bd8bddb5e9f968ffcbdfff5936934e3d706684 (diff)
protect calls to min and max with parentheses to make Eigen compatible with default windows.h
Diffstat (limited to 'test')
-rw-r--r--test/adjoint.cpp4
-rw-r--r--test/bandmatrix.cpp2
-rw-r--r--test/cwiseop.cpp8
-rw-r--r--test/main.h5
4 files changed, 15 insertions, 4 deletions
diff --git a/test/adjoint.cpp b/test/adjoint.cpp
index 643aca731..76c59bedd 100644
--- a/test/adjoint.cpp
+++ b/test/adjoint.cpp
@@ -65,7 +65,7 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
// check basic properties of dot, norm, norm2
typedef typename NumTraits<Scalar>::Real RealScalar;
- RealScalar ref = NumTraits<Scalar>::IsInteger ? RealScalar(0) : std::max((s1 * v1 + s2 * v2).norm(),v3.norm());
+ RealScalar ref = NumTraits<Scalar>::IsInteger ? RealScalar(0) : (std::max)((s1 * v1 + s2 * v2).norm(),v3.norm());
VERIFY(test_isApproxWithRef((s1 * v1 + s2 * v2).dot(v3), internal::conj(s1) * v1.dot(v3) + internal::conj(s2) * v2.dot(v3), ref));
VERIFY(test_isApproxWithRef(v3.dot(s1 * v1 + s2 * v2), s1*v3.dot(v1)+s2*v3.dot(v2), ref));
VERIFY_IS_APPROX(internal::conj(v1.dot(v2)), v2.dot(v1));
@@ -84,7 +84,7 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
// check compatibility of dot and adjoint
- ref = NumTraits<Scalar>::IsInteger ? 0 : std::max(std::max(v1.norm(),v2.norm()),std::max((square * v2).norm(),(square.adjoint() * v1).norm()));
+ ref = NumTraits<Scalar>::IsInteger ? 0 : (std::max)((std::max)(v1.norm(),v2.norm()),(std::max)((square * v2).norm(),(square.adjoint() * v1).norm()));
VERIFY(test_isApproxWithRef(v1.dot(square * v2), (square.adjoint() * v1).dot(v2), ref));
// like in testBasicStuff, test operator() to check const-qualification
diff --git a/test/bandmatrix.cpp b/test/bandmatrix.cpp
index 84fc387e0..996886f43 100644
--- a/test/bandmatrix.cpp
+++ b/test/bandmatrix.cpp
@@ -61,7 +61,7 @@ template<typename MatrixType> void bandmatrix(const MatrixType& _m)
m.col(i).setConstant(static_cast<RealScalar>(i+1));
dm1.col(i).setConstant(static_cast<RealScalar>(i+1));
}
- Index d = std::min(rows,cols);
+ Index d = (std::min)(rows,cols);
Index a = std::max<Index>(0,cols-d-supers);
Index b = std::max<Index>(0,rows-d-subs);
if(a>0) dm1.block(0,d+supers,rows,a).setZero();
diff --git a/test/cwiseop.cpp b/test/cwiseop.cpp
index 2ad56eb93..571c5a800 100644
--- a/test/cwiseop.cpp
+++ b/test/cwiseop.cpp
@@ -28,6 +28,14 @@
#include "main.h"
#include <functional>
+#ifdef min
+#undef min
+#endif
+
+#ifdef max
+#undef max
+#endif
+
using namespace std;
template<typename Scalar> struct AddIfNull {
diff --git a/test/main.h b/test/main.h
index 407c7be46..99049223c 100644
--- a/test/main.h
+++ b/test/main.h
@@ -23,6 +23,9 @@
// 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>
@@ -337,7 +340,7 @@ void createRandomPIMatrixOfRank(typename MatrixType::Index desired_rank, typenam
MatrixBType b = MatrixBType::Random(cols,cols);
// set the diagonal such that only desired_rank non-zero entries reamain
- const Index diag_size = std::min(d.rows(),d.cols());
+ const Index diag_size = (std::min)(d.rows(),d.cols());
if(diag_size != desired_rank)
d.diagonal().segment(desired_rank, diag_size-desired_rank) = VectorType::Zero(diag_size-desired_rank);