[mlpack-svn] r13850 - mlpack/trunk/src/mlpack/core/arma_extend

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Nov 7 17:39:08 EST 2012


Author: rcurtin
Date: 2012-11-07 17:39:08 -0500 (Wed, 07 Nov 2012)
New Revision: 13850

Removed:
   mlpack/trunk/src/mlpack/core/arma_extend/promote_type.hpp
   mlpack/trunk/src/mlpack/core/arma_extend/traits.hpp
   mlpack/trunk/src/mlpack/core/arma_extend/typedef.hpp
Modified:
   mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_bones.hpp
   mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_meat.hpp
   mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_bones.hpp
   mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_meat.hpp
   mlpack/trunk/src/mlpack/core/arma_extend/arma_extend.hpp
Log:
No need to typedef u64 anymore; set size_t == uword by defining ARMA_64BIT_WORD
on systems where size_t is 64 bits; clean up preprocessor #ifs so that Row_ and
Col_extra_bones work correctly.


Modified: mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_bones.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_bones.hpp	2012-11-07 20:48:28 UTC (rev 13849)
+++ mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_bones.hpp	2012-11-07 22:39:08 UTC (rev 13850)
@@ -5,8 +5,6 @@
  * Add an extra explicit constructor for sparse vectors, but only if it doesn't
  * already exist (Armadillo 3.4 specific).
  */
-#ifdef ARMA_HAS_SPMAT
-  #if ARMA_VERSION_MAJOR == 3 && ARMA_VERSION_MINOR == 4
-    inline explicit Col(const SpCol<eT>& X);
-  #endif
+#if (ARMA_VERSION_MAJOR == 3) && (ARMA_VERSION_MINOR == 4)
+  inline explicit Col(const SpCol<eT>& X);
 #endif

Modified: mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_meat.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_meat.hpp	2012-11-07 20:48:28 UTC (rev 13849)
+++ mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_meat.hpp	2012-11-07 22:39:08 UTC (rev 13850)
@@ -5,19 +5,17 @@
  * Add an extra explicit constructor for sparse vectors, but only if it doesn't
  * already exist (Armadillo 3.4 specific).
  */
-#ifdef ARMA_HAS_SPMAT
-  #if ARMA_VERSION_MAJOR == 3 && ARMA_VERSION_MINOR == 4
-    template<typename eT>
-    inline
-    Col<eT>::Col(const SpCol<eT>& X)
-      : Mat<eT>(arma_vec_indicator(), X.n_elem, 1, 1)
-      {
-      arma_extra_debug_sigprint_this(this);
+#if ARMA_VERSION_MAJOR == 3 && ARMA_VERSION_MINOR == 4
+  template<typename eT>
+  inline
+  Col<eT>::Col(const SpCol<eT>& X)
+    : Mat<eT>(arma_vec_indicator(), X.n_elem, 1, 1)
+    {
+    arma_extra_debug_sigprint_this(this);
 
-      arrayops::inplace_set(Mat<eT>::memptr(), eT(0), X.n_elem);
+    arrayops::inplace_set(Mat<eT>::memptr(), eT(0), X.n_elem);
 
-      for(typename SpCol<eT>::const_iterator it = X.begin(); it != X.end(); ++it)
-        at(it.row()) = (*it);
-      }
-  #endif
+    for(typename SpCol<eT>::const_iterator it = X.begin(); it != X.end(); ++it)
+      at(it.row()) = (*it);
+    }
 #endif

Modified: mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_bones.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_bones.hpp	2012-11-07 20:48:28 UTC (rev 13849)
+++ mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_bones.hpp	2012-11-07 22:39:08 UTC (rev 13850)
@@ -5,8 +5,6 @@
  * Add an extra explicit constructor for sparse vectors, but only if it doesn't
  * already exist (Armadillo 3.4 specific).
  */
-#ifdef ARMA_HAS_SPMAT
-  #if ARMA_VERSION_MAJOR == 3 && ARMA_VERSION_MINOR == 4
-    inline explicit Row(const SpRow<eT>& X);
-  #endif
+#if ARMA_VERSION_MAJOR == 3 && ARMA_VERSION_MINOR == 4
+  inline explicit Row(const SpRow<eT>& X);
 #endif

Modified: mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_meat.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_meat.hpp	2012-11-07 20:48:28 UTC (rev 13849)
+++ mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_meat.hpp	2012-11-07 22:39:08 UTC (rev 13850)
@@ -5,19 +5,17 @@
  * Add an extra explicit constructor for sparse vectors, but only if it doesn't
  * already exist (Armadillo 3.4 specific).
  */
