[mlpack-svn] r14169 - mlpack/trunk/src/mlpack/core/arma_extend
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Jan 29 11:25:59 EST 2013
Author: rcurtin
Date: 2013-01-29 11:25:58 -0500 (Tue, 29 Jan 2013)
New Revision: 14169
Modified:
mlpack/trunk/src/mlpack/core/arma_extend/hdf5_misc.hpp
mlpack/trunk/src/mlpack/core/arma_extend/promote_type.hpp
mlpack/trunk/src/mlpack/core/arma_extend/restrictors.hpp
mlpack/trunk/src/mlpack/core/arma_extend/traits.hpp
mlpack/trunk/src/mlpack/core/arma_extend/typedef.hpp
Log:
Far less hackery is required for Armadillo 3.6.2.
Modified: mlpack/trunk/src/mlpack/core/arma_extend/hdf5_misc.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/hdf5_misc.hpp 2013-01-27 10:01:28 UTC (rev 14168)
+++ mlpack/trunk/src/mlpack/core/arma_extend/hdf5_misc.hpp 2013-01-29 16:25:58 UTC (rev 14169)
@@ -1,21 +1,23 @@
// To hack in u64/s64 support to Armadillo when it is not compiled with
// ARMA_64BIT_WORD.
-#ifdef ARMA_USE_HDF5
+#if defined(ARMA_USE_HDF5)
+ #if !(defined(ARMA_64BIT_WORD) || defined(ARMA_USE_U64S64))
+ #if defined(ULLONG_MAX)
+ template<>
+ inline
+ hid_t
+ get_hdf5_type< long long >()
+ {
+ return H5Tcopy(H5T_NATIVE_LLONG);
+ }
-template<>
-inline
-hid_t
-get_hdf5_type< long long >()
- {
- return H5Tcopy(H5T_NATIVE_LLONG);
- }
-
-template<>
-inline
-hid_t
-get_hdf5_type< unsigned long long >()
- {
- return H5Tcopy(H5T_NATIVE_ULLONG);
- }
-
+ template<>
+ inline
+ hid_t
+ get_hdf5_type< unsigned long long >()
+ {
+ return H5Tcopy(H5T_NATIVE_ULLONG);
+ }
+ #endif
+ #endif
#endif
Modified: mlpack/trunk/src/mlpack/core/arma_extend/promote_type.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/promote_type.hpp 2013-01-27 10:01:28 UTC (rev 14168)
+++ mlpack/trunk/src/mlpack/core/arma_extend/promote_type.hpp 2013-01-29 16:25:58 UTC (rev 14169)
@@ -7,100 +7,104 @@
(ARMA_VERSION_PATCH >= 91))
// The new syntax changed the name of 'promote_type' to 'is_promotable'. We
-// have to update accordingly...
-#ifndef ARMA_64BIT_WORD
-template<typename T> struct is_promotable<std::complex<T>, s64> : public is_promotable_ok { typedef std::complex<T> result; };
-template<typename T> struct is_promotable<std::complex<T>, u64> : public is_promotable_ok { typedef std::complex<T> result; };
+// have to update accordingly. These aren't necessary on Armadillo > 3.6.1.
+ #if (ARMA_VERSION_MAJOR < 3) || \
+ ((ARMA_VERSION_MAJOR == 3) && (ARMA_VERSION_MINOR < 6)) || \
+ ((ARMA_VERSION_MAJOR == 3) && (ARMA_VERSION_MINOR == 6) && \
+ (ARMA_VERSION_PATCH < 2))
+ #ifndef ARMA_64BIT_WORD
+ template<typename T> struct is_promotable<std::complex<T>, s64> : public is_promotable_ok { typedef std::complex<T> result; };
+ template<typename T> struct is_promotable<std::complex<T>, u64> : public is_promotable_ok { typedef std::complex<T> result; };
-template<> struct is_promotable<double, s64> : public is_promotable_ok { typedef double result; };
-template<> struct is_promotable<double, u64> : public is_promotable_ok { typedef double result; };
+ template<> struct is_promotable<double, s64> : public is_promotable_ok { typedef double result; };
+ template<> struct is_promotable<double, u64> : public is_promotable_ok { typedef double result; };
-template<> struct is_promotable<float, s64> : public is_promotable_ok { typedef float result; };
-template<> struct is_promotable<float, u64> : public is_promotable_ok { typedef float result; };
+ template<> struct is_promotable<float, s64> : public is_promotable_ok { typedef float result; };
+ template<> struct is_promotable<float, u64> : public is_promotable_ok { typedef float result; };
-template<> struct is_promotable<s64, u64> : public is_promotable_ok { typedef s64 result; };
-template<> struct is_promotable<s64, s32> : public is_promotable_ok { typedef s64 result; };
-template<> struct is_promotable<s64, u32> : public is_promotable_ok { typedef s64 result; }; // float ?
-template<> struct is_promotable<s64, s16> : public is_promotable_ok { typedef s64 result; };
-template<> struct is_promotable<s64, u16> : public is_promotable_ok { typedef s64 result; };
-template<> struct is_promotable<s64, s8 > : public is_promotable_ok { typedef s64 result; };
-template<> struct is_promotable<s64, u8 > : public is_promotable_ok { typedef s64 result; };
+ template<> struct is_promotable<s64, u64> : public is_promotable_ok { typedef s64 result; };
+ template<> struct is_promotable<s64, s32> : public is_promotable_ok { typedef s64 result; };
+ template<> struct is_promotable<s64, u32> : public is_promotable_ok { typedef s64 result; }; // float ?
+ template<> struct is_promotable<s64, s16> : public is_promotable_ok { typedef s64 result; };
+ template<> struct is_promotable<s64, u16> : public is_promotable_ok { typedef s64 result; };
+ template<> struct is_promotable<s64, s8 > : public is_promotable_ok { typedef s64 result; };
+ template<> struct is_promotable<s64, u8 > : public is_promotable_ok { typedef s64 result; };
-template<> struct is_promotable<u64, u32> : public is_promotable_ok { typedef u64 result; };
-template<> struct is_promotable<u64, u16> : public is_promotable_ok { typedef u64 result; };
-template<> struct is_promotable<u64, u8 > : public is_promotable_ok { typedef u64 result; };
+ template<> struct is_promotable<u64, u32> : public is_promotable_ok { typedef u64 result; };
+ template<> struct is_promotable<u64, u16> : public is_promotable_ok { typedef u64 result; };
+ template<> struct is_promotable<u64, u8 > : public is_promotable_ok { typedef u64 result; };
-template<typename T> struct is_promotable<s64, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
-template<typename T> struct is_promotable<u64, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
+ template<typename T> struct is_promotable<s64, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
+ template<typename T> struct is_promotable<u64, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
-template<> struct is_promotable<s64, double> : public is_promotable_ok { typedef double result; };
-template<> struct is_promotable<u64, double> : public is_promotable_ok { typedef double result; };
+ template<> struct is_promotable<s64, double> : public is_promotable_ok { typedef double result; };
+ template<> struct is_promotable<u64, double> : public is_promotable_ok { typedef double result; };
-template<> struct is_promotable<s64, float> : public is_promotable_ok { typedef float result; };
-template<> struct is_promotable<u64, float> : public is_promotable_ok { typedef float result; };
+ template<> struct is_promotable<s64, float> : public is_promotable_ok { typedef float result; };
+ template<> struct is_promotable<u64, float> : public is_promotable_ok { typedef float result; };
-template<> struct is_promotable<u64, s64> : public is_promotable_ok { typedef s64 result; }; // float ?
+ template<> struct is_promotable<u64, s64> : public is_promotable_ok { typedef s64 result; }; // float ?
-template<> struct is_promotable<u32, s64> : public is_promotable_ok { typedef s64 result; }; // float ?
-template<> struct is_promotable<s16, s64> : public is_promotable_ok { typedef s64 result; };
-template<> struct is_promotable<u16, s64> : public is_promotable_ok { typedef s64 result; };
-template<> struct is_promotable<s8 , s64> : public is_promotable_ok { typedef s64 result; };
-template<> struct is_promotable<u8 , s64> : public is_promotable_ok { typedef s64 result; };
+ template<> struct is_promotable<u32, s64> : public is_promotable_ok { typedef s64 result; }; // float ?
+ template<> struct is_promotable<s16, s64> : public is_promotable_ok { typedef s64 result; };
+ template<> struct is_promotable<u16, s64> : public is_promotable_ok { typedef s64 result; };
+ template<> struct is_promotable<s8 , s64> : public is_promotable_ok { typedef s64 result; };
+ template<> struct is_promotable<u8 , s64> : public is_promotable_ok { typedef s64 result; };
-template<> struct is_promotable<u32, u64> : public is_promotable_ok { typedef u64 result; };
-template<> struct is_promotable<u16, u64> : public is_promotable_ok { typedef u64 result; };
-template<> struct is_promotable<u8 , u64> : public is_promotable_ok { typedef u64 result; };
-#endif
-
+ template<> struct is_promotable<u32, u64> : public is_promotable_ok { typedef u64 result; };
+ template<> struct is_promotable<u16, u64> : public is_promotable_ok { typedef u64 result; };
+ template<> struct is_promotable<u8 , u64> : public is_promotable_ok { typedef u64 result; };
+ #endif
+ #endif
#else
-// The old syntax used the 'promote_type' struct. We just define all of these
-// for u64 and s64.
-template<typename T> struct promote_type<std::complex<T>, s64> : public promote_type_ok { typedef std::complex<T> result; };
-template<typename T> struct promote_type<std::complex<T>, u64> : public promote_type_ok { typedef std::complex<T> result; };
+ // The old syntax used the 'promote_type' struct. We just define all of these
+ // for u64 and s64.
+ template<typename T> struct promote_type<std::complex<T>, s64> : public promote_type_ok { typedef std::complex<T> result; };
+ template<typename T> struct promote_type<std::complex<T>, u64> : public promote_type_ok { typedef std::complex<T> result; };
-template<> struct promote_type<double, s64 > : public promote_type_ok { typedef double result; };
-template<> struct promote_type<double, u64 > : public promote_type_ok { typedef double result; };
+ template<> struct promote_type<double, s64 > : public promote_type_ok { typedef double result; };
+ template<> struct promote_type<double, u64 > : public promote_type_ok { typedef double result; };
-template<> struct promote_type<float, s64> : public promote_type_ok { typedef float result; };
-template<> struct promote_type<float, u64> : public promote_type_ok { typedef float result; };
+ template<> struct promote_type<float, s64> : public promote_type_ok { typedef float result; };
+ template<> struct promote_type<float, u64> : public promote_type_ok { typedef float result; };
-template<> struct promote_type<s64, u64> : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<s64, s32> : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<s64, u32> : public promote_type_ok { typedef s64 result; }; // float ?
-template<> struct promote_type<s64, s16> : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<s64, u16> : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<s64, s8 > : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<s64, u8 > : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<s64, u64> : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<s64, s32> : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<s64, u32> : public promote_type_ok { typedef s64 result; }; // float ?
+ template<> struct promote_type<s64, s16> : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<s64, u16> : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<s64, s8 > : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<s64, u8 > : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<u64, s32> : public promote_type_ok { typedef s64 result; }; // float ?
-template<> struct promote_type<u64, u32> : public promote_type_ok { typedef u64 result; };
-template<> struct promote_type<u64, s16> : public promote_type_ok { typedef s64 result; }; // float ?
-template<> struct promote_type<u64, u16> : public promote_type_ok { typedef u64 result; };
-template<> struct promote_type<u64, s8 > : public promote_type_ok { typedef s64 result; }; // float ?
-template<> struct promote_type<u64, u8 > : public promote_type_ok { typedef u64 result; };
+ template<> struct promote_type<u64, s32> : public promote_type_ok { typedef s64 result; }; // float ?
+ template<> struct promote_type<u64, u32> : public promote_type_ok { typedef u64 result; };
+ template<> struct promote_type<u64, s16> : public promote_type_ok { typedef s64 result; }; // float ?
+ template<> struct promote_type<u64, u16> : public promote_type_ok { typedef u64 result; };
+ template<> struct promote_type<u64, s8 > : public promote_type_ok { typedef s64 result; }; // float ?
+ template<> struct promote_type<u64, u8 > : public promote_type_ok { typedef u64 result; };
-template<typename T> struct promote_type<s64, std::complex<T> > : public promote_type_ok { typedef std::complex<T> result; };
-template<typename T> struct promote_type<u64, std::complex<T> > : public promote_type_ok { typedef std::complex<T> result; };
+ template<typename T> struct promote_type<s64, std::complex<T> > : public promote_type_ok { typedef std::complex<T> result; };
+ template<typename T> struct promote_type<u64, std::complex<T> > : public promote_type_ok { typedef std::complex<T> result; };
-template<> struct promote_type<s64 , double> : public promote_type_ok { typedef double result; };
-template<> struct promote_type<u64 , double> : public promote_type_ok { typedef double result; };
+ template<> struct promote_type<s64 , double> : public promote_type_ok { typedef double result; };
+ template<> struct promote_type<u64 , double> : public promote_type_ok { typedef double result; };
-template<> struct promote_type<s64, float> : public promote_type_ok { typedef float result; };
-template<> struct promote_type<u64, float> : public promote_type_ok { typedef float result; };
+ template<> struct promote_type<s64, float> : public promote_type_ok { typedef float result; };
+ template<> struct promote_type<u64, float> : public promote_type_ok { typedef float result; };
-template<> struct promote_type<u64, s64> : public promote_type_ok { typedef s64 result; }; // float ?
-template<> struct promote_type<s32, s64> : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<u32, s64> : public promote_type_ok { typedef s64 result; }; // float ?
-template<> struct promote_type<s16, s64> : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<u16, s64> : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<s8 , s64> : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<u8 , s64> : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<u64, s64> : public promote_type_ok { typedef s64 result; }; // float ?
+ template<> struct promote_type<s32, s64> : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<u32, s64> : public promote_type_ok { typedef s64 result; }; // float ?
+ template<> struct promote_type<s16, s64> : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<u16, s64> : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<s8 , s64> : public promote_type_ok { typedef s64 result; };
+ template<> struct promote_type<u8 , s64> : public promote_type_ok { typedef s64 result; };
-template<> struct promote_type<s32, u64> : public promote_type_ok { typedef s64 result; }; // float ?
-template<> struct promote_type<u32, u64> : public promote_type_ok { typedef u64 result; };
-template<> struct promote_type<s16, u64> : public promote_type_ok { typedef s64 result; }; // float ?
-template<> struct promote_type<u16, u64> : public promote_type_ok { typedef u64 result; };
-template<> struct promote_type<s8 , u64> : public promote_type_ok { typedef s64 result; }; // float ?
-template<> struct promote_type<u8 , u64> : public promote_type_ok { typedef u64 result; };
+ template<> struct promote_type<s32, u64> : public promote_type_ok { typedef s64 result; }; // float ?
+ template<> struct promote_type<u32, u64> : public promote_type_ok { typedef u64 result; };
+ template<> struct promote_type<s16, u64> : public promote_type_ok { typedef s64 result; }; // float ?
+ template<> struct promote_type<u16, u64> : public promote_type_ok { typedef u64 result; };
+ template<> struct promote_type<s8 , u64> : public promote_type_ok { typedef s64 result; }; // float ?
+ template<> struct promote_type<u8 , u64> : public promote_type_ok { typedef u64 result; };
#endif
Modified: mlpack/trunk/src/mlpack/core/arma_extend/restrictors.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/restrictors.hpp 2013-01-27 10:01:28 UTC (rev 14168)
+++ mlpack/trunk/src/mlpack/core/arma_extend/restrictors.hpp 2013-01-29 16:25:58 UTC (rev 14169)
@@ -1,17 +1,22 @@
// Modifications to allow u64/s64 in Armadillo when ARMA_64BIT_WORD is not
-// defined.
-#ifndef ARMA_64BIT_WORD
+// defined. Only required on Armadillo < 3.6.2.
+#if (ARMA_VERSION_MAJOR < 3) || \
+ ((ARMA_VERSION_MAJOR == 3) && (ARMA_VERSION_MINOR < 6)) || \
+ ((ARMA_VERSION_MAJOR == 3) && (ARMA_VERSION_MINOR == 6) && \
+ (ARMA_VERSION_PATCH < 2))
+ #ifndef ARMA_64BIT_WORD
-template<> struct arma_scalar_only<u64> { typedef u64 result; };
-template<> struct arma_scalar_only<s64> { typedef s64 result; };
+ template<> struct arma_scalar_only<u64> { typedef u64 result; };
+ template<> struct arma_scalar_only<s64> { typedef s64 result; };
-template<> struct arma_integral_only<u64> { typedef u64 result; };
-template<> struct arma_integral_only<s64> { typedef s64 result; };
+ template<> struct arma_integral_only<u64> { typedef u64 result; };
+ template<> struct arma_integral_only<s64> { typedef s64 result; };
-template<> struct arma_unsigned_integral_only<u64> { typedef u64 result; };
+ template<> struct arma_unsigned_integral_only<u64> { typedef u64 result; };
-template<> struct arma_signed_integral_only<s64> { typedef s64 result; };
+ template<> struct arma_signed_integral_only<s64> { typedef s64 result; };
-template<> struct arma_signed_only<s64> { typedef s64 result; };
+ template<> struct arma_signed_only<s64> { typedef s64 result; };
+ #endif
#endif
Modified: mlpack/trunk/src/mlpack/core/arma_extend/traits.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/traits.hpp 2013-01-27 10:01:28 UTC (rev 14168)
+++ mlpack/trunk/src/mlpack/core/arma_extend/traits.hpp 2013-01-29 16:25:58 UTC (rev 14169)
@@ -1,42 +1,49 @@
-// Extra traits to support u64 and s64 until that patch is applied to the
-// Armadillo sources.
+// Extra traits to support u64 and s64 (or, specifically, unsigned long and
+// long) until that is applied to the Armadillo sources.
-// This isn't necessary if Armadillo was compiled with 64-bit support.
-#ifndef ARMA_64BIT_WORD
- template<typename T1>
- struct is_u64
- { static const bool value = false; };
+// This isn't necessary if Armadillo was compiled with 64-bit support, or if
+// ARMA_USE_U64S64 is enabled, or if Armadillo >= 3.6.2 is used (by default
+// Armadillo 3.6.2 allows long types).
+#if (ARMA_VERSION_MAJOR < 3) || \
+ ((ARMA_VERSION_MAJOR == 3) && (ARMA_VERSION_MINOR < 6)) || \
+ ((ARMA_VERSION_MAJOR == 3) && (ARMA_VERSION_MINOR == 6) && \
+ (ARMA_VERSION_PATCH < 2))
+ #if !(defined(ARMA_64BIT_WORD) || defined(ARMA_USE_U64S64))
+ template<typename T1>
+ struct is_u64
+ { static const bool value = false; };
- template<>
- struct is_u64<u64>
- { static const bool value = true; };
+ template<>
+ struct is_u64<u64>
+ { static const bool value = true; };
- template<typename T1>
- struct is_s64
- { static const bool value = false; };
+ template<typename T1>
+ struct is_s64
+ { static const bool value = false; };
- template<>
- struct is_s64<s64>
- { static const bool value = true; };
+ template<>
+ struct is_s64<s64>
+ { static const bool value = true; };
- template<>
- struct is_supported_elem_type<u64>
- {
- static const bool value = true;
- };
+ template<>
+ struct is_supported_elem_type<u64>
+ {
+ static const bool value = true;
+ };
- template<>
- struct is_supported_elem_type<s64>
- {
- static const bool value = true;
- };
+ template<>
+ struct is_supported_elem_type<s64>
+ {
+ static const bool value = true;
+ };
- template<>
- struct is_signed<u64>
- {
- static const bool value = false;
- };
+ template<>
+ struct is_signed<u64>
+ {
+ static const bool value = false;
+ };
+ #endif
#endif
Modified: mlpack/trunk/src/mlpack/core/arma_extend/typedef.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/typedef.hpp 2013-01-27 10:01:28 UTC (rev 14168)
+++ mlpack/trunk/src/mlpack/core/arma_extend/typedef.hpp 2013-01-29 16:25:58 UTC (rev 14169)
@@ -1,25 +1,30 @@
// Extensions to typedef u64 and s64 until that support is added into
-// Armadillo. We only need to typedef s64 on Armadillo > 1.2.0.
+// Armadillo. We only need to typedef s64 on Armadillo > 1.2.0. This is not
+// necessary for Armadillo > 3.6.1.
+#if (ARMA_VERSION_MAJOR < 3) || \
+ ((ARMA_VERSION_MAJOR == 3) && (ARMA_VERSION_MINOR < 6)) || \
+ ((ARMA_VERSION_MAJOR == 3) && (ARMA_VERSION_MINOR == 6) && \
+ (ARMA_VERSION_PATCH < 2))
+ #ifndef ARMA_64BIT_WORD
+ // We must typedef both u64 and s64.
+ #if ULONG_MAX >= 0xffffffffffffffff
+ typedef unsigned long u64;
+ typedef long s64;
+ #elif ULLONG_MAX >= 0xffffffffffffffff
+ typedef unsigned long long u64;
+ typedef long long s64;
+ #else
+ #error "don't know how to typedef 'u64' on this system"
+ #endif
-#ifndef ARMA_64BIT_WORD
- // We must typedef both u64 and s64.
- #if ULONG_MAX >= 0xffffffffffffffff
- typedef unsigned long u64;
- typedef long s64;
- #elif ULLONG_MAX >= 0xffffffffffffffff
- typedef unsigned long long u64;
- typedef long long s64;
- #else
- #error "don't know how to typedef 'u64' on this system"
- #endif
-
- namespace junk
- {
- struct arma_64_elem_size_test
+ namespace junk
{
- arma_static_check( (sizeof(u64) != 8), ERROR___TYPE_U64_HAS_UNSUPPORTED_SIZE );
- arma_static_check( (sizeof(s64) != 8), ERROR___TYPE_S64_HAS_UNSUPPORTED_SIZE );
- };
- }
+ struct arma_64_elem_size_test
+ {
+ arma_static_check( (sizeof(u64) != 8), ERROR___TYPE_U64_HAS_UNSUPPORTED_SIZE );
+ arma_static_check( (sizeof(s64) != 8), ERROR___TYPE_S64_HAS_UNSUPPORTED_SIZE );
+ };
+ }
+ #endif
#endif
More information about the mlpack-svn
mailing list