aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2007-08-12 09:32:17 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2007-08-12 09:32:17 +0000
commit71268227d44d560b224c321e0bc36a2594cc003e (patch)
tree6a9a20eeac245aec7c3af8452b094fa59abbd939
parentca438b2c1257d57f28b82da93b2584466b9319ae (diff)
Big rework of the Traits system, unittests updated.
-rw-r--r--tvmet-1.7.1/ChangeLog30
-rw-r--r--tvmet-1.7.1/ChangeLog.114
-rw-r--r--tvmet-1.7.1/examples/frob_matrix_norm.cc4
-rw-r--r--tvmet-1.7.1/include/tvmet/MatrixFunctions.h4
-rw-r--r--tvmet-1.7.1/include/tvmet/MatrixImpl.h12
-rw-r--r--tvmet-1.7.1/include/tvmet/NumericTraits.h323
-rw-r--r--tvmet-1.7.1/include/tvmet/Traits.h122
-rw-r--r--tvmet-1.7.1/include/tvmet/VectorFunctions.h18
-rw-r--r--tvmet-1.7.1/include/tvmet/VectorImpl.h12
-rw-r--r--tvmet-1.7.1/include/tvmet/meta/Matrix.h2
-rw-r--r--tvmet-1.7.1/include/tvmet/meta/Vector.h4
-rw-r--r--tvmet-1.7.1/include/tvmet/util/Random.h88
-rw-r--r--tvmet-1.7.1/include/tvmet/xpr/MMProduct.h4
-rw-r--r--tvmet-1.7.1/include/tvmet/xpr/MMProductTransposed.h4
-rw-r--r--tvmet-1.7.1/include/tvmet/xpr/MMtProduct.h4
-rw-r--r--tvmet-1.7.1/include/tvmet/xpr/MVProduct.h4
-rw-r--r--tvmet-1.7.1/include/tvmet/xpr/MatrixFunctions.h4
-rw-r--r--tvmet-1.7.1/include/tvmet/xpr/MtMProduct.h4
-rw-r--r--tvmet-1.7.1/include/tvmet/xpr/MtVProduct.h4
-rw-r--r--tvmet-1.7.1/include/tvmet/xpr/VectorFunctions.h16
-rw-r--r--tvmet-1.7.1/testsuite/CMakeLists.txt6
-rw-r--r--tvmet-1.7.1/testsuite/TestNumericTraits.cc26
-rw-r--r--tvmet-1.7.1/testsuite/TestNumericTraits.h90
-rw-r--r--tvmet-1.7.1/testsuite/TestNumericTraitsComplex.cc18
-rw-r--r--tvmet-1.7.1/testsuite/TestNumericTraitsComplex.h212
-rw-r--r--tvmet-1.7.1/testsuite/TestVectorFunctions.h4
-rw-r--r--tvmet-1.7.1/testsuite/TestXprVectorFunctions.h4
-rw-r--r--tvmet-1.7.1/testsuite/main.h5
-rw-r--r--tvmet-1.7.1/testsuite/testnumerictraits.cpp86
-rw-r--r--tvmet-1.7.1/testsuite/testtraits.cpp126
30 files changed, 501 insertions, 753 deletions
diff --git a/tvmet-1.7.1/ChangeLog b/tvmet-1.7.1/ChangeLog
index 7e7066a21..6c336d4b1 100644
--- a/tvmet-1.7.1/ChangeLog
+++ b/tvmet-1.7.1/ChangeLog
@@ -101,12 +101,12 @@
2004-11-04 19:12 opetzold
- * testsuite/: TestNumericTraits.h, TestNumericTraitsComplex.h: conj
+ * testsuite/: TestTraits.h, TestTraitsComplex.h: conj
tests updated for signed and unsigned types.
2004-11-04 19:10 opetzold
- * include/tvmet/NumericTraits.h: conj for all unsigned types
+ * include/tvmet/Traits.h: conj for all unsigned types
disabled. An unary minus operator applied to unsigned type will
result unsigned.
@@ -125,7 +125,7 @@
2004-11-04 17:25 opetzold
- * include/tvmet/NumericTraits.h: bug removed: displaced semicolon
+ * include/tvmet/Traits.h: bug removed: displaced semicolon
removed - was wrong statement termination.
2004-11-04 17:21 opetzold
@@ -149,7 +149,7 @@
2004-10-31 10:51 opetzold
- * include/tvmet/NumericTraits.h: doxygen notes added for unsigned
+ * include/tvmet/Traits.h: doxygen notes added for unsigned
types and conj - it's useless.
2004-10-31 10:50 opetzold
@@ -233,8 +233,8 @@
2004-09-15 09:51 opetzold
- * testsuite/: TestNumericTraits.cc, TestNumericTraits.h,
- TestNumericTraitsComplex.cc, TestNumericTraitsComplex.h: added new
+ * testsuite/: TestTraits.cc, TestTraits.h,
+ TestTraitsComplex.cc, TestTraitsComplex.h: added new
tests for tvmet's traits.
2004-07-06 11:45 opetzold
@@ -421,7 +421,7 @@
2004-06-08 18:16 opetzold
- * include/tvmet/NumericTraits.h: extended member to simplify
+ * include/tvmet/Traits.h: extended member to simplify
complex calcs; not used yet.
2004-06-08 14:11 opetzold
@@ -914,7 +914,7 @@
2003-12-13 21:20 opetzold
- * include/tvmet/NumericTraits.h: infos about complex type added.
+ * include/tvmet/Traits.h: infos about complex type added.
2003-12-09 19:38 opetzold
@@ -1191,7 +1191,7 @@
include/tvmet/MatrixEval.h, include/tvmet/MatrixFunctions.h,
include/tvmet/MatrixImpl.h, include/tvmet/MatrixOperators.h,
include/tvmet/MatrixUnaryFunctions.h,
- include/tvmet/NumericTraits.h, include/tvmet/RunTimeError.h,
+ include/tvmet/Traits.h, include/tvmet/RunTimeError.h,
include/tvmet/TvmetBase.h, include/tvmet/TypePromotion.h,
include/tvmet/UnaryFunctionals.h, include/tvmet/Vector.h,
include/tvmet/VectorBinaryFunctions.h, include/tvmet/VectorEval.h,
@@ -1500,7 +1500,7 @@
2003-10-21 20:48 opetzold
- * include/tvmet/NumericTraits.h: complexity for numeric types
+ * include/tvmet/Traits.h: complexity for numeric types
added.
2003-10-21 20:39 opetzold
@@ -1777,7 +1777,7 @@
CompileTimeError.h, Extremum.h, Functional.h, Matrix.h,
MatrixBinaryFunctions.h, MatrixEval.h, MatrixFunctions.h,
MatrixImpl.h, MatrixOperators.h, MatrixUnaryFunctions.h,
- NumericTraits.h, RunTimeError.h, TvmetBase.h, TypePromotion.h,
+ Traits.h, RunTimeError.h, TvmetBase.h, TypePromotion.h,
UnaryFunctionals.h, Vector.h, VectorBinaryFunctions.h,
VectorEval.h, VectorFunctions.h, VectorImpl.h, VectorOperators.h,
VectorUnaryFunctions.h, tvmet.h, meta/Gemm.h, meta/Gemmt.h,
@@ -3811,7 +3811,7 @@
include/tvmet/Extremum.h, include/tvmet/Functional.h,
include/tvmet/Matrix.h, include/tvmet/MatrixEval.h,
include/tvmet/MatrixFunctions.h, include/tvmet/MatrixImpl.h,
- include/tvmet/MatrixOperators.h, include/tvmet/NumericTraits.h,
+ include/tvmet/MatrixOperators.h, include/tvmet/Traits.h,
include/tvmet/RunTimeError.h, include/tvmet/TvmetBase.h,
include/tvmet/TypePromotion.h, include/tvmet/UnaryFunctionals.h,
include/tvmet/Vector.h, include/tvmet/VectorEval.h,
@@ -3935,7 +3935,7 @@
include/tvmet/Extremum.h, include/tvmet/Functional.h,
include/tvmet/Matrix.h, include/tvmet/MatrixEval.h,
include/tvmet/MatrixFunctions.h, include/tvmet/MatrixImpl.h,
- include/tvmet/MatrixOperators.h, include/tvmet/NumericTraits.h,
+ include/tvmet/MatrixOperators.h, include/tvmet/Traits.h,
include/tvmet/RunTimeError.h, include/tvmet/TvmetBase.h,
include/tvmet/TypePromotion.h, include/tvmet/UnaryFunctionals.h,
include/tvmet/Vector.h, include/tvmet/VectorEval.h,
@@ -4003,7 +4003,7 @@
include/tvmet/Makefile.am, include/tvmet/Makefile.in,
include/tvmet/Matrix.h, include/tvmet/MatrixEval.h,
include/tvmet/MatrixFunctions.h, include/tvmet/MatrixImpl.h,
- include/tvmet/MatrixOperators.h, include/tvmet/NumericTraits.h,
+ include/tvmet/MatrixOperators.h, include/tvmet/Traits.h,
include/tvmet/RunTimeError.h, include/tvmet/TvmetBase.h,
include/tvmet/TypePromotion.h, include/tvmet/UnaryFunctionals.h,
include/tvmet/Vector.h, include/tvmet/VectorEval.h,
@@ -4078,7 +4078,7 @@
include/tvmet/Makefile.am, include/tvmet/Makefile.in,
include/tvmet/Matrix.h, include/tvmet/MatrixEval.h,
include/tvmet/MatrixFunctions.h, include/tvmet/MatrixImpl.h,
- include/tvmet/MatrixOperators.h, include/tvmet/NumericTraits.h,
+ include/tvmet/MatrixOperators.h, include/tvmet/Traits.h,
include/tvmet/RunTimeError.h, include/tvmet/TvmetBase.h,
include/tvmet/TypePromotion.h, include/tvmet/UnaryFunctionals.h,
include/tvmet/Vector.h, include/tvmet/VectorEval.h,
diff --git a/tvmet-1.7.1/ChangeLog.1 b/tvmet-1.7.1/ChangeLog.1
index 391a35ba0..11ee5e420 100644
--- a/tvmet-1.7.1/ChangeLog.1
+++ b/tvmet-1.7.1/ChangeLog.1
@@ -313,7 +313,7 @@
* regression/TestMathOps.h: Test for normalize(Vector<>) added.
* include/tvmet/{Matrix,Vector}Operators.h: Matrix/Vector<T, Sz> and POD's
- extended with long long int to handle long long from NumericTraits
+ extended with long long int to handle long long from Traits
too.
2002-10-29 opetzold <opetzold@wit.regiocom.net>
@@ -339,7 +339,7 @@
* doc/Doxygen.in: PREDEFINED targets use the forgotten TVMET prefix too.
- * include/tvmet/{Binary|UnaryFunctionals.h, NumericTraits.h,
+ * include/tvmet/{Binary|UnaryFunctionals.h, Traits.h,
TypePromotion.h TvmetBase.h}: macros
generated operators, functions and functionals doc added for
doxygen include path.
@@ -443,7 +443,7 @@
* version 0.4.0 released
- * include/tvmet/NumericTraits.h: rewritten to avoid macro and ifdef garbage.
+ * include/tvmet/Traits.h: rewritten to avoid macro and ifdef garbage.
* include/tvmet/*: member rename to be conform to m_xxx
@@ -475,7 +475,7 @@
and complex types as well. Change ranking breaks compatibility
with prior releases.
- * include/tvmet/NumericTraits.h: support for long long. Specialized version for
+ * include/tvmet/Traits.h: support for long long. Specialized version for
long double and long long self removed - there isn't a way to guarantee
the precision than.
@@ -556,10 +556,10 @@
* include/tvmet/TypePromotion.h: std::complex<int> added, therfore the priorities
for all complex types have changed!
- * include/tvmet/NumericTraits.h: depends on HAVE_LONG_DOUBLE, sum_type of double
+ * include/tvmet/Traits.h: depends on HAVE_LONG_DOUBLE, sum_type of double
is long double or double.
- * include/tvmet/{MatrixEval.h, MatrixFunctions.h, MatrixOperators.h, NumericTraits.h,
+ * include/tvmet/{MatrixEval.h, MatrixFunctions.h, MatrixOperators.h, Traits.h,
TypePromotion.h, UnaryFunctionals.h, VectorEval.h, VectorFunctions.h,
VectorOperators.h, XprFunctions.h, XprOperators.h} HAVE_LONG_DOUBLE
encapsulated.
@@ -577,7 +577,7 @@
* examples/Makefile.am (examples): bug corrected.
- * include/tvmet/NumericTraits.h: complex<int> numeric traits added.
+ * include/tvmet/Traits.h: complex<int> numeric traits added.
* include/tvmet/MatrixOperators.h: operator*() is in namespace element_wise left
diff --git a/tvmet-1.7.1/examples/frob_matrix_norm.cc b/tvmet-1.7.1/examples/frob_matrix_norm.cc
index 446a440cb..eb26e4161 100644
--- a/tvmet-1.7.1/examples/frob_matrix_norm.cc
+++ b/tvmet-1.7.1/examples/frob_matrix_norm.cc
@@ -37,7 +37,7 @@ frob_norm(const tvmet::Matrix<T, Rows, Cols>& M) {
namespace tvmet {
template<class T, int Rows, int Cols>
- typename NumericTraits<T>::float_type
+ typename Traits<T>::float_type
norm(const Matrix<T, Rows, Cols>& M) {
return std::sqrt( sum( diag( MtM_prod(M,M) ) ) );
}
@@ -113,7 +113,7 @@ _Z9frob_normIdLj3ELj3EEdRKN5tvmet6MatrixIT_XT0_EXT1_EEE:
/*
gcc 3.3 produce the norm function using tvmet 1.3.0:
-_ZN5tvmet4normIdLj3ELj3EEENS_13NumericTraitsIT_E10float_typeERKNS_6MatrixIS2_XT0_EXT1_EEE:
+_ZN5tvmet4normIdLj3ELj3EEENS_13TraitsIT_E10float_typeERKNS_6MatrixIS2_XT0_EXT1_EEE:
.LFB3252:
.L194:
.L198:
diff --git a/tvmet-1.7.1/include/tvmet/MatrixFunctions.h b/tvmet-1.7.1/include/tvmet/MatrixFunctions.h
index add1184b1..49db418ae 100644
--- a/tvmet-1.7.1/include/tvmet/MatrixFunctions.h
+++ b/tvmet-1.7.1/include/tvmet/MatrixFunctions.h
@@ -337,7 +337,7 @@ trans(const Matrix<T, Rows, Cols>& rhs) _tvmet_always_inline;
template<class T, int Sz>
-typename NumericTraits<T>::sum_type
+typename Traits<T>::sum_type
trace(const Matrix<T, Sz, Sz>& m) _tvmet_always_inline;
@@ -972,7 +972,7 @@ trans(const Matrix<T, Rows, Cols>& rhs) {
*/
template<class T, int Sz>
inline
-typename NumericTraits<T>::sum_type
+typename Traits<T>::sum_type
trace(const Matrix<T, Sz, Sz>& m) {
return meta::Matrix<Sz, Sz, 0, 0>::trace(m);
}
diff --git a/tvmet-1.7.1/include/tvmet/MatrixImpl.h b/tvmet-1.7.1/include/tvmet/MatrixImpl.h
index 8704366fc..32d8624a6 100644
--- a/tvmet-1.7.1/include/tvmet/MatrixImpl.h
+++ b/tvmet-1.7.1/include/tvmet/MatrixImpl.h
@@ -51,12 +51,12 @@ std::ostream& Matrix<T, NRows, NCols>::print_xpr(std::ostream& os, int l) const
template<class T, int NRows, int NCols>
std::ostream& Matrix<T, NRows, NCols>::print_on(std::ostream& os) const
{
- enum {
- complex_type = NumericTraits<value_type>::is_complex
- };
-
- std::streamsize w = IoPrintHelper<Matrix>::width(dispatch<complex_type>(), *this);
-
+ std::streamsize w;
+ if(Traits<value_type>::isComplex())
+ w = IoPrintHelper<Matrix>::width(dispatch<true>(), *this);
+ else
+ w = IoPrintHelper<Matrix>::width(dispatch<false>(), *this);
+
os << std::setw(0) << "[\n";
for(int i = 0; i < Rows; ++i) {
os << " [";
diff --git a/tvmet-1.7.1/include/tvmet/NumericTraits.h b/tvmet-1.7.1/include/tvmet/NumericTraits.h
deleted file mode 100644
index 53540fcdc..000000000
--- a/tvmet-1.7.1/include/tvmet/NumericTraits.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Tiny Vector Matrix Library
- * Dense Vector Matrix Libary of Tiny size using Expression Templates
- *
- * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id: NumericTraits.h,v 1.11 2004/11/04 18:10:35 opetzold Exp $
- */
-
-#ifndef TVMET_NUMERIC_TRAITS_H
-#define TVMET_NUMERIC_TRAITS_H
-
-#if defined(EIGEN_USE_COMPLEX)
-# include <complex>
-#endif
-
-#include <cmath>
-#include <limits>
-
-#include <tvmet/CompileTimeError.h>
-#include <tvmet/util/Random.h>
-
-namespace tvmet {
-
-/**
- * \class NumericTraits NumericTraits.h "tvmet/NumericTraits.h"
- * \brief Traits for integral types for operations.
- *
- * For each type we have to specialize this traits.
- */
-template<class T>
-struct NumericTraits {
- typedef T real_type;
- typedef T value_type;
- typedef T float_type;
- typedef const T & argument_type;
-
- static inline
- real_type real(argument_type x);
-
- static inline
- real_type imag(argument_type x);
-
- static inline
- value_type conj(argument_type x);
-
- static inline
- real_type abs(argument_type x);
-
- static inline
- value_type sqrt(argument_type x);
-
- enum{ is_complex = false };
-};
-
-/*
- * numeric traits for built-in types
- */
-
-/**
- * \class NumericTraits<int> NumericTraits.h "tvmet/NumericTraits.h"
- * \brief Traits specialized for int.
- */
-template<>
-struct NumericTraits<int> {
- typedef int value_type;
- typedef value_type real_type;
- typedef double float_type;
- typedef value_type argument_type;
-
- static inline
- real_type real(argument_type x) { return x; }
-
- static inline
- real_type imag(argument_type x) { TVMET_UNUSED(x); return 0; }
-
- static inline
- value_type conj(argument_type x) { return x; }
-
- static inline
- value_type sqrt(argument_type x) {
- return static_cast<value_type>(std::sqrt(static_cast<float_type>(x)));
- }
-
- static inline
- value_type abs(argument_type x) {
- return std::abs(x);
- }
-
- enum { is_complex = false };
-
- /** Complexity on operations. */
- enum {
- ops_plus = 1, /**< Complexity on plus/minus ops. */
- ops_muls = 1 /**< Complexity on multiplications. */
- };
-};
-
-/**
- * \class NumericTraits<float> NumericTraits.h "tvmet/NumericTraits.h"
- * \brief Traits specialized for float.
- */
-template<>
-struct NumericTraits<float> {
- typedef float value_type;
- typedef value_type real_type;
- typedef value_type float_type;
- typedef value_type argument_type;
-
- static inline
- real_type real(argument_type x) { return x; }
-
- static inline
- real_type imag(argument_type x) { TVMET_UNUSED(x); return 0; }
-
- static inline
- value_type conj(argument_type x) { return x; }
-
- static inline
- value_type sqrt(argument_type x) {
- return std::sqrt(x);
- }
-
- static inline
- value_type abs(argument_type x) {
- return std::abs(x);
- }
-
- enum { is_complex = false };
-
- /** Complexity on operations. */
- enum {
- ops_plus = 1, /**< Complexity on plus/minus ops. */
- ops_muls = 1 /**< Complexity on multiplications. */
- };
-};
-
-
-/**
- * \class NumericTraits<double> NumericTraits.h "tvmet/NumericTraits.h"
- * \brief Traits specialized for double.
- */
-template<>
-struct NumericTraits<double> {
- typedef double value_type;
- typedef value_type real_type;
- typedef value_type float_type;
- typedef value_type argument_type;
-
- static inline
- real_type real(argument_type x) { return x; }
-
- static inline
- real_type imag(argument_type x) { TVMET_UNUSED(x); return 0; }
-
- static inline
- value_type conj(argument_type x) { return x; }
-
- static inline
- value_type sqrt(argument_type x) {
- return std::sqrt(x);
- }
-
- static inline
- value_type abs(argument_type x) {
- return std::abs(x);
- }
-
- enum { is_complex = false };
-
- /** Complexity on operations. */
- enum {
- ops_plus = 1, /**< Complexity on plus/minus ops. */
- ops_muls = 1 /**< Complexity on multiplications. */
- };
-};
-
-
-/*
- * numeric traits for complex types
- */
-#if defined(EIGEN_USE_COMPLEX)
-
-/**
- * \class NumericTraits< std::complex<int> > NumericTraits.h "tvmet/NumericTraits.h"
- * \brief Traits specialized for std::complex<int>.
- */
-template<>
-struct NumericTraits< std::complex<int> > {
- typedef std::complex<int> value_type;
- typedef int real_type;
- typedef std::complex<float> float_type;
- typedef const value_type& argument_type;
-
- static inline
- real_type real(argument_type z) { return std::real(z); }
-
- static inline
- real_type imag(argument_type z) { return std::imag(z); }
-
- static inline
- value_type conj(argument_type z) { return std::conj(z); }
-
- static inline
- real_type abs(argument_type z) {
- // the use of ceil() guarantees e.g. that abs(real(x)) <= abs(x),
- // and that abs(x)==0 if and only if x==0.
- return static_cast<value_type>(std::ceil(std::abs(static_cast<float_type>(x))));
- }
-
- static inline
- value_type sqrt(argument_type x) {
- return static_cast<value_type>(std::sqrt(static_cast<float_type>(x)));
- }
-
- enum { is_complex = true };
-
- /** Complexity on operations. */
- enum {
- ops_plus = 2, /**< Complexity on plus/minus ops. */
- ops_muls = 6 /**< Complexity on multiplications. */
- };
-};
-
-
-/**
- * \class NumericTraits< std::complex<float> > NumericTraits.h "tvmet/NumericTraits.h"
- * \brief Traits specialized for std::complex<float>.
- */
-template<>
-struct NumericTraits< std::complex<float> > {
- typedef std::complex<float> value_type;
- typedef float real_type;
- typedef value_type float_type;
- typedef const value_type& argument_type;
-
- static inline
- real_type real(argument_type z) { return std::real(z); }
-
- static inline
- real_type imag(argument_type z) { return std::imag(z); }
-
- static inline
- value_type conj(argument_type z) { return std::conj(z); }
-
- static inline
- value_type sqrt(argument_type x) {
- return std::sqrt(x);
- }
-
- static inline
- value_type abs(argument_type x) {
- return std::abs(x);
- }
-
- enum { is_complex = true };
-
- /** Complexity on operations. */
- enum {
- ops_plus = 2, /**< Complexity on plus/minus ops. */
- ops_muls = 6 /**< Complexity on multiplications. */
- };
-};
-
-
-/**
- * \class NumericTraits< std::complex<double> > NumericTraits.h "tvmet/NumericTraits.h"
- * \brief Traits specialized for std::complex<double>.
- */
-template<>
-struct NumericTraits< std::complex<double> > {
- typedef std::complex<double> value_type;
- typedef double real_type;
- typedef value_type float_type;
- typedef const value_type& argument_type;
-
- static inline
- real_type real(argument_type z) { return std::real(z); }
-
- static inline
- real_type imag(argument_type z) { return std::imag(z); }
-
- static inline
- value_type conj(argument_type z) { return std::conj(z); }
-
- static inline
- value_type sqrt(argument_type x) {
- return std::sqrt(x);
- }
-
- static inline
- value_type abs(argument_type x) {
- return std::abs(x);
- }
-
- enum { is_complex = true };
-
- /** Complexity on operations. */
- enum {
- ops_plus = 2, /**< Complexity on plus/minus ops. */
- ops_muls = 6 /**< Complexity on multiplications. */
- };
-};
-
-#endif // defined(EIGEN_USE_COMPLEX)
-
-} // namespace tvmet
-
-#endif // TVMET_NUMERIC_TRAITS_H
diff --git a/tvmet-1.7.1/include/tvmet/Traits.h b/tvmet-1.7.1/include/tvmet/Traits.h
new file mode 100644
index 000000000..10d016185
--- /dev/null
+++ b/tvmet-1.7.1/include/tvmet/Traits.h
@@ -0,0 +1,122 @@
+/* This file is part of Eigen, a C++ template library for linear algebra
+ * Copyright (C) 2007 Benoit Jacob <jacob@math.jussieu.fr>
+ *
+ * Based on Tvmet source code, http://tvmet.sourceforge.net,
+ * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id: Traits.h,v 1.11 2004/11/04 18:10:35 opetzold Exp $
+ */
+
+#ifndef TVMET_NUMERIC_TRAITS_H
+#define TVMET_NUMERIC_TRAITS_H
+
+#if defined(EIGEN_USE_COMPLEX)
+# include <complex>
+#endif
+
+#include <cmath>
+
+#include <tvmet/TraitsBase.h>
+
+namespace tvmet {
+
+/**
+ * \class Traits Traits.h "tvmet/Traits.h"
+ * \brief Traits for standard types.
+ *
+ */
+template<typename T>
+struct Traits : public TraitsBase<T>
+{
+ typedef TraitsBase<T> Base;
+ typedef typename Base::value_type value_type;
+ typedef typename Base::real_type real_type;
+ typedef typename Base::float_type float_type;
+ typedef typename Base::argument_type argument_type;
+
+ using Base::isFloat;
+ using Base::isComplex;
+ using Base::epsilon;
+ using Base::abs;
+ using Base::real;
+ using Base::imag;
+ using Base::conj;
+ using Base::sqrt;
+
+ static value_type random()
+ {
+ value_type x;
+ pickRandom(x);
+ return x;
+ }
+ /**
+ * Short version: returns true if the absolute value of \a a is much smaller
+ * than that of \a b.
+ *
+ * Full story: returns(abs(a) <= abs(b) * epsilon());
+ */
+ static bool isNegligible(argument_type a, argument_type b)
+ {
+ if(isFloat())
+ return(abs(a) <= abs(b) * epsilon());
+ else
+ return(a==0);
+ }
+
+ /**
+ * Short version: returns true if \a a is approximately zero.
+ *
+ * Full story: returns isNegligible( a, static_cast<T>(1) );
+ */
+ static bool isZero(argument_type a)
+ {
+ return isNegligible(a, static_cast<value_type>(1));
+ }
+
+ /**
+ * Short version: returns true if a is very close to b, false otherwise.
+ *
+ * Full story: returns abs( a - b ) <= min( abs(a), abs(b) ) * epsilon<T>.
+ */
+ static bool isApprox(argument_type a, argument_type b)
+ {
+ if(isFloat())
+ return(abs( a - b ) <= std::min(abs(a), abs(b)) * epsilon());
+ else
+ return(a==b);
+ }
+
+ /**
+ * Short version: returns true if a is smaller or approximately equalt to b, false otherwise.
+ *
+ * Full story: returns a <= b || isApprox(a, b);
+ */
+ static bool isLessThan( argument_type a, argument_type b )
+ {
+ assert(!isComplex());
+ if(isFloat())
+ return(a <= b || isApprox(a, b));
+ else
+ return(a<=b);
+ }
+
+};
+
+
+} // namespace tvmet
+
+#endif // TVMET_NUMERIC_TRAITS_H
diff --git a/tvmet-1.7.1/include/tvmet/VectorFunctions.h b/tvmet-1.7.1/include/tvmet/VectorFunctions.h
index 65174a7a0..6d549a109 100644
--- a/tvmet-1.7.1/include/tvmet/VectorFunctions.h
+++ b/tvmet-1.7.1/include/tvmet/VectorFunctions.h
@@ -187,12 +187,12 @@ TVMET_DECLARE_MACRO(div)
template<class T, int Sz>
-typename NumericTraits<T>::sum_type
+typename Traits<T>::sum_type
sum(const Vector<T, Sz>& v) _tvmet_always_inline;
template<class T, int Sz>
-typename NumericTraits<T>::sum_type
+typename Traits<T>::sum_type
product(const Vector<T, Sz>& v) _tvmet_always_inline;
@@ -209,12 +209,12 @@ cross(const Vector<T1, 3>& lhs,
template<class T, int Sz>
-typename NumericTraits<T>::sum_type
+typename Traits<T>::sum_type
norm1(const Vector<T, Sz>& v) _tvmet_always_inline;
template<class T, int Sz>
-typename NumericTraits<T>::sum_type
+typename Traits<T>::sum_type
norm2(const Vector<T, Sz>& v) _tvmet_always_inline;
@@ -505,7 +505,7 @@ TVMET_IMPLEMENT_MACRO(div)
*/
template<class T, int Sz>
inline
-typename NumericTraits<T>::sum_type
+typename Traits<T>::sum_type
sum(const Vector<T, Sz>& v) {
return meta::Vector<Sz>::sum(v);
}
@@ -523,7 +523,7 @@ sum(const Vector<T, Sz>& v) {
*/
template<class T, int Sz>
inline
-typename NumericTraits<T>::sum_type
+typename Traits<T>::sum_type
product(const Vector<T, Sz>& v) {
return meta::Vector<Sz>::product(v);
}
@@ -580,7 +580,7 @@ cross(const Vector<T1, 3>& lhs, const Vector<T2, 3>& rhs) {
*/
template<class T, int Sz>
inline
-typename NumericTraits<T>::sum_type
+typename Traits<T>::sum_type
norm1(const Vector<T, Sz>& v) {
return sum(abs(v));
}
@@ -601,9 +601,9 @@ norm1(const Vector<T, Sz>& v) {
*/
template<class T, int Sz>
inline
-typename NumericTraits<T>::sum_type
+typename Traits<T>::sum_type
norm2(const Vector<T, Sz>& v) {
- return static_cast<T>( std::sqrt(static_cast<typename NumericTraits<T>::float_type>(dot(v, v))) );
+ return static_cast<T>( std::sqrt(static_cast<typename Traits<T>::float_type>(dot(v, v))) );
}
diff --git a/tvmet-1.7.1/include/tvmet/VectorImpl.h b/tvmet-1.7.1/include/tvmet/VectorImpl.h
index a1a28cfb7..3310ddfed 100644
--- a/tvmet-1.7.1/include/tvmet/VectorImpl.h
+++ b/tvmet-1.7.1/include/tvmet/VectorImpl.h
@@ -51,12 +51,12 @@ std::ostream& Vector<T, Sz>::print_xpr(std::ostream& os, int l) const
template<class T, int Sz>
std::ostream& Vector<T, Sz>::print_on(std::ostream& os) const
{
- enum {
- complex_type = NumericTraits<value_type>::is_complex
- };
-
- std::streamsize w = IoPrintHelper<Vector>::width(dispatch<complex_type>(), *this);
-
+ std::streamsize w;
+ if(Traits<value_type>::isComplex())
+ w = IoPrintHelper<Vector>::width(dispatch<true>(), *this);
+ else
+ w = IoPrintHelper<Vector>::width(dispatch<false>(), *this);
+
os << std::setw(0) << "[\n ";
for(int i = 0; i < (Size - 1); ++i) {
os << std::setw(w) << m_data[i] << ", ";
diff --git a/tvmet-1.7.1/include/tvmet/meta/Matrix.h b/tvmet-1.7.1/include/tvmet/meta/Matrix.h
index 0764c31da..b6b4014dc 100644
--- a/tvmet-1.7.1/include/tvmet/meta/Matrix.h
+++ b/tvmet-1.7.1/include/tvmet/meta/Matrix.h
@@ -24,7 +24,7 @@
#ifndef TVMET_META_MATRIX_H
#define TVMET_META_MATRIX_H
-#include <tvmet/NumericTraits.h>
+#include <tvmet/Traits.h>
#include <tvmet/xpr/Null.h>
namespace tvmet {
diff --git a/tvmet-1.7.1/include/tvmet/meta/Vector.h b/tvmet-1.7.1/include/tvmet/meta/Vector.h
index b9f2c9c63..02888c4cb 100644
--- a/tvmet-1.7.1/include/tvmet/meta/Vector.h
+++ b/tvmet-1.7.1/include/tvmet/meta/Vector.h
@@ -24,7 +24,7 @@
#ifndef TVMET_META_VECTOR_H
#define TVMET_META_VECTOR_H
-#include <tvmet/NumericTraits.h>
+#include <tvmet/Traits.h>
#include <tvmet/xpr/Null.h>
namespace tvmet {
@@ -72,7 +72,7 @@ public:
/** build the product of the vector. */
template<class E>
static inline
- typename NumericTraits<
+ typename Traits<
typename E::value_type
>::sum_type
product(const E& e) {
diff --git a/tvmet-1.7.1/include/tvmet/util/Random.h b/tvmet-1.7.1/include/tvmet/util/Random.h
deleted file mode 100644
index 5f62b4729..000000000
--- a/tvmet-1.7.1/include/tvmet/util/Random.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* This file is part of Eigen, a C++ template library for linear algebra
- * Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id: SelfTest.cc,v 1.1 2004/04/24 11:55:15 opetzold Exp $
- */
-
-#ifndef TVMET_UTIL_RANDOM_H
-#define TVMET_UTIL_RANDOM_H
-
-#ifdef __GNUC__
-# if __GNUC__>=4
-# define EIGEN_WITH_GCC_4_OR_LATER
-# endif
-#endif
-
-#include <cstdlib>
-
-#ifdef EIGEN_USE_COMPLEX
-#include <complex>
-#endif
-
-namespace tvmet {
-
-namespace util {
-
-/** Stores in x a random int between -RAND_MAX/2 and RAND_MAX/2 */
-inline void pickRandom( int & x )
-{
- x = rand() - RAND_MAX / 2;
-}
-
-
-/** Stores in x a random float between -1.0 and 1.0 */
-inline void pickRandom( float & x )
-{
- x = 2.0f * rand() / RAND_MAX - 1.0f;
-}
-
-/** Stores in x a random double between -1.0 and 1.0 */
-inline void pickRandom( double & x )
-{
- x = 2.0 * rand() / RAND_MAX - 1.0;
-}
-
-#ifdef EIGEN_USE_COMPLEX
-/** Stores in the real and imaginary parts of x
- * random values between -1.0 and 1.0 */
-template<typename T> void pickRandom( std::complex<T> & x )
-{
-#ifdef EIGEN_WITH_GCC_4_OR_LATER
- pickRandom( x.real() );
- pickRandom( x.imag() );
-#else // workaround by David Faure for MacOS 10.3 and GCC 3.3, commit 630812
- T r = x.real();
- T i = x.imag();
- pickRandom( r );
- pickRandom( i );
- x = std::complex<T>(r,i);
-#endif
-}
-#endif // EIGEN_USE_COMPLEX
-
-template<typename T> T someRandom()
-{
- T t;
- pickRandom(t);
- return t;
-}
-
-} // namespace util
-
-} // namespace tvmet
-
-#endif // TVMET_UTIL_RANDOM_H
diff --git a/tvmet-1.7.1/include/tvmet/xpr/MMProduct.h b/tvmet-1.7.1/include/tvmet/xpr/MMProduct.h
index 7fe4f746a..0d165ea8c 100644
--- a/tvmet-1.7.1/include/tvmet/xpr/MMProduct.h
+++ b/tvmet-1.7.1/include/tvmet/xpr/MMProduct.h
@@ -63,8 +63,8 @@ public:
ops_rhs = E2::ops,
M = Rows1 * Cols1 * Cols2,
N = Rows1 * (Cols1 - 1) * Cols2,
- ops_plus = M * NumericTraits<value_type>::ops_plus,
- ops_muls = N * NumericTraits<value_type>::ops_muls,
+ ops_plus = M * Traits<value_type>::ops_plus,
+ ops_muls = N * Traits<value_type>::ops_muls,
ops = ops_plus + ops_muls,
use_meta = Rows1*Cols2 < TVMET_COMPLEXITY_MM_TRIGGER ? true : false
};
diff --git a/tvmet-1.7.1/include/tvmet/xpr/MMProductTransposed.h b/tvmet-1.7.1/include/tvmet/xpr/MMProductTransposed.h
index d8fb735b1..d869e3af8 100644
--- a/tvmet-1.7.1/include/tvmet/xpr/MMProductTransposed.h
+++ b/tvmet-1.7.1/include/tvmet/xpr/MMProductTransposed.h
@@ -64,8 +64,8 @@ public:
ops_rhs = E2::ops,
M = Rows1 * Cols1 * Cols2,
N = Rows1 * (Cols1-1) * Cols2,
- ops_plus = M * NumericTraits<value_type>::ops_plus,
- ops_muls = N * NumericTraits<value_type>::ops_muls,
+ ops_plus = M * Traits<value_type>::ops_plus,
+ ops_muls = N * Traits<value_type>::ops_muls,
ops = ops_plus + ops_muls,
use_meta = Cols2*Rows1 < TVMET_COMPLEXITY_MM_TRIGGER ? true : false
};
diff --git a/tvmet-1.7.1/include/tvmet/xpr/MMtProduct.h b/tvmet-1.7.1/include/tvmet/xpr/MMtProduct.h
index 1cc7bd9cf..71c6dda63 100644
--- a/tvmet-1.7.1/include/tvmet/xpr/MMtProduct.h
+++ b/tvmet-1.7.1/include/tvmet/xpr/MMtProduct.h
@@ -65,8 +65,8 @@ public:
Rows2 = Cols1,
M = Rows1 * Cols1 * Rows1,
N = Rows1 * (Cols1 - 1) * Rows2,
- ops_plus = M * NumericTraits<value_type>::ops_plus,
- ops_muls = N * NumericTraits<value_type>::ops_muls,
+ ops_plus = M * Traits<value_type>::ops_plus,
+ ops_muls = N * Traits<value_type>::ops_muls,
ops = ops_plus + ops_muls,
use_meta = Rows1*Rows2 < TVMET_COMPLEXITY_MM_TRIGGER ? true : false
};
diff --git a/tvmet-1.7.1/include/tvmet/xpr/MVProduct.h b/tvmet-1.7.1/include/tvmet/xpr/MVProduct.h
index 751431656..0b9202f15 100644
--- a/tvmet-1.7.1/include/tvmet/xpr/MVProduct.h
+++ b/tvmet-1.7.1/include/tvmet/xpr/MVProduct.h
@@ -61,8 +61,8 @@ public:
ops_rhs = E2::ops,
M = Rows * Cols,
N = Rows * (Cols - 1),
- ops_plus = M * NumericTraits<value_type>::ops_plus,
- ops_muls = N * NumericTraits<value_type>::ops_muls,
+ ops_plus = M * Traits<value_type>::ops_plus,
+ ops_muls = N * Traits<value_type>::ops_muls,
ops = ops_plus + ops_muls,
use_meta = Rows*Cols < TVMET_COMPLEXITY_MV_TRIGGER ? true : false
};
diff --git a/tvmet-1.7.1/include/tvmet/xpr/MatrixFunctions.h b/tvmet-1.7.1/include/tvmet/xpr/MatrixFunctions.h
index 288efb798..54f02c08d 100644
--- a/tvmet-1.7.1/include/tvmet/xpr/MatrixFunctions.h
+++ b/tvmet-1.7.1/include/tvmet/xpr/MatrixFunctions.h
@@ -255,7 +255,7 @@ trans(const XprMatrix<E, Rows, Cols>& rhs) _tvmet_always_inline;
#if 0 // XXX needs declaration of meta::Matrix<Sz, Sz, 0, 0>::trace
template<class E, int Sz>
-typename NumericTraits<typename E::value_type>::sum_type
+typename Traits<typename E::value_type>::sum_type
trace(const XprMatrix<E, Sz, Sz>& m)_tvmet_always_inline;
#endif
@@ -649,7 +649,7 @@ trans(const XprMatrix<E, Rows, Cols>& rhs) {
*/
template<class E, int Sz>
inline
-typename NumericTraits<typename E::value_type>::sum_type
+typename Traits<typename E::value_type>::sum_type
trace(const XprMatrix<E, Sz, Sz>& m) {
return meta::Matrix<Sz, Sz, 0, 0>::trace(m);
}
diff --git a/tvmet-1.7.1/include/tvmet/xpr/MtMProduct.h b/tvmet-1.7.1/include/tvmet/xpr/MtMProduct.h
index f985ca7f7..6d657d086 100644
--- a/tvmet-1.7.1/include/tvmet/xpr/MtMProduct.h
+++ b/tvmet-1.7.1/include/tvmet/xpr/MtMProduct.h
@@ -65,8 +65,8 @@ public:
ops_rhs = E2::ops,
M = Rows1 * Cols1 * Cols2,
N = (Rows1-1) * Cols1 * Cols2,
- ops_plus = M * NumericTraits<value_type>::ops_plus,
- ops_muls = N * NumericTraits<value_type>::ops_muls,
+ ops_plus = M * Traits<value_type>::ops_plus,
+ ops_muls = N * Traits<value_type>::ops_muls,
ops = ops_plus + ops_muls,
use_meta = Cols1*Cols2 < TVMET_COMPLEXITY_MM_TRIGGER ? true : false
};
diff --git a/tvmet-1.7.1/include/tvmet/xpr/MtVProduct.h b/tvmet-1.7.1/include/tvmet/xpr/MtVProduct.h
index 3967dbe42..a50bacc97 100644
--- a/tvmet-1.7.1/include/tvmet/xpr/MtVProduct.h
+++ b/tvmet-1.7.1/include/tvmet/xpr/MtVProduct.h
@@ -61,8 +61,8 @@ public:
ops_rhs = E2::ops,
M = Cols * Rows,
N = Cols * (Rows - 1),
- ops_plus = M * NumericTraits<value_type>::ops_plus,
- ops_muls = N * NumericTraits<value_type>::ops_muls,
+ ops_plus = M * Traits<value_type>::ops_plus,
+ ops_muls = N * Traits<value_type>::ops_muls,
ops = ops_plus + ops_muls,
use_meta = Rows*Cols < TVMET_COMPLEXITY_MV_TRIGGER ? true : false
};
diff --git a/tvmet-1.7.1/include/tvmet/xpr/VectorFunctions.h b/tvmet-1.7.1/include/tvmet/xpr/VectorFunctions.h
index 846aaf842..172ed7ab2 100644
--- a/tvmet-1.7.1/include/tvmet/xpr/VectorFunctions.h
+++ b/tvmet-1.7.1/include/tvmet/xpr/VectorFunctions.h
@@ -163,12 +163,12 @@ TVMET_DECLARE_MACRO(div)
template<class E, int Sz>
-typename NumericTraits<typename E::value_type>::sum_type
+typename Traits<typename E::value_type>::sum_type
sum(const XprVector<E, Sz>& v) _tvmet_always_inline;
template<class E, int Sz>
-typename NumericTraits<typename E::value_type>::sum_type
+typename Traits<typename E::value_type>::sum_type
product(const XprVector<E, Sz>& v) _tvmet_always_inline;
@@ -220,12 +220,12 @@ cross(const XprVector<E, 3>& lhs,
template<class E, int Sz>
-typename NumericTraits<typename E::value_type>::sum_type
+typename Traits<typename E::value_type>::sum_type
norm1(const XprVector<E, Sz>& v) _tvmet_always_inline;
template<class E, int Sz>
-typename NumericTraits<typename E::value_type>::sum_type
+typename Traits<typename E::value_type>::sum_type
norm2(const XprVector<E, Sz>& v) _tvmet_always_inline;
@@ -418,7 +418,7 @@ TVMET_IMPLEMENT_MACRO(div)
*/
template<class E, int Sz>
inline
-typename NumericTraits<typename E::value_type>::sum_type
+typename Traits<typename E::value_type>::sum_type
sum(const XprVector<E, Sz>& v) {
return meta::Vector<Sz>::sum(v);
}
@@ -436,7 +436,7 @@ sum(const XprVector<E, Sz>& v) {
*/
template<class E, int Sz>
inline
-typename NumericTraits<typename E::value_type>::sum_type
+typename Traits<typename E::value_type>::sum_type
product(const XprVector<E, Sz>& v) {
return meta::Vector<Sz>::product(v);
}
@@ -585,7 +585,7 @@ cross(const Vector<T1, 3>& lhs, const XprVector<E2, 3>& rhs) {
*/
template<class E, int Sz>
inline
-typename NumericTraits<typename E::value_type>::sum_type
+typename Traits<typename E::value_type>::sum_type
norm1(const XprVector<E, Sz>& v) {
return sum(abs(v));
}
@@ -606,7 +606,7 @@ norm1(const XprVector<E, Sz>& v) {
*/
template<class E, int Sz>
inline
-typename NumericTraits<typename E::value_type>::sum_type
+typename Traits<typename E::value_type>::sum_type
norm2(const XprVector<E, Sz>& v) {
typedef typename E::value_type value_type;
return static_cast<value_type>( std::sqrt(static_cast<value_type>(dot(v, v))) );
diff --git a/tvmet-1.7.1/testsuite/CMakeLists.txt b/tvmet-1.7.1/testsuite/CMakeLists.txt
index 2f515104b..9319e886d 100644
--- a/tvmet-1.7.1/testsuite/CMakeLists.txt
+++ b/tvmet-1.7.1/testsuite/CMakeLists.txt
@@ -11,9 +11,9 @@ INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} )
SET(testsuite_SOURCES
main.cpp
selftest.cpp
- testnumerictraits.cpp
-# TestNumericTraits.h TestNumericTraits.cc
-# TestNumericTraitsComplex.h TestNumericTraitsComplex.cc
+ testtraits.cpp
+# TestTraits.h TestTraits.cc
+# TestTraitsComplex.h TestTraitsComplex.cc
# TestConstruction.h TestConstruction.cc
# TestComplexMatrix.h TestComplexMatrix.cc
# TestComplexVector.h TestComplexVector.cc
diff --git a/tvmet-1.7.1/testsuite/TestNumericTraits.cc b/tvmet-1.7.1/testsuite/TestNumericTraits.cc
index dd0fdfda2..902301764 100644
--- a/tvmet-1.7.1/testsuite/TestNumericTraits.cc
+++ b/tvmet-1.7.1/testsuite/TestNumericTraits.cc
@@ -18,13 +18,13 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: TestNumericTraits.cc,v 1.1 2004/09/15 07:51:43 opetzold Exp $
+ * $Id: TestTraits.cc,v 1.1 2004/09/15 07:51:43 opetzold Exp $
*/
#include <iostream>
#include <complex>
-#include <TestNumericTraits.h>
+#include <TestTraits.h>
#include <cppunit/extensions/HelperMacros.h>
@@ -32,17 +32,17 @@
* instance
****************************************************************************/
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<char> );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<unsigned char> );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<short int> );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<unsigned short int> );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<int> );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<unsigned int> );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<long> );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<unsigned long> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<char> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<unsigned char> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<short int> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<unsigned short int> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<int> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<unsigned int> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<long> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<unsigned long> );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<float> );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<double> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<float> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<double> );
#if defined(TVMET_HAVE_LONG_DOUBLE)
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraits<long double> );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraits<long double> );
#endif
diff --git a/tvmet-1.7.1/testsuite/TestNumericTraits.h b/tvmet-1.7.1/testsuite/TestNumericTraits.h
index c04d7d116..31739facd 100644
--- a/tvmet-1.7.1/testsuite/TestNumericTraits.h
+++ b/tvmet-1.7.1/testsuite/TestNumericTraits.h
@@ -18,7 +18,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: TestNumericTraits.h,v 1.2 2004/11/04 18:12:40 opetzold Exp $
+ * $Id: TestTraits.h,v 1.2 2004/11/04 18:12:40 opetzold Exp $
*/
#ifndef TVMET_TEST_NUMERIC_TRAITS_H
@@ -34,9 +34,9 @@
#include <cassert>
template <class T>
-class TestNumericTraits : public CppUnit::TestFixture
+class TestTraits : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE( TestNumericTraits );
+ CPPUNIT_TEST_SUITE( TestTraits );
CPPUNIT_TEST( Real );
CPPUNIT_TEST( Imag );
CPPUNIT_TEST( Conj );
@@ -53,7 +53,7 @@ private:
typedef tvmet::Matrix<T, 3, 3> matrix_type;
public:
- TestNumericTraits()
+ TestTraits()
: m_real(4), m_imag(9),
m_conj(16),
m_abs_Q1(7), m_abs_Q2(-m_abs_Q1)
@@ -95,10 +95,10 @@ private:
****************************************************************************/
template <class T>
-void TestNumericTraits<T>::setUp () { }
+void TestTraits<T>::setUp () { }
template <class T>
-void TestNumericTraits<T>::tearDown() { }
+void TestTraits<T>::tearDown() { }
/*****************************************************************************
* Implementation Part II
@@ -106,11 +106,11 @@ void TestNumericTraits<T>::tearDown() { }
template <class T>
void
-TestNumericTraits<T>::Real()
+TestTraits<T>::Real()
{
- typedef typename tvmet::NumericTraits<T>::base_type real_type;
+ typedef typename tvmet::Traits<T>::base_type real_type;
- real_type r = tvmet::NumericTraits<T>::real(m_real);
+ real_type r = tvmet::Traits<T>::real(m_real);
CPPUNIT_ASSERT( r == m_real );
}
@@ -118,29 +118,29 @@ TestNumericTraits<T>::Real()
template <class T>
void
-TestNumericTraits<T>::Imag()
+TestTraits<T>::Imag()
{
- typedef typename tvmet::NumericTraits<T>::base_type imag_type;
+ typedef typename tvmet::Traits<T>::base_type imag_type;
- imag_type r = tvmet::NumericTraits<T>::imag(m_imag);
+ imag_type r = tvmet::Traits<T>::imag(m_imag);
CPPUNIT_ASSERT( r == 0 );
}
// conj only for signed types !!
-template <> void TestNumericTraits<unsigned char>::Conj() { }
-template <> void TestNumericTraits<unsigned short int>::Conj() { }
-template <> void TestNumericTraits<unsigned int>::Conj() { }
-template <> void TestNumericTraits<unsigned long>::Conj() { }
+template <> void TestTraits<unsigned char>::Conj() { }
+template <> void TestTraits<unsigned short int>::Conj() { }
+template <> void TestTraits<unsigned int>::Conj() { }
+template <> void TestTraits<unsigned long>::Conj() { }
template <class T>
void
-TestNumericTraits<T>::Conj()
+TestTraits<T>::Conj()
{
- typedef typename tvmet::NumericTraits<T>::base_type conj_type;
+ typedef typename tvmet::Traits<T>::base_type conj_type;
- conj_type r = tvmet::NumericTraits<T>::conj(m_conj);
+ conj_type r = tvmet::Traits<T>::conj(m_conj);
CPPUNIT_ASSERT( r == m_conj );
}
@@ -148,16 +148,16 @@ TestNumericTraits<T>::Conj()
template <class T>
void
-TestNumericTraits<T>::Abs()
+TestTraits<T>::Abs()
{
- typedef typename tvmet::NumericTraits<T>::base_type value_type;
+ typedef typename tvmet::Traits<T>::base_type value_type;
enum {
is_signed = std::numeric_limits<value_type>::is_signed
};
- value_type r1 = tvmet::NumericTraits<T>::abs(m_abs_Q1);
- value_type r2 = tvmet::NumericTraits<T>::abs(m_abs_Q2);
+ value_type r1 = tvmet::Traits<T>::abs(m_abs_Q1);
+ value_type r2 = tvmet::Traits<T>::abs(m_abs_Q2);
CPPUNIT_ASSERT( r1 == m_abs_Q1 );
@@ -168,7 +168,7 @@ TestNumericTraits<T>::Abs()
template <class T>
void
-TestNumericTraits<T>::AbsHelper(tvmet::dispatch<true>, const T& r)
+TestTraits<T>::AbsHelper(tvmet::dispatch<true>, const T& r)
{
// signed type
CPPUNIT_ASSERT( r == (m_abs_Q1) );
@@ -177,7 +177,7 @@ TestNumericTraits<T>::AbsHelper(tvmet::dispatch<true>, const T& r)
template <class T>
void
-TestNumericTraits<T>::AbsHelper(tvmet::dispatch<false>, const T& r)
+TestTraits<T>::AbsHelper(tvmet::dispatch<false>, const T& r)
{
// unsigned type
CPPUNIT_ASSERT( r == T(-m_abs_Q1) );
@@ -186,12 +186,12 @@ TestNumericTraits<T>::AbsHelper(tvmet::dispatch<false>, const T& r)
template <class T>
void
-TestNumericTraits<T>::Sqrt()
+TestTraits<T>::Sqrt()
{
- typedef typename tvmet::NumericTraits<T>::base_type value_type;
+ typedef typename tvmet::Traits<T>::base_type value_type;
- value_type r1 = tvmet::NumericTraits<T>::sqrt(m_real);
- value_type r2 = tvmet::NumericTraits<T>::sqrt(m_imag);
+ value_type r1 = tvmet::Traits<T>::sqrt(m_real);
+ value_type r2 = tvmet::Traits<T>::sqrt(m_imag);
CPPUNIT_ASSERT( r1 == 2 );
CPPUNIT_ASSERT( r2 == 3 );
@@ -200,56 +200,56 @@ TestNumericTraits<T>::Sqrt()
template <class T>
void
-TestNumericTraits<T>::Norm_1()
+TestTraits<T>::Norm_1()
{
- typedef typename tvmet::NumericTraits<T>::base_type value_type;
+ typedef typename tvmet::Traits<T>::base_type value_type;
- value_type r = tvmet::NumericTraits<T>::norm_1(m_real);
+ value_type r = tvmet::Traits<T>::norm_1(m_real);
- CPPUNIT_ASSERT( r == tvmet::NumericTraits<T>::abs(m_real) );
+ CPPUNIT_ASSERT( r == tvmet::Traits<T>::abs(m_real) );
}
template <class T>
void
-TestNumericTraits<T>::Norm_2()
+TestTraits<T>::Norm_2()
{
- typedef typename tvmet::NumericTraits<T>::base_type value_type;
+ typedef typename tvmet::Traits<T>::base_type value_type;
- value_type r = tvmet::NumericTraits<T>::norm_2(m_real);
+ value_type r = tvmet::Traits<T>::norm_2(m_real);
- CPPUNIT_ASSERT( r == tvmet::NumericTraits<T>::abs(m_real) );
+ CPPUNIT_ASSERT( r == tvmet::Traits<T>::abs(m_real) );
}
template <class T>
void
-TestNumericTraits<T>::Norm_Inf()
+TestTraits<T>::Norm_Inf()
{
- typedef typename tvmet::NumericTraits<T>::base_type value_type;
+ typedef typename tvmet::Traits<T>::base_type value_type;
- value_type r = tvmet::NumericTraits<T>::norm_inf(m_real);
+ value_type r = tvmet::Traits<T>::norm_inf(m_real);
- CPPUNIT_ASSERT( r == tvmet::NumericTraits<T>::abs(m_real) );
+ CPPUNIT_ASSERT( r == tvmet::Traits<T>::abs(m_real) );
}
template <class T>
void
-TestNumericTraits<T>::Equals()
+TestTraits<T>::Equals()
{
- typedef typename tvmet::NumericTraits<T>::base_type value_type;
+ typedef typename tvmet::Traits<T>::base_type value_type;
value_type lhs, rhs;
lhs = rhs = 47;
- CPPUNIT_ASSERT( true == tvmet::NumericTraits<T>::equals(lhs,rhs) );
+ CPPUNIT_ASSERT( true == tvmet::Traits<T>::equals(lhs,rhs) );
// a not very intelligent test
rhs += 1;
- CPPUNIT_ASSERT( false == tvmet::NumericTraits<T>::equals(lhs,rhs) );
+ CPPUNIT_ASSERT( false == tvmet::Traits<T>::equals(lhs,rhs) );
}
diff --git a/tvmet-1.7.1/testsuite/TestNumericTraitsComplex.cc b/tvmet-1.7.1/testsuite/TestNumericTraitsComplex.cc
index 0f2546329..f40cb59b2 100644
--- a/tvmet-1.7.1/testsuite/TestNumericTraitsComplex.cc
+++ b/tvmet-1.7.1/testsuite/TestNumericTraitsComplex.cc
@@ -18,13 +18,13 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: TestNumericTraitsComplex.cc,v 1.1 2004/09/15 07:51:44 opetzold Exp $
+ * $Id: TestTraitsComplex.cc,v 1.1 2004/09/15 07:51:44 opetzold Exp $
*/
#include <iostream>
#include <complex>
-#include <TestNumericTraitsComplex.h>
+#include <TestTraitsComplex.h>
#include <cppunit/extensions/HelperMacros.h>
@@ -33,13 +33,13 @@
****************************************************************************/
#if defined(EIGEN_USE_COMPLEX)
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraitsComplex< std::complex<int> > );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraitsComplex< std::complex<unsigned int> > );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraitsComplex< std::complex<long> > );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraitsComplex< std::complex<unsigned long> > );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraitsComplex< std::complex<float> > );
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraitsComplex< std::complex<double> > );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraitsComplex< std::complex<int> > );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraitsComplex< std::complex<unsigned int> > );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraitsComplex< std::complex<long> > );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraitsComplex< std::complex<unsigned long> > );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraitsComplex< std::complex<float> > );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraitsComplex< std::complex<double> > );
# if defined(TVMET_HAVE_LONG_DOUBLE)
-CPPUNIT_TEST_SUITE_REGISTRATION( TestNumericTraitsComplex< std::complex<long double> > );
+CPPUNIT_TEST_SUITE_REGISTRATION( TestTraitsComplex< std::complex<long double> > );
# endif
#endif
diff --git a/tvmet-1.7.1/testsuite/TestNumericTraitsComplex.h b/tvmet-1.7.1/testsuite/TestNumericTraitsComplex.h
index 8591dcf84..dee00b783 100644
--- a/tvmet-1.7.1/testsuite/TestNumericTraitsComplex.h
+++ b/tvmet-1.7.1/testsuite/TestNumericTraitsComplex.h
@@ -18,7 +18,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: TestNumericTraitsComplex.h,v 1.2 2004/11/04 18:12:40 opetzold Exp $
+ * $Id: TestTraitsComplex.h,v 1.2 2004/11/04 18:12:40 opetzold Exp $
*/
#ifndef TVMET_TEST_NUMERIC_TRAITS_H
@@ -34,9 +34,9 @@
#include <cassert>
template <class T>
-class TestNumericTraitsComplex : public CppUnit::TestFixture
+class TestTraitsComplex : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE( TestNumericTraitsComplex );
+ CPPUNIT_TEST_SUITE( TestTraitsComplex );
CPPUNIT_TEST( Real );
CPPUNIT_TEST( Imag );
CPPUNIT_TEST( Conj );
@@ -53,7 +53,7 @@ private:
typedef tvmet::Matrix<T, 3, 3> matrix_type;
public:
- TestNumericTraitsComplex()
+ TestTraitsComplex()
: m_p_real( 3), m_p_imag( 4),
m_n_real(-3), m_n_imag(-4),
m_z1(m_p_real, m_p_imag),
@@ -83,19 +83,19 @@ protected:
private:
// Helper
void AbsHelper(tvmet::dispatch<true>,
- typename tvmet::NumericTraits<T>::base_type);
+ typename tvmet::Traits<T>::base_type);
void AbsHelper(tvmet::dispatch<false>,
- typename tvmet::NumericTraits<T>::base_type);
+ typename tvmet::Traits<T>::base_type);
void SqrtHelper(tvmet::dispatch<true>);
void SqrtHelper(tvmet::dispatch<false>);
void NormHelper(tvmet::dispatch<true>,
- typename tvmet::NumericTraits<T>::base_type);
+ typename tvmet::Traits<T>::base_type);
void NormHelper(tvmet::dispatch<false>,
- typename tvmet::NumericTraits<T>::base_type);
+ typename tvmet::Traits<T>::base_type);
private:
- typedef typename tvmet::NumericTraits<T>::base_type base_type;
+ typedef typename tvmet::Traits<T>::base_type base_type;
typedef T value_type;
const base_type m_p_real;
@@ -115,10 +115,10 @@ private:
****************************************************************************/
template <class T>
-void TestNumericTraitsComplex<T>::setUp () { }
+void TestTraitsComplex<T>::setUp () { }
template <class T>
-void TestNumericTraitsComplex<T>::tearDown() { }
+void TestTraitsComplex<T>::tearDown() { }
/*****************************************************************************
* Implementation Part II
@@ -126,14 +126,14 @@ void TestNumericTraitsComplex<T>::tearDown() { }
template <class T>
void
-TestNumericTraitsComplex<T>::Real()
+TestTraitsComplex<T>::Real()
{
- typedef typename tvmet::NumericTraits<T>::base_type base_type;
+ typedef typename tvmet::Traits<T>::base_type base_type;
- base_type r1 = tvmet::NumericTraits<T>::real(m_z1);
- base_type r2 = tvmet::NumericTraits<T>::real(m_z2);
- base_type r3 = tvmet::NumericTraits<T>::real(m_z3);
- base_type r4 = tvmet::NumericTraits<T>::real(m_z4);
+ base_type r1 = tvmet::Traits<T>::real(m_z1);
+ base_type r2 = tvmet::Traits<T>::real(m_z2);
+ base_type r3 = tvmet::Traits<T>::real(m_z3);
+ base_type r4 = tvmet::Traits<T>::real(m_z4);
CPPUNIT_ASSERT( r1 == m_p_real );
CPPUNIT_ASSERT( r2 == m_n_real );
@@ -144,14 +144,14 @@ TestNumericTraitsComplex<T>::Real()
template <class T>
void
-TestNumericTraitsComplex<T>::Imag()
+TestTraitsComplex<T>::Imag()
{
- typedef typename tvmet::NumericTraits<T>::base_type base_type;
+ typedef typename tvmet::Traits<T>::base_type base_type;
- base_type i1 = tvmet::NumericTraits<T>::imag(m_z1);
- base_type i2 = tvmet::NumericTraits<T>::imag(m_z2);
- base_type i3 = tvmet::NumericTraits<T>::imag(m_z3);
- base_type i4 = tvmet::NumericTraits<T>::imag(m_z4);
+ base_type i1 = tvmet::Traits<T>::imag(m_z1);
+ base_type i2 = tvmet::Traits<T>::imag(m_z2);
+ base_type i3 = tvmet::Traits<T>::imag(m_z3);
+ base_type i4 = tvmet::Traits<T>::imag(m_z4);
CPPUNIT_ASSERT( i1 == m_p_imag );
CPPUNIT_ASSERT( i2 == m_p_imag );
@@ -161,69 +161,69 @@ TestNumericTraitsComplex<T>::Imag()
// conj only for signed types !!
-template <> void TestNumericTraitsComplex<std::complex<unsigned char> >::Conj() { }
-template <> void TestNumericTraitsComplex<std::complex<unsigned short int> >::Conj() { }
-template <> void TestNumericTraitsComplex<std::complex<unsigned int> >::Conj() { }
-template <> void TestNumericTraitsComplex<std::complex<unsigned long> >::Conj() { }
+template <> void TestTraitsComplex<std::complex<unsigned char> >::Conj() { }
+template <> void TestTraitsComplex<std::complex<unsigned short int> >::Conj() { }
+template <> void TestTraitsComplex<std::complex<unsigned int> >::Conj() { }
+template <> void TestTraitsComplex<std::complex<unsigned long> >::Conj() { }
template <class T>
void
-TestNumericTraitsComplex<T>::Conj()
+TestTraitsComplex<T>::Conj()
{
- typedef typename tvmet::NumericTraits<T>::value_type value_type;
- typedef typename tvmet::NumericTraits<T>::base_type base_type;
+ typedef typename tvmet::Traits<T>::value_type value_type;
+ typedef typename tvmet::Traits<T>::base_type base_type;
enum {
is_signed = std::numeric_limits<base_type>::is_signed
};
// conjugate
- value_type conj_z1 = tvmet::NumericTraits<T>::conj(m_z1);
- value_type conj_z2 = tvmet::NumericTraits<T>::conj(m_z2);
- value_type conj_z3 = tvmet::NumericTraits<T>::conj(m_z3);
- value_type conj_z4 = tvmet::NumericTraits<T>::conj(m_z4);
+ value_type conj_z1 = tvmet::Traits<T>::conj(m_z1);
+ value_type conj_z2 = tvmet::Traits<T>::conj(m_z2);
+ value_type conj_z3 = tvmet::Traits<T>::conj(m_z3);
+ value_type conj_z4 = tvmet::Traits<T>::conj(m_z4);
// real part
- base_type r1 = tvmet::NumericTraits<T>::real(conj_z1);
- base_type r2 = tvmet::NumericTraits<T>::real(conj_z2);
- base_type r3 = tvmet::NumericTraits<T>::real(conj_z3);
- base_type r4 = tvmet::NumericTraits<T>::real(conj_z4);
+ base_type r1 = tvmet::Traits<T>::real(conj_z1);
+ base_type r2 = tvmet::Traits<T>::real(conj_z2);
+ base_type r3 = tvmet::Traits<T>::real(conj_z3);
+ base_type r4 = tvmet::Traits<T>::real(conj_z4);
// imag part
- base_type i1 = tvmet::NumericTraits<T>::imag(conj_z1);
- base_type i2 = tvmet::NumericTraits<T>::imag(conj_z2);
- base_type i3 = tvmet::NumericTraits<T>::imag(conj_z3);
- base_type i4 = tvmet::NumericTraits<T>::imag(conj_z4);
+ base_type i1 = tvmet::Traits<T>::imag(conj_z1);
+ base_type i2 = tvmet::Traits<T>::imag(conj_z2);
+ base_type i3 = tvmet::Traits<T>::imag(conj_z3);
+ base_type i4 = tvmet::Traits<T>::imag(conj_z4);
// check on real part; real is tested before
- CPPUNIT_ASSERT( r1 == tvmet::NumericTraits<T>::real(m_z1) );
- CPPUNIT_ASSERT( r2 == tvmet::NumericTraits<T>::real(m_z2) );
- CPPUNIT_ASSERT( r3 == tvmet::NumericTraits<T>::real(m_z3) );
- CPPUNIT_ASSERT( r4 == tvmet::NumericTraits<T>::real(m_z4) );
+ CPPUNIT_ASSERT( r1 == tvmet::Traits<T>::real(m_z1) );
+ CPPUNIT_ASSERT( r2 == tvmet::Traits<T>::real(m_z2) );
+ CPPUNIT_ASSERT( r3 == tvmet::Traits<T>::real(m_z3) );
+ CPPUNIT_ASSERT( r4 == tvmet::Traits<T>::real(m_z4) );
// check on imag part
- CPPUNIT_ASSERT( i1 == -tvmet::NumericTraits<T>::imag(m_z1) );
- CPPUNIT_ASSERT( i2 == -tvmet::NumericTraits<T>::imag(m_z2) );
- CPPUNIT_ASSERT( i3 == -tvmet::NumericTraits<T>::imag(m_z3) );
- CPPUNIT_ASSERT( i4 == -tvmet::NumericTraits<T>::imag(m_z4) );
+ CPPUNIT_ASSERT( i1 == -tvmet::Traits<T>::imag(m_z1) );
+ CPPUNIT_ASSERT( i2 == -tvmet::Traits<T>::imag(m_z2) );
+ CPPUNIT_ASSERT( i3 == -tvmet::Traits<T>::imag(m_z3) );
+ CPPUNIT_ASSERT( i4 == -tvmet::Traits<T>::imag(m_z4) );
}
template <class T>
void
-TestNumericTraitsComplex<T>::Abs()
+TestTraitsComplex<T>::Abs()
{
- typedef typename tvmet::NumericTraits<T>::base_type base_type;
+ typedef typename tvmet::Traits<T>::base_type base_type;
enum {
is_signed = std::numeric_limits<base_type>::is_signed
};
- base_type a1 = tvmet::NumericTraits<T>::abs(m_z1);
- base_type a2 = tvmet::NumericTraits<T>::abs(m_z2);
- base_type a3 = tvmet::NumericTraits<T>::abs(m_z3);
- base_type a4 = tvmet::NumericTraits<T>::abs(m_z4);
+ base_type a1 = tvmet::Traits<T>::abs(m_z1);
+ base_type a2 = tvmet::Traits<T>::abs(m_z2);
+ base_type a3 = tvmet::Traits<T>::abs(m_z3);
+ base_type a4 = tvmet::Traits<T>::abs(m_z4);
// result depends on signed type
AbsHelper(tvmet::dispatch<is_signed>(), a1);
@@ -235,8 +235,8 @@ TestNumericTraitsComplex<T>::Abs()
template <class T>
void
-TestNumericTraitsComplex<T>::AbsHelper(tvmet::dispatch<true>,
- typename tvmet::NumericTraits<T>::base_type r)
+TestTraitsComplex<T>::AbsHelper(tvmet::dispatch<true>,
+ typename tvmet::Traits<T>::base_type r)
{
// signed type
CPPUNIT_ASSERT( r == 5 );
@@ -245,26 +245,26 @@ TestNumericTraitsComplex<T>::AbsHelper(tvmet::dispatch<true>,
template <class T>
void
-TestNumericTraitsComplex<T>::AbsHelper(tvmet::dispatch<false>,
- typename tvmet::NumericTraits<T>::base_type r)
+TestTraitsComplex<T>::AbsHelper(tvmet::dispatch<false>,
+ typename tvmet::Traits<T>::base_type r)
{
- typedef typename tvmet::NumericTraits<T>::base_type base_type;
+ typedef typename tvmet::Traits<T>::base_type base_type;
base_type x = m_z1.real(); // sign doesn't matter on abs()
base_type y = m_z1.imag(); // sign doesn't matter on abs()
// unsigned type
CPPUNIT_ASSERT( r == static_cast<base_type>(
- tvmet::NumericTraits<base_type>::sqrt(x * x + y * y))
+ tvmet::Traits<base_type>::sqrt(x * x + y * y))
);
}
template <class T>
void
-TestNumericTraitsComplex<T>::Sqrt()
+TestTraitsComplex<T>::Sqrt()
{
- typedef typename tvmet::NumericTraits<T>::base_type base_type;
+ typedef typename tvmet::Traits<T>::base_type base_type;
enum {
is_signed = std::numeric_limits<base_type>::is_signed
@@ -277,16 +277,16 @@ TestNumericTraitsComplex<T>::Sqrt()
template <class T>
void
-TestNumericTraitsComplex<T>::SqrtHelper(tvmet::dispatch<true>)
+TestTraitsComplex<T>::SqrtHelper(tvmet::dispatch<true>)
{
// signed type
- typedef typename tvmet::NumericTraits<T>::value_type value_type;
+ typedef typename tvmet::Traits<T>::value_type value_type;
// sqrt
- value_type z1 = tvmet::NumericTraits<T>::sqrt(m_z1);
- value_type z2 = tvmet::NumericTraits<T>::sqrt(m_z2);
- value_type z3 = tvmet::NumericTraits<T>::sqrt(m_z3);
- value_type z4 = tvmet::NumericTraits<T>::sqrt(m_z4);
+ value_type z1 = tvmet::Traits<T>::sqrt(m_z1);
+ value_type z2 = tvmet::Traits<T>::sqrt(m_z2);
+ value_type z3 = tvmet::Traits<T>::sqrt(m_z3);
+ value_type z4 = tvmet::Traits<T>::sqrt(m_z4);
CPPUNIT_ASSERT( z1 == value_type(2,1) );
CPPUNIT_ASSERT( z2 == value_type(1,2) );
@@ -298,7 +298,7 @@ TestNumericTraitsComplex<T>::SqrtHelper(tvmet::dispatch<true>)
template <class T>
void
-TestNumericTraitsComplex<T>::SqrtHelper(tvmet::dispatch<false>)
+TestTraitsComplex<T>::SqrtHelper(tvmet::dispatch<false>)
{
// unsigned type
@@ -306,11 +306,11 @@ TestNumericTraitsComplex<T>::SqrtHelper(tvmet::dispatch<false>)
* very dirty - we assume we calculate right
* on "negative" complex types */
- typedef typename tvmet::NumericTraits<T>::value_type value_type;
+ typedef typename tvmet::Traits<T>::value_type value_type;
// sqrt
- value_type z1 = tvmet::NumericTraits<T>::sqrt(m_z1);
- value_type z2 = tvmet::NumericTraits<T>::sqrt(m_z2);
+ value_type z1 = tvmet::Traits<T>::sqrt(m_z1);
+ value_type z2 = tvmet::Traits<T>::sqrt(m_z2);
CPPUNIT_ASSERT( z1 == value_type(2,1) );
CPPUNIT_ASSERT( z2 == value_type(1,2) );
@@ -319,19 +319,19 @@ TestNumericTraitsComplex<T>::SqrtHelper(tvmet::dispatch<false>)
template <class T>
void
-TestNumericTraitsComplex<T>::Norm_1()
+TestTraitsComplex<T>::Norm_1()
{
- typedef typename tvmet::NumericTraits<T>::base_type base_type;
+ typedef typename tvmet::Traits<T>::base_type base_type;
enum {
is_signed = std::numeric_limits<base_type>::is_signed
};
// norm_1
- base_type n1 = tvmet::NumericTraits<T>::norm_1(m_z1);
- base_type n2 = tvmet::NumericTraits<T>::norm_1(m_z2);
- base_type n3 = tvmet::NumericTraits<T>::norm_1(m_z3);
- base_type n4 = tvmet::NumericTraits<T>::norm_1(m_z4);
+ base_type n1 = tvmet::Traits<T>::norm_1(m_z1);
+ base_type n2 = tvmet::Traits<T>::norm_1(m_z2);
+ base_type n3 = tvmet::Traits<T>::norm_1(m_z3);
+ base_type n4 = tvmet::Traits<T>::norm_1(m_z4);
// result depends on signed type
NormHelper(tvmet::dispatch<is_signed>(), n1);
@@ -343,19 +343,19 @@ TestNumericTraitsComplex<T>::Norm_1()
template <class T>
void
-TestNumericTraitsComplex<T>::Norm_2()
+TestTraitsComplex<T>::Norm_2()
{
- typedef typename tvmet::NumericTraits<T>::base_type base_type;
+ typedef typename tvmet::Traits<T>::base_type base_type;
enum {
is_signed = std::numeric_limits<base_type>::is_signed
};
// norm_2
- base_type n1 = tvmet::NumericTraits<T>::norm_2(m_z1);
- base_type n2 = tvmet::NumericTraits<T>::norm_2(m_z2);
- base_type n3 = tvmet::NumericTraits<T>::norm_2(m_z3);
- base_type n4 = tvmet::NumericTraits<T>::norm_2(m_z4);
+ base_type n1 = tvmet::Traits<T>::norm_2(m_z1);
+ base_type n2 = tvmet::Traits<T>::norm_2(m_z2);
+ base_type n3 = tvmet::Traits<T>::norm_2(m_z3);
+ base_type n4 = tvmet::Traits<T>::norm_2(m_z4);
// result depends on signed type
NormHelper(tvmet::dispatch<is_signed>(), n1);
@@ -367,19 +367,19 @@ TestNumericTraitsComplex<T>::Norm_2()
template <class T>
void
-TestNumericTraitsComplex<T>::Norm_Inf()
+TestTraitsComplex<T>::Norm_Inf()
{
- typedef typename tvmet::NumericTraits<T>::base_type base_type;
+ typedef typename tvmet::Traits<T>::base_type base_type;
enum {
is_signed = std::numeric_limits<base_type>::is_signed
};
// norm_inf
- base_type n1 = tvmet::NumericTraits<T>::norm_inf(m_z1);
- base_type n2 = tvmet::NumericTraits<T>::norm_inf(m_z2);
- base_type n3 = tvmet::NumericTraits<T>::norm_inf(m_z3);
- base_type n4 = tvmet::NumericTraits<T>::norm_inf(m_z4);
+ base_type n1 = tvmet::Traits<T>::norm_inf(m_z1);
+ base_type n2 = tvmet::Traits<T>::norm_inf(m_z2);
+ base_type n3 = tvmet::Traits<T>::norm_inf(m_z3);
+ base_type n4 = tvmet::Traits<T>::norm_inf(m_z4);
// result depends on signed type
NormHelper(tvmet::dispatch<is_signed>(), n1);
@@ -390,8 +390,8 @@ TestNumericTraitsComplex<T>::Norm_Inf()
template <class T>
void
-TestNumericTraitsComplex<T>::NormHelper(tvmet::dispatch<true>,
- typename tvmet::NumericTraits<T>::base_type)
+TestTraitsComplex<T>::NormHelper(tvmet::dispatch<true>,
+ typename tvmet::Traits<T>::base_type)
{
// XXX To be implement
}
@@ -399,8 +399,8 @@ TestNumericTraitsComplex<T>::NormHelper(tvmet::dispatch<true>,
template <class T>
void
-TestNumericTraitsComplex<T>::NormHelper(tvmet::dispatch<false>,
- typename tvmet::NumericTraits<T>::base_type)
+TestTraitsComplex<T>::NormHelper(tvmet::dispatch<false>,
+ typename tvmet::Traits<T>::base_type)
{
// XXX To be implement
}
@@ -408,49 +408,49 @@ TestNumericTraitsComplex<T>::NormHelper(tvmet::dispatch<false>,
template <class T>
void
-TestNumericTraitsComplex<T>::Equals()
+TestTraitsComplex<T>::Equals()
{
// XXX this test is to simple
- typedef typename tvmet::NumericTraits<T>::value_type value_type;
+ typedef typename tvmet::Traits<T>::value_type value_type;
value_type lhs, rhs;
{
lhs = rhs = m_z1;
- CPPUNIT_ASSERT( true == tvmet::NumericTraits<T>::equals(lhs,rhs) );
+ CPPUNIT_ASSERT( true == tvmet::Traits<T>::equals(lhs,rhs) );
rhs += m_z1;
- CPPUNIT_ASSERT( false == tvmet::NumericTraits<T>::equals(lhs,rhs) );
+ CPPUNIT_ASSERT( false == tvmet::Traits<T>::equals(lhs,rhs) );
}
{
lhs = rhs = m_z2;
- CPPUNIT_ASSERT( true == tvmet::NumericTraits<T>::equals(lhs,rhs) );
+ CPPUNIT_ASSERT( true == tvmet::Traits<T>::equals(lhs,rhs) );
rhs += m_z2;
- CPPUNIT_ASSERT( false == tvmet::NumericTraits<T>::equals(lhs,rhs) );
+ CPPUNIT_ASSERT( false == tvmet::Traits<T>::equals(lhs,rhs) );
}
{
lhs = rhs = m_z3;
- CPPUNIT_ASSERT( true == tvmet::NumericTraits<T>::equals(lhs,rhs) );
+ CPPUNIT_ASSERT( true == tvmet::Traits<T>::equals(lhs,rhs) );
rhs += m_z3;
- CPPUNIT_ASSERT( false == tvmet::NumericTraits<T>::equals(lhs,rhs) );
+ CPPUNIT_ASSERT( false == tvmet::Traits<T>::equals(lhs,rhs) );
}
{
lhs = rhs = m_z4;
- CPPUNIT_ASSERT( true == tvmet::NumericTraits<T>::equals(lhs,rhs) );
+ CPPUNIT_ASSERT( true == tvmet::Traits<T>::equals(lhs,rhs) );
rhs += m_z4;
- CPPUNIT_ASSERT( false == tvmet::NumericTraits<T>::equals(lhs,rhs) );
+ CPPUNIT_ASSERT( false == tvmet::Traits<T>::equals(lhs,rhs) );
}
}
diff --git a/tvmet-1.7.1/testsuite/TestVectorFunctions.h b/tvmet-1.7.1/testsuite/TestVectorFunctions.h
index 77a3233bb..be82784ff 100644
--- a/tvmet-1.7.1/testsuite/TestVectorFunctions.h
+++ b/tvmet-1.7.1/testsuite/TestVectorFunctions.h
@@ -434,9 +434,9 @@ TestVectorFunctions<T>::fn_norm() {
CPPUNIT_ASSERT( t1 == sum(v1) );
CPPUNIT_ASSERT( t2 == sum(v1) );
- CPPUNIT_ASSERT( std::abs(t3 - std::sqrt(static_cast<typename tvmet::NumericTraits<T>::float_type>(14)))
+ CPPUNIT_ASSERT( std::abs(t3 - std::sqrt(static_cast<typename tvmet::Traits<T>::float_type>(14)))
< std::numeric_limits<T>::epsilon() );
- CPPUNIT_ASSERT( std::abs(t4 - std::sqrt(static_cast<typename tvmet::NumericTraits<T>::float_type>(14)))
+ CPPUNIT_ASSERT( std::abs(t4 - std::sqrt(static_cast<typename tvmet::Traits<T>::float_type>(14)))
< std::numeric_limits<T>::epsilon() );
r = v1/norm2(v1); // norm2 is checked before
diff --git a/tvmet-1.7.1/testsuite/TestXprVectorFunctions.h b/tvmet-1.7.1/testsuite/TestXprVectorFunctions.h
index 005667986..b1f1aa37b 100644
--- a/tvmet-1.7.1/testsuite/TestXprVectorFunctions.h
+++ b/tvmet-1.7.1/testsuite/TestXprVectorFunctions.h
@@ -285,9 +285,9 @@ TestXprVectorFunctions<T>::fn_norm() {
CPPUNIT_ASSERT( t1 == sum(v1) );
CPPUNIT_ASSERT( t2 == sum(v1) );
- CPPUNIT_ASSERT( std::abs(t3 - std::sqrt(static_cast<typename tvmet::NumericTraits<T>::float_type>(14)))
+ CPPUNIT_ASSERT( std::abs(t3 - std::sqrt(static_cast<typename tvmet::Traits<T>::float_type>(14)))
< std::numeric_limits<T>::epsilon() );
- CPPUNIT_ASSERT( std::abs(t4 - std::sqrt(static_cast<typename tvmet::NumericTraits<T>::float_type>(14)))
+ CPPUNIT_ASSERT( std::abs(t4 - std::sqrt(static_cast<typename tvmet::Traits<T>::float_type>(14)))
< std::numeric_limits<T>::epsilon() );
r = v1/norm2(v1); // norm2 is checked before
diff --git a/tvmet-1.7.1/testsuite/main.h b/tvmet-1.7.1/testsuite/main.h
index 77191faf5..33896662a 100644
--- a/tvmet-1.7.1/testsuite/main.h
+++ b/tvmet-1.7.1/testsuite/main.h
@@ -30,12 +30,9 @@
#include <tvmet/Vector.h>
#include <tvmet/Matrix.h>
-#include <tvmet/util/Random.h>
-
#include "compare.h"
using namespace tvmet;
-using namespace util;
using namespace std;
class TvmetTestSuite : public QObject
@@ -47,7 +44,7 @@ class TvmetTestSuite : public QObject
private slots:
void selfTest();
- void testNumericTraits();
+ void testTraits();
};
#endif // EIGEN_TESTSUITE_MAIN_H
diff --git a/tvmet-1.7.1/testsuite/testnumerictraits.cpp b/tvmet-1.7.1/testsuite/testnumerictraits.cpp
deleted file mode 100644
index eede0bcaa..000000000
--- a/tvmet-1.7.1/testsuite/testnumerictraits.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* This file is part of Eigen, a C++ template library for linear algebra
- * Copyright (C) 2007 Benoit Jacob <jacob@math.jussieu.fr>
- *
- * Based on Tvmet source code, http://tvmet.sourceforge.net,
- * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id: SelfTest.cc,v 1.1 2004/04/24 11:55:15 opetzold Exp $
- */
-
-#include "main.h"
-
-template<typename T> struct TestNumericTraits
-{
- void real()
- {
- T x = someRandom<T>();
- typedef typename NumericTraits<T>::real_type real_type;
- real_type r = NumericTraits<T>::real(x);
- TEST_APPROX(r, x);
- }
-
- void imag()
- {
- T x = someRandom<T>();
- typedef typename NumericTraits<T>::real_type real_type;
- real_type r = NumericTraits<T>::imag(x);
- TEST_ZERO(r);
- }
-
- void conj()
- {
- T x = someRandom<T>();
- typedef typename NumericTraits<T>::real_type conj_type;
- conj_type r = NumericTraits<T>::conj(x);
- TEST_APPROX(r, x);
- }
-
- void abs()
- {
- T x = someRandom<T>();
- typedef typename NumericTraits<T>::real_type value_type;
- value_type r1 = NumericTraits<T>::abs(x);
- value_type r2 = NumericTraits<T>::abs(-x);
- TEST_APPROX(r1, r2);
- }
-
- void sqrt()
- {
- T x = someRandom<T>();
- T a = NumericTraits<T>::abs(x);
- T b = NumericTraits<T>::sqrt(a);
- // T could be an integer type, so b*b=a is not necessarily true
- TEST_LESSTHAN(b*b, a);
- TEST_LESSTHAN(a, (b+1)*(b+1));
- }
-
- TestNumericTraits()
- {
- real();
- imag();
- conj();
- abs();
- sqrt();
- }
-};
-
-void TvmetTestSuite::testNumericTraits()
-{
- TestNumericTraits<int>();
- TestNumericTraits<float>();
- TestNumericTraits<double>();
-}
diff --git a/tvmet-1.7.1/testsuite/testtraits.cpp b/tvmet-1.7.1/testsuite/testtraits.cpp
new file mode 100644
index 000000000..dd7fb7bee
--- /dev/null
+++ b/tvmet-1.7.1/testsuite/testtraits.cpp
@@ -0,0 +1,126 @@
+/* This file is part of Eigen, a C++ template library for linear algebra
+ * Copyright (C) 2007 Benoit Jacob <jacob@math.jussieu.fr>
+ *
+ * Based on Tvmet source code, http://tvmet.sourceforge.net,
+ * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id: SelfTest.cc,v 1.1 2004/04/24 11:55:15 opetzold Exp $
+ */
+
+#include "main.h"
+
+template<typename T> struct TestTraits
+{
+ void real()
+ {
+ T x = Traits<T>::random();
+ typedef typename Traits<T>::real_type real_type;
+ real_type r = Traits<T>::real(x);
+ TEST_APPROX(r, x);
+ }
+
+ void imag()
+ {
+ T x = Traits<T>::random();
+ typedef typename Traits<T>::real_type real_type;
+ real_type r = Traits<T>::imag(x);
+ TEST_ZERO(r);
+ }
+
+ void conj()
+ {
+ T x = Traits<T>::random();
+ typedef typename Traits<T>::real_type conj_type;
+ conj_type r = Traits<T>::conj(x);
+ TEST_APPROX(r, x);
+ }
+
+ void abs()
+ {
+ T x = Traits<T>::random();
+ typedef typename Traits<T>::real_type value_type;
+ value_type r1 = Traits<T>::abs(x);
+ value_type r2 = Traits<T>::abs(-x);
+ TEST_APPROX(r1, r2);
+ }
+
+ void sqrt()
+ {
+ T x = Traits<T>::random();
+ T a = Traits<T>::abs(x);
+ T b = Traits<T>::sqrt(a);
+ // T could be an integer type, so b*b=a is not necessarily true
+ TEST_LESSTHAN(b*b, a);
+ TEST_LESSTHAN(a, (b+1)*(b+1));
+ }
+
+ void isApprox()
+ {
+ T x = Traits<T>::random();
+ TEST(Traits<T>::isApprox(x,x));
+ TEST(Traits<T>::isApprox(x,x+Traits<T>::epsilon()/10));
+ TEST(!Traits<T>::isApprox(x,x+1));
+ }
+
+ void isNegligible()
+ {
+ T zero(0), one(1), x = Traits<T>::random();
+ TEST(Traits<T>::isNegligible(zero, zero));
+ TEST(Traits<T>::isNegligible(zero, one));
+ TEST(!Traits<T>::isNegligible(one, one));
+ if(x != zero) {
+ TEST(Traits<T>::isNegligible(zero, x));
+ }
+ TEST(!Traits<T>::isNegligible(one, x));
+ }
+
+ void isZero()
+ {
+ T zero(0), one(1), x = Traits<T>::random(), y = Traits<T>::random();
+ TEST(Traits<T>::isZero(zero));
+ TEST(!Traits<T>::isZero(one));
+ TEST(Traits<T>::isZero((x+y)*(x+y)-x*x-y*y-x*y-y*x));
+ }
+
+ void isLessThan()
+ {
+ T one(1), x = Traits<T>::random();
+ TEST(Traits<T>::isLessThan(x, x+one));
+ TEST(!Traits<T>::isLessThan(x+one, x));
+ TEST(Traits<T>::isLessThan(x, x+Traits<T>::epsilon()/10));
+ }
+
+ TestTraits()
+ {
+ real();
+ imag();
+ conj();
+ abs();
+ sqrt();
+ isApprox();
+ isNegligible();
+ isZero();
+ isLessThan();
+ }
+};
+
+void TvmetTestSuite::testTraits()
+{
+ TestTraits<int>();
+ TestTraits<float>();
+ TestTraits<double>();
+}