-#ifdef ARMA_HAS_SPMAT
-  #if ARMA_VERSION_MAJOR == 3 && ARMA_VERSION_MINOR == 4
-    template<typename eT>
-    inline
-    Row<eT>::Row(const SpRow<eT>& X)
-      : Mat<eT>(arma_vec_indicator(), 1, X.n_elem, 1)
-      {
-      arma_extra_debug_sigprint_this(this);
+#if ARMA_VERSION_MAJOR == 3 && ARMA_VERSION_MINOR == 4
+  template<typename eT>
+  inline
+  Row<eT>::Row(const SpRow<eT>& X)
+    : Mat<eT>(arma_vec_indicator(), 1, X.n_elem, 1)
+    {
+    arma_extra_debug_sigprint_this(this);
 
-      arrayops::inplace_set(Mat<eT>::memptr(), eT(0), X.n_elem);
+    arrayops::inplace_set(Mat<eT>::memptr(), eT(0), X.n_elem);
 
-      for(typename SpRow<eT>::const_iterator it = X.begin(); it != X.end(); ++it)
-        at(it.col()) = (*it);
-      }
-  #endif
+    for(typename SpRow<eT>::const_iterator it = X.begin(); it != X.end(); ++it)
+      at(it.col()) = (*it);
+    }
 #endif

Modified: mlpack/trunk/src/mlpack/core/arma_extend/arma_extend.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/arma_extend.hpp	2012-11-07 20:48:28 UTC (rev 13849)
+++ mlpack/trunk/src/mlpack/core/arma_extend/arma_extend.hpp	2012-11-07 22:39:08 UTC (rev 13850)
@@ -12,6 +12,20 @@
 #ifndef __MLPACK_CORE_ARMA_EXTEND_ARMA_EXTEND_HPP
 #define __MLPACK_CORE_ARMA_EXTEND_ARMA_EXTEND_HPP
 
+// Use 64-bit indices (define uword as u64), but only if size_t is that size.
+// Basically, this will use 64-bit indices on 64-bit systems and 32-bit indices
+// on 32-bit systems (yes, there are exceptions).
+#if (ULONG_MAX > 0xffffffff)
+  #define ARMA_64BIT_WORD
+#endif
+
+// Add constructors for sparse vectors (these are only added if sparse support
+// is enabled).
+#define ARMA_EXTRA_COL_PROTO mlpack/core/arma_extend/Col_extra_bones.hpp
+#define ARMA_EXTRA_COL_MEAT  mlpack/core/arma_extend/Col_extra_meat.hpp
+#define ARMA_EXTRA_ROW_PROTO mlpack/core/arma_extend/Row_extra_bones.hpp
+#define ARMA_EXTRA_ROW_MEAT  mlpack/core/arma_extend/Row_extra_meat.hpp
+
 #include <armadillo>
 
 // To get CSV support on versions of Armadillo prior to 2.0.0, we'll do this.  I
@@ -20,12 +34,8 @@
   #define csv_ascii (ppm_binary + 1) // ppm_binary is the last in the old enums.
 #endif
 
