[mlpack-svn] r13849 - 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 15:48:28 EST 2012
Author: rcurtin
Date: 2012-11-07 15:48:28 -0500 (Wed, 07 Nov 2012)
New Revision: 13849
Added:
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
Log:
Add explicit constructors for sparse vectors, which are applied only when
Armadillo 3.4 is used (this is a backport of new functionality).
Added: mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_bones.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_bones.hpp (rev 0)
+++ mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_bones.hpp 2012-11-07 20:48:28 UTC (rev 13849)
@@ -0,0 +1,12 @@
+/**
+ * @file Col_extra_bones.hpp
+ * @author Ryan Curtin
+ *
+ * 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
+#endif
Added: mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_meat.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_meat.hpp (rev 0)
+++ mlpack/trunk/src/mlpack/core/arma_extend/Col_extra_meat.hpp 2012-11-07 20:48:28 UTC (rev 13849)
@@ -0,0 +1,23 @@
+/**
+ * @file Col_extra_meat.hpp
+ * @author Ryan Curtin
+ *
+ * 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);
+
+ 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
+#endif
Added: mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_bones.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_bones.hpp (rev 0)
+++ mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_bones.hpp 2012-11-07 20:48:28 UTC (rev 13849)
@@ -0,0 +1,12 @@
+/**
+ * @file Row_extra_bones.hpp
+ * @author Ryan Curtin
+ *
+ * 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
+#endif
Added: mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_meat.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_meat.hpp (rev 0)
+++ mlpack/trunk/src/mlpack/core/arma_extend/Row_extra_meat.hpp 2012-11-07 20:48:28 UTC (rev 13849)
@@ -0,0 +1,23 @@
+/**
+ * @file Row_extra_meat.hpp
+ * @author Ryan Curtin
+ *
+ * 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);
+
+ 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
+#endif
More information about the mlpack-svn
mailing list