[mlpack] Add patch so u64/s64 work with recent Armadillo versions.
rcurtin
rcurtin at fedoraproject.org
Tue Jan 1 22:35:25 UTC 2013
commit d3a671e9dbe8b78ac6f071667e6a83695139b914
Author: Ryan Curtin <gth671b at mail.gatech.edu>
Date: Tue Jan 1 17:35:04 2013 -0500
Add patch so u64/s64 work with recent Armadillo versions.
mlpack.spec | 9 +++-
u64_s64.patch | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 155 insertions(+), 1 deletions(-)
---
diff --git a/mlpack.spec b/mlpack.spec
index 5c9fb86..02bde5d 100644
--- a/mlpack.spec
+++ b/mlpack.spec
@@ -1,6 +1,6 @@
Name: mlpack
Version: 1.0.3
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Scalable, fast C++ machine learning library
Group: System Environment/Libraries
@@ -13,6 +13,12 @@ Source0: http://www.mlpack.org/files/%{name}-%{version}.tar.gz
# be fixed by mlpack 1.0.2.
Patch0: cmake_libdir.patch
+# The u64/s64 support in Armadillo is not complete if ARMA_64BIT_WORD is not
+# defined. We cannot assume that it is defined, so we have to backport some
+# changes from trunk which ensure u64/s64 will work properly even when
+# ARMA_64BIT_WORD is not defined.
+Patch1: u64_s64.patch
+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: cmake >= 2.8.0
@@ -91,6 +97,7 @@ margins. This package provides the Doxygen-generated documentation for mlpack.
%prep
%setup -q
%patch0 -p1
+%patch1 -p1
%build
diff --git a/u64_s64.patch b/u64_s64.patch
new file mode 100644
index 0000000..eea1ec6
--- /dev/null
+++ b/u64_s64.patch
@@ -0,0 +1,147 @@
+Index: mlpack-1.0.3/src/mlpack/core/arma_extend/traits.hpp
+===================================================================
+--- mlpack-1.0.3/src/mlpack/core/arma_extend/traits.hpp (revision 13920)
++++ mlpack-1.0.3/src/mlpack/core/arma_extend/traits.hpp (working copy)
+@@ -15,7 +15,25 @@
+
+ // 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; };
++
+ template<>
++struct is_u64<u64>
++ { static const bool value = true; };
++
++
++template<typename T1>
++struct is_s64
++ { static const bool value = false; };
++
++template<>
++struct is_s64<s64>
++ { static const bool value = true; };
++
++
++template<>
+ struct is_supported_elem_type<u64>
+ {
+ static const bool value = true;
+@@ -26,6 +44,13 @@
+ {
+ static const bool value = true;
+ };
++
++
++template<>
++struct is_signed<u64>
++ {
++ static const bool value = false;
++ };
+ #endif
+
+ #endif
+Index: mlpack-1.0.3/src/mlpack/core/arma_extend/restrictors.hpp
+===================================================================
+--- mlpack-1.0.3/src/mlpack/core/arma_extend/restrictors.hpp (revision 0)
++++ mlpack-1.0.3/src/mlpack/core/arma_extend/restrictors.hpp (working copy)
+@@ -0,0 +1,17 @@
++// Modifications to allow u64/s64 in Armadillo when ARMA_64BIT_WORD is not
++// defined.
++#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_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_signed_integral_only<s64> { typedef s64 result; };
++
++template<> struct arma_signed_only<s64> { typedef s64 result; };
++
++#endif
+Index: mlpack-1.0.3/src/mlpack/core/arma_extend/arma_extend.hpp
+===================================================================
+--- mlpack-1.0.3/src/mlpack/core/arma_extend/arma_extend.hpp (revision 13920)
++++ mlpack-1.0.3/src/mlpack/core/arma_extend/arma_extend.hpp (working copy)
+@@ -21,10 +21,12 @@
+ #endif
+
+ namespace arma {
+- // u64
++ // u64/s64
+ #include "typedef.hpp"
+ #include "traits.hpp"
+ #include "promote_type.hpp"
++ #include "restrictors.hpp"
++ #include "hdf5_misc.hpp"
+
+ // ccov()
+ #include "op_ccov_proto.hpp"
+Index: mlpack-1.0.3/src/mlpack/core/arma_extend/typedef.hpp
+===================================================================
+--- mlpack-1.0.3/src/mlpack/core/arma_extend/typedef.hpp (revision 13920)
++++ mlpack-1.0.3/src/mlpack/core/arma_extend/typedef.hpp (working copy)
+@@ -42,17 +42,28 @@
+ #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;
++ typedef long long s64;
+ #else
+ #error "don't know how to typedef 's64' on this system"
+ #endif
++
++ typedef deduce_u64<(sizeof(std::size_t) >= 8)>::u64 u64;
++
++ namespace junk
++ {
++ 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
++
+ #else
+
+ // We must typedef both u64 and s64.
+Index: mlpack-1.0.3/src/mlpack/core/arma_extend/hdf5_misc.hpp
+===================================================================
+--- mlpack-1.0.3/src/mlpack/core/arma_extend/hdf5_misc.hpp (revision 0)
++++ mlpack-1.0.3/src/mlpack/core/arma_extend/hdf5_misc.hpp (working copy)
+@@ -0,0 +1,21 @@
++// To hack in u64/s64 support to Armadillo when it is not compiled with
++// ARMA_64BIT_WORD.
++#ifdef ARMA_USE_HDF5
++
++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);
++ }
++
++#endif
More information about the scm-commits
mailing list