[mlpack-svn] r12340 - mlpack/trunk/src/mlpack/core/arma_extend/sparse
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Apr 12 11:52:49 EDT 2012
Author: rcurtin
Date: 2012-04-12 11:52:49 -0400 (Thu, 12 Apr 2012)
New Revision: 12340
Added:
mlpack/trunk/src/mlpack/core/arma_extend/sparse/traits.hpp
Modified:
mlpack/trunk/src/mlpack/core/arma_extend/sparse/Proxy.hpp
mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpCol_bones.hpp
mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpMat_bones.hpp
mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpRow_bones.hpp
mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpSubview_bones.hpp
Log:
Hackery necessary for sparse support using Armadillo 3.0.0 or greater.
Modified: mlpack/trunk/src/mlpack/core/arma_extend/sparse/Proxy.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/sparse/Proxy.hpp 2012-04-12 15:48:43 UTC (rev 12339)
+++ mlpack/trunk/src/mlpack/core/arma_extend/sparse/Proxy.hpp 2012-04-12 15:52:49 UTC (rev 12340)
@@ -26,6 +26,11 @@
static const bool prefer_at_accessor = false;
static const bool has_subview = false;
+#if (ARMA_VERSION_MAJOR >= 3)
+ static const bool is_row = false;
+ static const bool is_col = false;
+#endif
+
arma_aligned const SpMat<eT>& Q;
inline explicit Proxy(const SpMat<eT>& A)
@@ -60,6 +65,11 @@
static const bool prefer_at_accessor = false;
static const bool has_subview = false;
+#if (ARMA_VERSION_MAJOR >= 3)
+ static const bool is_row = false;
+ static const bool is_col = true;
+#endif
+
arma_aligned const SpCol<eT>& Q;
inline explicit Proxy(const SpCol<eT>& A)
@@ -94,6 +104,11 @@
static const bool prefer_at_accessor = false;
static const bool has_subview = false;
+#if (ARMA_VERSION_MAJOR >= 3)
+ static const bool is_row = true;
+ static const bool is_col = false;
+#endif
+
arma_aligned const SpRow<eT>& Q;
inline explicit Proxy(const SpRow<eT>& A)
@@ -128,6 +143,11 @@
static const bool prefer_at_accessor = true;
static const bool has_subview = true;
+#if (ARMA_VERSION_MAJOR >= 3)
+ static const bool is_row = false;
+ static const bool is_col = false;
+#endif
+
arma_aligned const SpSubview<eT>& Q;
inline explicit Proxy(const SpSubview<eT>& A)
Modified: mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpCol_bones.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpCol_bones.hpp 2012-04-12 15:48:43 UTC (rev 12339)
+++ mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpCol_bones.hpp 2012-04-12 15:52:49 UTC (rev 12340)
@@ -20,10 +20,15 @@
class SpCol : public SpMat<eT>
{
public:
-
+
typedef eT elem_type;
- typedef typename get_pod_type<eT>::result pod_type;
+ typedef typename get_pod_type<eT>::result pod_type;
+#if (ARMA_VERSION_MAJOR) >= 3
+ static const bool is_row = false;
+ static const bool is_col = true;
+#endif
+
inline SpCol();
inline explicit SpCol(const uword n_elem);
inline SpCol(const uword in_rows, const uword in_cols);
@@ -33,7 +38,7 @@
inline SpCol(const std::string& text);
inline const SpCol& operator=(const std::string& text);
-
+
inline const SpCol& operator=(const eT val);
template<typename T1> inline SpCol(const Base<eT,T1>& X);
@@ -62,11 +67,11 @@
inline void shed_row (const uword row_num);
inline void shed_rows(const uword in_row1, const uword in_row2);
-
+
inline void insert_rows(const uword row_num, const uword N, const bool set_to_zero = true);
template<typename T1> inline void insert_rows(const uword row_num, const Base<eT,T1>& X);
-
-
+
+
typedef typename SpMat<eT>::iterator row_iterator;
typedef typename SpMat<eT>::const_iterator const_row_iterator;
Modified: mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpMat_bones.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpMat_bones.hpp 2012-04-12 15:48:43 UTC (rev 12339)
+++ mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpMat_bones.hpp 2012-04-12 15:52:49 UTC (rev 12340)
@@ -23,6 +23,11 @@
typedef eT elem_type; //!< the type of elements stored in the matrix
typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-complex, pod_type is the same as eT; otherwise, pod_type is the underlying type used by std::complex
+#if (ARMA_VERSION_MAJOR) >= 3
+ static const bool is_row = false;
+ static const bool is_col = false;
+#endif
+
const uword n_rows;
const uword n_cols;
const uword n_elem;
Modified: mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpRow_bones.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpRow_bones.hpp 2012-04-12 15:48:43 UTC (rev 12339)
+++ mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpRow_bones.hpp 2012-04-12 15:52:49 UTC (rev 12340)
@@ -1,6 +1,6 @@
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
// Copyright (C) 2008-2011 Conrad Sanderson
-//
+//
// This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness
// for any purpose. You can redistribute this file
@@ -20,71 +20,75 @@
class SpRow : public Mat<eT>
{
public:
-
+
typedef eT elem_type;
typedef typename get_pod_type<eT>::result pod_type;
-
-
+
+#if (ARMA_VERSION_MAJOR) >= 3
+ static const bool is_row = true;
+ static const bool is_col = false;
+#endif
+
inline SpRow();
inline explicit SpRow(const uword N);
inline SpRow(const uword in_rows, const uword in_cols);
-
+
inline SpRow(const char* text);
inline const SpRow& operator=(const char* text);
-
+
inline SpRow(const std::string& text);
inline const SpRow& operator=(const std::string& text);
-
+
inline const SpRow& operator=(const eT val);
template<typename T1> inline SpRow(const Base<eT,T1>& X);
template<typename T1> inline const SpRow& operator=(const Base<eT,T1>& X);
-
+
template<typename T1, typename T2>
inline explicit SpRow(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
-
+
template<typename T1> inline SpRow(const BaseCube<eT,T1>& X);
template<typename T1> inline const SpRow& operator=(const BaseCube<eT,T1>& X);
-
+
inline SpRow(const subview_cube<eT>& X);
inline const SpRow& operator=(const subview_cube<eT>& X);
-
+
arma_inline eT& col(const uword col_num);
arma_inline eT col(const uword col_num) const;
-
+
arma_inline subview_row<eT> cols(const uword in_col1, const uword in_col2);
arma_inline const subview_row<eT> cols(const uword in_col1, const uword in_col2) const;
-
+
arma_inline subview_row<eT> subvec(const uword in_col1, const uword in_col2);
arma_inline const subview_row<eT> subvec(const uword in_col1, const uword in_col2) const;
-
+
arma_inline subview_row<eT> subvec(const span& col_span);
arma_inline const subview_row<eT> subvec(const span& col_span) const;
-
+
// arma_inline subview_row<eT> operator()(const span& col_span);
// arma_inline const subview_row<eT> operator()(const span& col_span) const;
-
-
+
+
inline void shed_col (const uword col_num);
inline void shed_cols(const uword in_col1, const uword in_col2);
-
+
inline void insert_cols(const uword col_num, const uword N, const bool set_to_zero = true);
template<typename T1> inline void insert_cols(const uword col_num, const Base<eT,T1>& X);
-
-
+
+
typedef typename SpMat<eT>::iterator row_iterator;
typedef typename SpMat<eT>::const_iterator const_row_iterator;
-
+
inline row_iterator begin_row(const uword row_num);
inline const_row_iterator begin_row(const uword row_num) const;
-
+
inline row_iterator end_row (const uword row_num);
inline const_row_iterator end_row (const uword row_num) const;
-
+
#ifdef ARMA_EXTRA_ROW_PROTO
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_PROTO)
#endif
-
+
};
Modified: mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpSubview_bones.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpSubview_bones.hpp 2012-04-12 15:48:43 UTC (rev 12339)
+++ mlpack/trunk/src/mlpack/core/arma_extend/sparse/SpSubview_bones.hpp 2012-04-12 15:52:49 UTC (rev 12340)
@@ -10,6 +10,11 @@
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
+#if (ARMA_VERSION_MAJOR) >= 3
+ static const bool is_row = false;
+ static const bool is_col = false;
+#endif
+
const uword aux_row1;
const uword aux_col1;
const uword n_rows;
@@ -36,7 +41,7 @@
template<typename T1> inline void operator-= (const Base<eT,T1>& x);
template<typename T1> inline void operator%= (const Base<eT,T1>& x);
template<typename T1> inline void operator/= (const Base<eT,T1>& x);
-
+
/* not doing anything special
inline void operator= (const SpSubview& x);
inline void operator+= (const SpSubview& x);
@@ -61,55 +66,55 @@
inline eT& operator[](const uword i);
inline eT operator[](const uword i) const;
-
+
inline eT& operator()(const uword i);
inline eT operator()(const uword i) const;
-
+
inline eT& operator()(const uword in_row, const uword in_col);
inline eT operator()(const uword in_row, const uword in_col) const;
-
+
inline eT& at(const uword in_row, const uword in_col);
inline eT at(const uword in_row, const uword in_col) const;
inline bool check_overlap(const SpSubview& x) const;
-
+
inline bool is_vec() const;
-
+
/* not yet
inline SpSubview_row<eT> row(const uword row_num);
inline const SpSubview_row<eT> row(const uword row_num) const;
-
+
inline SpSubview_row<eT> operator()(const uword row_num, const span& col_span);
inline const SpSubview_row<eT> operator()(const uword row_num, const span& col_span) const;
-
+
inline SpSubview_col<eT> col(const uword col_num);
inline const SpSubview_col<eT> col(const uword col_num) const;
-
+
inline SpSubview_col<eT> operator()(const span& row_span, const uword col_num);
inline const SpSubview_col<eT> operator()(const span& row_span, const uword col_num) const;
-
+
inline Col<eT> unsafe_col(const uword col_num);
inline const Col<eT> unsafe_col(const uword col_num) const;
-
+
inline SpSubview<eT> rows(const uword in_row1, const uword in_row2);
inline const SpSubview<eT> rows(const uword in_row1, const uword in_row2) const;
-
+
inline SpSubview<eT> cols(const uword in_col1, const uword in_col2);
inline const SpSubview<eT> cols(const uword in_col1, const uword in_col2) const;
-
+
inline SpSubview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2);
inline const SpSubview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const;
-
+
inline SpSubview<eT> submat (const span& row_span, const span& col_span);
inline const SpSubview<eT> submat (const span& row_span, const span& col_span) const;
-
+
inline SpSubview<eT> operator()(const span& row_span, const span& col_span);
inline const SpSubview<eT> operator()(const span& row_span, const span& col_span) const;
-
+
inline diagview<eT> diag(const s32 in_id = 0);
inline const diagview<eT> diag(const s32 in_id = 0) const;
*/
-
+
inline void swap_rows(const uword in_row1, const uword in_row2);
inline void swap_cols(const uword in_col1, const uword in_col2);
@@ -124,38 +129,38 @@
class SpSubview_col : public SpSubview<eT>
{
public:
-
+
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
-
+
inline void operator= (const SpSubview<eT>& x);
inline void operator= (const SpSubview_col& x);
-
+
template<typename T1>
inline void operator= (const Base<eT,T1>& x);
-
+
inline SpSubview_col<eT> rows(const uword in_row1, const uword in_row2);
inline const SpSubview_col<eT> rows(const uword in_row1, const uword in_row2) const;
-
+
inline SpSubview_col<eT> subvec(const uword in_row1, const uword in_row2);
inline const SpSubview_col<eT> subvec(const uword in_row1, const uword in_row2) const;
-
-
+
+
protected:
-
+
inline SpSubview_col(const Mat<eT>& in_m, const uword in_col);
inline SpSubview_col( Mat<eT>& in_m, const uword in_col);
-
+
inline SpSubview_col(const Mat<eT>& in_m, const uword in_col, const uword in_row1, const uword in_n_rows);
inline SpSubview_col( Mat<eT>& in_m, const uword in_col, const uword in_row1, const uword in_n_rows);
-
-
+
+
private:
-
+
friend class Mat<eT>;
friend class Col<eT>;
friend class SpSubview<eT>;
-
+
SpSubview_col();
};
@@ -163,38 +168,38 @@
class SpSubview_row : public SpSubview<eT>
{
public:
-
+
typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
-
+
inline void operator= (const SpSubview<eT>& x);
inline void operator= (const SpSubview_row& x);
-
+
template<typename T1>
inline void operator= (const Base<eT,T1>& x);
-
+
inline SpSubview_row<eT> cols(const uword in_col1, const uword in_col2);
inline const SpSubview_row<eT> cols(const uword in_col1, const uword in_col2) const;
-
+
inline SpSubview_row<eT> subvec(const uword in_col1, const uword in_col2);
inline const SpSubview_row<eT> subvec(const uword in_col1, const uword in_col2) const;
-
-
+
+
protected:
-
+
inline SpSubview_row(const Mat<eT>& in_m, const uword in_row);
inline SpSubview_row( Mat<eT>& in_m, const uword in_row);
-
+
inline SpSubview_row(const Mat<eT>& in_m, const uword in_row, const uword in_col1, const uword in_n_cols);
inline SpSubview_row( Mat<eT>& in_m, const uword in_row, const uword in_col1, const uword in_n_cols);
-
-
+
+
private:
-
+
friend class Mat<eT>;
friend class Row<eT>;
friend class SpSubview<eT>;
-
+
SpSubview_row();
};
*/
Added: mlpack/trunk/src/mlpack/core/arma_extend/sparse/traits.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/arma_extend/sparse/traits.hpp (rev 0)
+++ mlpack/trunk/src/mlpack/core/arma_extend/sparse/traits.hpp 2012-04-12 15:52:49 UTC (rev 12340)
@@ -0,0 +1,58 @@
+#if (ARMA_VERSION_MAJOR) >= 3
+// Cheap hack so that we can do things with SpMats in Armadillo 3.0.0.
+
+template<typename eT>
+struct is_Mat< SpMat<eT> >
+ { static const bool value = true; };
+
+template<typename eT>
+struct is_Mat< SpCol<eT> >
+ { static const bool value = true; };
+
+template<typename eT>
+struct is_Mat< SpRow<eT> >
+ { static const bool value = true; };
+
+template<typename eT>
+struct is_Mat< const SpMat<eT> >
+ { static const bool value = true; };
+
+template<typename eT>
+struct is_Mat< const SpCol<eT> >
+ { static const bool value = true; };
+
+template<typename eT>
+struct is_Mat< const SpRow<eT> >
+ { static const bool value = true; };
+
+
+
+template<typename eT>
+struct is_Row< SpRow<eT> >
+ { static const bool value = true; };
+
+template<typename eT>
+struct is_Row< const SpRow<eT> >
+ { static const bool value = true; };
+
+
+
+template<typename eT>
+struct is_Col< SpCol<eT> >
+ { static const bool value = true; };
+
+template<typename eT>
+struct is_Col< const SpCol<eT> >
+ { static const bool value = true; };
+
+
+
+template<typename eT>
+struct is_subview< SpSubview<eT> >
+ { static const bool value = true; };
+
+template<typename eT>
+struct is_subview< const SpSubview<eT> >
+ { static const bool value = true; };
+
+#endif
More information about the mlpack-svn
mailing list