+
 namespace arma {
-  // u64
-  #include "typedef.hpp"
-  #include "traits.hpp"
-  #include "promote_type.hpp"
-
   // ccov()
   #include "op_ccov_proto.hpp"
   #include "op_ccov_meat.hpp"

Deleted: mlpack/trunk/src/mlpack/core/arma_extend/promote_type.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/promote_type.hpp	2012-11-07 20:48:28 UTC (rev 13849)
+++ mlpack/trunk/src/mlpack/core/arma_extend/promote_type.hpp	2012-11-07 22:39:08 UTC (rev 13850)
@@ -1,106 +0,0 @@
-// Extra promote_type definitions until 64-bit index support is added to
-// Armadillo.  The syntax was changed for 2.1.91, so we need to be careful about
-// how we do that.
-#if ((ARMA_VERSION_MAJOR > 2)) || \
-    ((ARMA_VERSION_MAJOR == 2) && (ARMA_VERSION_MINOR > 1)) || \
-    ((ARMA_VERSION_MAJOR == 2) && (ARMA_VERSION_MINOR == 1) && \
-     (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; };
-
-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<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<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, 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<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
-
-#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; };
-
-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<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<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, 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<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

Deleted: mlpack/trunk/src/mlpack/core/arma_extend/traits.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/traits.hpp	2012-11-07 20:48:28 UTC (rev 13849)
+++ mlpack/trunk/src/mlpack/core/arma_extend/traits.hpp	2012-11-07 22:39:08 UTC (rev 13850)
@@ -1,31 +0,0 @@
-// Extra traits to support u64 and s64 until that patch is applied to the
-// Armadillo sources.
-
-#if ARMA_VERSION_MAJOR < 1 || \
-    (ARMA_VERSION_MAJOR == 1 && ARMA_VERSION_MINOR <= 2)
-// For old Armadillo versions ( <= 1.2.0 ), all we have to do is define these
-// two structs which say these element types are supported.
-template<> struct isnt_supported_elem_type< u64 >                  : public isnt_supported_elem_type_false {};
-template<> struct isnt_supported_elem_type< s64 >                  : public isnt_supported_elem_type_false {};
-
-#else
-// For new Armadillo versions ( > 1.2.0 ) we have to get a little bit more
-// tricky.  We will overload the values for the is_supported_elem_type
-// structure, allowing us to redefine it to report success for u64s and s64s.
-
-// This isn't necessary if Armadillo was compiled with 64-bit support.
-#ifndef ARMA_64BIT_WORD
-template<>
-struct is_supported_elem_type<u64>
-  {
-  static const bool value = true;
-  };
-
-template<>
-struct is_supported_elem_type<s64>
-  {
-  static const bool value = true;
-  };
-#endif
-
-#endif

Deleted: mlpack/trunk/src/mlpack/core/arma_extend/typedef.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/typedef.hpp	2012-11-07 20:48:28 UTC (rev 13849)
+++ mlpack/trunk/src/mlpack/core/arma_extend/typedef.hpp	2012-11-07 22:39:08 UTC (rev 13850)
@@ -1,69 +0,0 @@
-// Extensions to typedef u64 and s64 until that support is added into
-// Armadillo.  We only need to typedef s64 on Armadillo > 1.2.0.
-
-#if   ((ARMA_VERSION_MAJOR > 1)) || \
-      ((ARMA_VERSION_MAJOR == 1) && (ARMA_VERSION_MINOR > 2)) || \
-      ((ARMA_VERSION_MAJOR == 1) && (ARMA_VERSION_MINOR == 2) && \
-       (ARMA_VERSION_PATCH > 0))
-#ifndef ARMA_64BIT_WORD
-  // An unincluded header file typedefs u64 for us.
-  template<const bool size_t_is_greater_or_equal_to_8_bytes>
-  struct deduce_u64
-    {
-    };
-
-  template<>
-  struct deduce_u64<true>
-    {
-    typedef std::size_t u64;
-
-    static const u64  max   = (sizeof(u64) >= 8) ? 0xFFFFFFFFFFFFFFFFULL : 0xFFFFFFFF;  // check required for silly compilers
-    static const bool trunc = false;
-    };
-
-  template<>
-  struct deduce_u64<false>
-    {
-    #if (ULONG_MAX >= 0xFFFFFFFFFFFFFFFF)
-      typedef unsigned long u64;
-      static const u64  max   = 0xFFFFFFFFFFFFFFFFUL;
-      static const bool trunc = false;
-    #elif defined(ULLONG_MAX)
-      typedef unsigned long long u64;
-      static const u64  max   = 0xFFFFFFFFFFFFFFFFULL;
-      static const bool trunc = false;
-    #elif (_MSC_VER >= 1200)
-    //#elif (_MSC_VER >= 1310) && defined(_MSC_EXTENSIONS)
-      typedef unsigned __int64 u64;
-      static const u64  max   = 0xFFFFFFFFFFFFFFFF;
-      static const bool trunc = false;
-    #else
-      #error "don't know how to typedef 'u64' on this system"
-    #endif
-    };
-
-  typedef deduce_u64<(sizeof(std::size_t) >= 8)>::u64 u64;
-#endif
-
-  // We only need to typedef s64.
-  #if   ULONG_MAX >= 0xffffffffffffffff
-    typedef          long s64;
-  #elif ULLONG_MAX >= 0xffffffffffffffff
-    typedef          long s64;
-  #else
-    #error "don't know how to typedef 's64' on this system"
-  #endif
-#else
-
-  // 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
-
-#endif




More information about the mlpack-svn mailing list