[Rcpp-commits] r2920 - in pkg/RcppArmadillo: . inst inst/include/armadillo_bits
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Mar 2 14:26:50 CET 2011
Author: edd
Date: 2011-03-02 14:26:50 +0100 (Wed, 02 Mar 2011)
New Revision: 2920
Modified:
pkg/RcppArmadillo/ChangeLog
pkg/RcppArmadillo/DESCRIPTION
pkg/RcppArmadillo/inst/NEWS
pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Col_proto.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_proto.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_proto.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Row_proto.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/config.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/field_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/field_proto.hpp
Log:
Upgraded to Armadillo 1.1.6
Modified: pkg/RcppArmadillo/ChangeLog
===================================================================
--- pkg/RcppArmadillo/ChangeLog 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/ChangeLog 2011-03-02 13:26:50 UTC (rev 2920)
@@ -1,5 +1,9 @@
2011-03-02 Dirk Eddelbuettel <edd at debian.org>
+ * DESCRIPTION: Release 0.2.14
+
+ * inst/include/*: Updated to Armadillo 1.1.6 “Baby Carpet Shark”
+
* inst/include/RcppArmadillo/Row_meat.h: Support RTTI via vec_stat
* inst/include/RcppArmadillo/Col_meat.h: Support RTTI via vec_stat
Modified: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/DESCRIPTION 2011-03-02 13:26:50 UTC (rev 2920)
@@ -1,7 +1,7 @@
Package: RcppArmadillo
Type: Package
Title: Rcpp integration for Armadillo templated linear algebra library
-Version: 0.2.13
+Version: 0.2.14
Date: $Date$
Author: Romain Francois, Dirk Eddelbuettel and Doug Bates
Maintainer: Romain Francois, Dirk Eddelbuettel and Doug Bates <RcppArmadillo-authors at r-enthusiasts.com>
Modified: pkg/RcppArmadillo/inst/NEWS
===================================================================
--- pkg/RcppArmadillo/inst/NEWS 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/NEWS 2011-03-02 13:26:50 UTC (rev 2920)
@@ -1,5 +1,11 @@
-0.2.14 2011-ab-cd
+0.2.14 2011-03-02
+ o Upgraded to Armadillo Version 1.1.6 “Baby Carpet Shark”
+
+ * fixed size matrices and vectors can use auxiliary (external) memory
+ * .in_range() can use span() arguments
+ * subfields can use span() arguments
+
o Support Run-Time Type Information (RTTI) on matrices by setting the
state variable vec_state in Row and Col instantiation, with thanks to
Conrad Sanderson for the hint
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -571,6 +571,57 @@
+template<typename eT>
+template<u32 fixed_n_elem>
+inline
+Col<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem)
+ {
+ arma_extra_debug_sigprint_this(this);
+
+ if(fixed_n_elem > 0)
+ {
+ access::rw(Mat<eT>::n_rows) = fixed_n_elem;
+ access::rw(Mat<eT>::n_cols) = 1;
+ access::rw(Mat<eT>::n_elem) = fixed_n_elem;
+ access::rw(Mat<eT>::vec_state) = 1;
+ access::rw(Mat<eT>::mem_state) = 3;
+
+ if(copy_aux_mem == true)
+ {
+ access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_prealloc) ? mem_local_extra : Mat<eT>::mem_local;
+
+ arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
+ }
+ else
+ {
+ access::rw(Mat<eT>::mem) = aux_mem;
+ }
+ }
+ else
+ {
+ access::rw(Mat<eT>::n_rows) = 0;
+ access::rw(Mat<eT>::n_cols) = 0;
+ access::rw(Mat<eT>::n_elem) = 0;
+ access::rw(Mat<eT>::vec_state) = 1;
+ access::rw(Mat<eT>::mem_state) = 3;
+ access::rw(Mat<eT>::mem) = 0;
+ }
+ }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+inline
+Col<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
+ {
+ mem_setup();
+
+ arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
+ }
+
+
+
#ifdef ARMA_EXTRA_COL_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_MEAT)
#endif
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_proto.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_proto.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_proto.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -110,6 +110,9 @@
template<typename T1, typename T2>
inline explicit fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B) { mem_setup(); Col<eT>::init(A,B); }
+ inline fixed( eT* aux_mem, const bool copy_aux_mem = true);
+ inline fixed(const eT* aux_mem);
+
inline fixed(const subview_cube<eT>& X) { mem_setup(); Col<eT>::operator=(X); }
inline const Col& operator=(const subview_cube<eT>& X) { Col<eT>::operator=(X); return *this; }
};
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -1970,6 +1970,30 @@
+//! returns true if the given start and end indices are currently in range
+template<typename eT>
+arma_inline
+arma_warn_unused
+bool
+Cube<eT>::in_range(const span& x) const
+ {
+ arma_extra_debug_sigprint();
+
+ if(x.whole == true)
+ {
+ return true;
+ }
+ else
+ {
+ const u32 a = x.a;
+ const u32 b = x.b;
+
+ return ( (a <= b) && (b < n_elem) );
+ }
+ }
+
+
+
//! returns true if the given location is currently in range
template<typename eT>
arma_inline
@@ -1982,6 +2006,34 @@
+template<typename eT>
+inline
+arma_warn_unused
+bool
+Cube<eT>::in_range(const span& row_span, const span& col_span, const span& slice_span) const
+ {
+ arma_extra_debug_sigprint();
+
+ const u32 in_row1 = row_span.a;
+ const u32 in_row2 = row_span.b;
+
+ const u32 in_col1 = col_span.a;
+ const u32 in_col2 = col_span.b;
+
+ const u32 in_slice1 = slice_span.a;
+ const u32 in_slice2 = slice_span.b;
+
+
+ const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (in_row2 < n_rows) );
+ const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (in_col2 < n_cols) );
+ const bool slices_ok = slice_span.whole ? true : ( (in_slice1 <= in_slice2) && (in_slice2 < n_slices) );
+
+
+ return ( (rows_ok == true) && (cols_ok == true) && (slices_ok == true) );
+ }
+
+
+
//! returns a pointer to array of eTs used by the cube
template<typename eT>
arma_inline
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_proto.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_proto.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_proto.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -181,10 +181,11 @@
arma_inline arma_warn_unused bool is_finite() const;
arma_inline arma_warn_unused bool is_empty() const;
- // TODO: expand .in_range() to handle ranges specified by span
- arma_inline arma_warn_unused bool in_range(const u32 i) const;
- arma_inline arma_warn_unused bool in_range(const u32 in_row, const u32 in_col, const u32 in_slice) const;
+ arma_inline arma_warn_unused bool in_range(const u32 i) const;
+ arma_inline arma_warn_unused bool in_range(const span& x) const;
+ arma_inline arma_warn_unused bool in_range(const u32 in_row, const u32 in_col, const u32 in_slice) const;
+ inline arma_warn_unused bool in_range(const span& row_span, const span& col_span, const span& slice_span) const;
arma_inline arma_warn_unused eT* memptr();
arma_inline arma_warn_unused const eT* memptr() const;
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -4845,6 +4845,57 @@
+template<typename eT>
+template<u32 fixed_n_rows, u32 fixed_n_cols>
+inline
+Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(eT* aux_mem, const bool copy_aux_mem)
+ {
+ arma_extra_debug_sigprint_this(this);
+
+ if(fixed_n_elem > 0)
+ {
+ access::rw(Mat<eT>::n_rows) = fixed_n_rows;
+ access::rw(Mat<eT>::n_cols) = fixed_n_cols;
+ access::rw(Mat<eT>::n_elem) = fixed_n_elem;
+ access::rw(Mat<eT>::vec_state) = 0;
+ access::rw(Mat<eT>::mem_state) = 3;
+
+ if(copy_aux_mem == true)
+ {
+ access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_prealloc) ? mem_local_extra : mem_local;
+
+ arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
+ }
+ else
+ {
+ access::rw(Mat<eT>::mem) = aux_mem;
+ }
+ }
+ else
+ {
+ access::rw(Mat<eT>::n_rows) = 0;
+ access::rw(Mat<eT>::n_cols) = 0;
+ access::rw(Mat<eT>::n_elem) = 0;
+ access::rw(Mat<eT>::vec_state) = 0;
+ access::rw(Mat<eT>::mem_state) = 3;
+ access::rw(Mat<eT>::mem) = 0;
+ }
+ }
+
+
+
+template<typename eT>
+template<u32 fixed_n_rows, u32 fixed_n_cols>
+inline
+Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const eT* aux_mem)
+ {
+ mem_setup();
+
+ arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
+ }
+
+
+
//! prefix ++
template<typename eT>
arma_inline
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_proto.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_proto.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_proto.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -258,14 +258,13 @@
arma_inline arma_warn_unused bool is_square() const;
inline arma_warn_unused bool is_finite() const;
- // TODO: test and add expanded .in_range() to user documentation
arma_inline arma_warn_unused bool in_range(const u32 i) const;
arma_inline arma_warn_unused bool in_range(const span& x) const;
- arma_inline arma_warn_unused bool in_range(const u32 in_row, const u32 in_col ) const;
- arma_inline arma_warn_unused bool in_range(const span& row_span, const u32 in_col ) const;
- arma_inline arma_warn_unused bool in_range(const u32 in_row, const span& col_span) const;
- arma_inline arma_warn_unused bool in_range(const span& row_span, const span& col_span) const;
+ arma_inline arma_warn_unused bool in_range(const u32 in_row, const u32 in_col ) const;
+ arma_inline arma_warn_unused bool in_range(const span& row_span, const u32 in_col ) const;
+ arma_inline arma_warn_unused bool in_range(const u32 in_row, const span& col_span) const;
+ arma_inline arma_warn_unused bool in_range(const span& row_span, const span& col_span) const;
arma_inline arma_warn_unused eT* colptr(const u32 in_col);
arma_inline arma_warn_unused const eT* colptr(const u32 in_col) const;
@@ -445,6 +444,9 @@
template<typename T1, typename T2>
inline explicit fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B) { mem_setup(); Mat<eT>::init(A,B); }
+
+ inline fixed( eT* aux_mem, const bool copy_aux_mem = true);
+ inline fixed(const eT* aux_mem);
};
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -546,6 +546,57 @@
+template<typename eT>
+template<u32 fixed_n_elem>
+inline
+Row<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem)
+ {
+ arma_extra_debug_sigprint_this(this);
+
+ if(fixed_n_elem > 0)
+ {
+ access::rw(Mat<eT>::n_rows) = 1;
+ access::rw(Mat<eT>::n_cols) = fixed_n_elem;
+ access::rw(Mat<eT>::n_elem) = fixed_n_elem;
+ access::rw(Mat<eT>::vec_state) = 2;
+ access::rw(Mat<eT>::mem_state) = 3;
+
+ if(copy_aux_mem == true)
+ {
+ access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_prealloc) ? mem_local_extra : Mat<eT>::mem_local;
+
+ arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
+ }
+ else
+ {
+ access::rw(Mat<eT>::mem) = aux_mem;
+ }
+ }
+ else
+ {
+ access::rw(Mat<eT>::n_rows) = 0;
+ access::rw(Mat<eT>::n_cols) = 0;
+ access::rw(Mat<eT>::n_elem) = 0;
+ access::rw(Mat<eT>::vec_state) = 2;
+ access::rw(Mat<eT>::mem_state) = 3;
+ access::rw(Mat<eT>::mem) = 0;
+ }
+ }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+inline
+Row<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
+ {
+ mem_setup();
+
+ arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
+ }
+
+
+
#ifdef ARMA_EXTRA_ROW_MEAT
#include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_MEAT)
#endif
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_proto.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_proto.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_proto.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -110,6 +110,9 @@
template<typename T1, typename T2>
inline explicit fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B) { mem_setup(); Row<eT>::init(A,B); }
+ inline fixed( eT* aux_mem, const bool copy_aux_mem = true);
+ inline fixed(const eT* aux_mem);
+
inline fixed(const subview_cube<eT>& X) { mem_setup(); Row<eT>::operator=(X); }
inline const Row& operator=(const subview_cube<eT>& X) { Row<eT>::operator=(X); return *this; }
};
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -18,11 +18,13 @@
#define ARMA_VERSION_MAJOR 1
#define ARMA_VERSION_MINOR 1
-#define ARMA_VERSION_PATCH 4
-#define ARMA_VERSION_NAME "Manta Lodge"
+#define ARMA_VERSION_PATCH 6
+#define ARMA_VERSION_NAME "Baby Carpet Shark"
+// http://en.wikipedia.org/wiki/Carpet_shark
+
struct arma_version
{
static const unsigned int major = ARMA_VERSION_MAJOR;
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/config.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/config.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/config.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -14,10 +14,17 @@
#if !defined(ARMA_USE_LAPACK)
// #define ARMA_USE_LAPACK
+//// Uncomment the above line if you have LAPACK or a fast replacement for LAPACK,
+//// such as Intel's MKL, AMD's ACML, or the Accelerate framework.
+//// LAPACK is required for matrix decompositions (eg. SVD) and matrix inverse.
#endif
#if !defined(ARMA_USE_BLAS)
// #define ARMA_USE_BLAS
+//// Uncomment the above line if you have BLAS or a fast replacement for BLAS,
+//// such as GotoBLAS, Intel's MKL, AMD's ACML, or the Accelerate framework.
+//// BLAS is used for matrix multiplication.
+//// Without BLAS, matrix multiplication will still work, but might be slower.
#endif
// #define ARMA_BLAS_LONG
@@ -28,7 +35,7 @@
#define ARMA_BLAS_UNDERSCORE
//// Uncomment the above line if your BLAS and LAPACK libraries have function names with a trailing underscore.
-//// Conversely, comment it out if the function names don't have a trailing underscore
+//// Conversely, comment it out if the function names don't have a trailing underscore.
#if !defined(ARMA_MAT_PREALLOC)
#define ARMA_MAT_PREALLOC 16
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/field_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/field_meat.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/field_meat.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -396,9 +396,9 @@
"field::rows(): indicies out of bounds or incorrectly used"
);
- const u32 subfield_n_rows = in_row2 - in_row1 + 1;
+ const u32 sub_n_rows = in_row2 - in_row1 + 1;
- return subview_field<oT>(*this, in_row1, 0, subfield_n_rows, n_cols);
+ return subview_field<oT>(*this, in_row1, 0, sub_n_rows, n_cols);
}
@@ -417,9 +417,9 @@
"field::rows(): indicies out of bounds or incorrectly used"
);
- const u32 subfield_n_rows = in_row2 - in_row1 + 1;
+ const u32 sub_n_rows = in_row2 - in_row1 + 1;
- return subview_field<oT>(*this, in_row1, 0, subfield_n_rows, n_cols);
+ return subview_field<oT>(*this, in_row1, 0, sub_n_rows, n_cols);
}
@@ -438,9 +438,9 @@
"field::cols(): indicies out of bounds or incorrectly used"
);
- const u32 subfield_n_cols = in_col2 - in_col1 + 1;
+ const u32 sub_n_cols = in_col2 - in_col1 + 1;
- return subview_field<oT>(*this, 0, in_col1, n_rows, subfield_n_cols);
+ return subview_field<oT>(*this, 0, in_col1, n_rows, sub_n_cols);
}
@@ -459,9 +459,9 @@
"field::cols(): indicies out of bounds or incorrectly used"
);
- const u32 subfield_n_cols = in_col2 - in_col1 + 1;
+ const u32 sub_n_cols = in_col2 - in_col1 + 1;
- return subview_field<oT>(*this, 0, in_col1, n_rows, subfield_n_cols);
+ return subview_field<oT>(*this, 0, in_col1, n_rows, sub_n_cols);
}
@@ -480,15 +480,15 @@
"field::subfield(): indices out of bounds or incorrectly used"
);
- const u32 subfield_n_rows = in_row2 - in_row1 + 1;
- const u32 subfield_n_cols = in_col2 - in_col1 + 1;
+ const u32 sub_n_rows = in_row2 - in_row1 + 1;
+ const u32 sub_n_cols = in_col2 - in_col1 + 1;
- return subview_field<oT>(*this, in_row1, in_col1, subfield_n_rows, subfield_n_cols);
+ return subview_field<oT>(*this, in_row1, in_col1, sub_n_rows, sub_n_cols);
}
-//! creation of subview_field (generic submatrix)
+//! creation of subview_field (subfield with arbitrary dimensions)
template<typename oT>
inline
const subview_field<oT>
@@ -502,14 +502,110 @@
"field::subfield(): indices out of bounds or incorrectly used"
);
- const u32 subfield_n_rows = in_row2 - in_row1 + 1;
- const u32 subfield_n_cols = in_col2 - in_col1 + 1;
+ const u32 sub_n_rows = in_row2 - in_row1 + 1;
+ const u32 sub_n_cols = in_col2 - in_col1 + 1;
- return subview_field<oT>(*this, in_row1, in_col1, subfield_n_rows, subfield_n_cols);
+ return subview_field<oT>(*this, in_row1, in_col1, sub_n_rows, sub_n_cols);
}
+//! creation of subview_field (subfield with arbitrary dimensions)
+template<typename oT>
+inline
+subview_field<oT>
+field<oT>::subfield(const span& row_span, const span& col_span)
+ {
+ arma_extra_debug_sigprint();
+
+ const bool row_all = row_span.whole;
+ const bool col_all = col_span.whole;
+
+ const u32 local_n_rows = n_rows;
+ const u32 local_n_cols = n_cols;
+
+ const u32 in_row1 = row_all ? 0 : row_span.a;
+ const u32 in_row2 = row_span.b;
+ const u32 sub_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
+
+ const u32 in_col1 = col_all ? 0 : col_span.a;
+ const u32 in_col2 = col_span.b;
+ const u32 sub_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
+
+ arma_debug_check
+ (
+ ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
+ ||
+ ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
+ ,
+ "field::subfield(): indices out of bounds or incorrectly used"
+ );
+
+ return subview_field<oT>(*this, in_row1, in_col1, sub_n_rows, sub_n_cols);
+ }
+
+
+
+//! creation of subview_field (subfield with arbitrary dimensions)
+template<typename oT>
+inline
+const subview_field<oT>
+field<oT>::subfield(const span& row_span, const span& col_span) const
+ {
+ arma_extra_debug_sigprint();
+
+ const bool row_all = row_span.whole;
+ const bool col_all = col_span.whole;
+
+ const u32 local_n_rows = n_rows;
+ const u32 local_n_cols = n_cols;
+
+ const u32 in_row1 = row_all ? 0 : row_span.a;
+ const u32 in_row2 = row_span.b;
+ const u32 sub_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
+
+ const u32 in_col1 = col_all ? 0 : col_span.a;
+ const u32 in_col2 = col_span.b;
+ const u32 sub_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
+
+ arma_debug_check
+ (
+ ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
+ ||
+ ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
+ ,
+ "field::subfield(): indices out of bounds or incorrectly used"
+ );
+
+ return subview_field<oT>(*this, in_row1, in_col1, sub_n_rows, sub_n_cols);
+ }
+
+
+
+template<typename oT>
+inline
+subview_field<oT>
+field<oT>::operator()(const span& row_span, const span& col_span)
+ {
+ arma_extra_debug_sigprint();
+
+ return (*this).subfield(row_span, col_span);
+ }
+
+
+
+template<typename oT>
+inline
+const subview_field<oT>
+field<oT>::operator()(const span& row_span, const span& col_span) const
+ {
+ arma_extra_debug_sigprint();
+
+ return (*this).subfield(row_span, col_span);
+ }
+
+
+
//! print contents of the field (to the cout stream),
//! optionally preceding with a user specified line of text.
//! the field class preserves the stream's flags
@@ -628,6 +724,7 @@
//! returns true if the given index is currently in range
template<typename oT>
arma_inline
+arma_warn_unused
bool
field<oT>::in_range(const u32 i) const
{
@@ -636,9 +733,34 @@
+//! returns true if the given start and end indices are currently in range
+template<typename oT>
+arma_inline
+arma_warn_unused
+bool
+field<oT>::in_range(const span& x) const
+ {
+ arma_extra_debug_sigprint();
+
+ if(x.whole == true)
+ {
+ return true;
+ }
+ else
+ {
+ const u32 a = x.a;
+ const u32 b = x.b;
+
+ return ( (a <= b) && (b < n_elem) );
+ }
+ }
+
+
+
//! returns true if the given location is currently in range
template<typename oT>
arma_inline
+arma_warn_unused
bool
field<oT>::in_range(const u32 in_row, const u32 in_col) const
{
@@ -648,6 +770,74 @@
template<typename oT>
+arma_inline
+arma_warn_unused
+bool
+field<oT>::in_range(const span& row_span, const u32 in_col) const
+ {
+ arma_extra_debug_sigprint();
+
+ if(row_span.whole == true)
+ {
+ return (in_col < n_cols);
+ }
+ else
+ {
+ const u32 in_row1 = row_span.a;
+ const u32 in_row2 = row_span.b;
+
+ return ( (in_row1 <= in_row2) && (in_row2 < n_rows) && (in_col < n_cols) );
+ }
+ }
+
+
+
+template<typename oT>
+arma_inline
+arma_warn_unused
+bool
+field<oT>::in_range(const u32 in_row, const span& col_span) const
+ {
+ arma_extra_debug_sigprint();
+
+ if(col_span.whole == true)
+ {
+ return (in_row < n_rows);
+ }
+ else
+ {
+ const u32 in_col1 = col_span.a;
+ const u32 in_col2 = col_span.b;
+
+ return ( (in_row < n_rows) && (in_col1 <= in_col2) && (in_col2 < n_cols) );
+ }
+ }
+
+
+
+template<typename oT>
+arma_inline
+arma_warn_unused
+bool
+field<oT>::in_range(const span& row_span, const span& col_span) const
+ {
+ arma_extra_debug_sigprint();
+
+ const u32 in_row1 = row_span.a;
+ const u32 in_row2 = row_span.b;
+
+ const u32 in_col1 = col_span.a;
+ const u32 in_col2 = col_span.b;
+
+ const bool rows_ok = row_span.whole ? true : ( (in_row1 <= in_row2) && (in_row2 < n_rows) );
+ const bool cols_ok = col_span.whole ? true : ( (in_col1 <= in_col2) && (in_col2 < n_cols) );
+
+ return ( (rows_ok == true) && (cols_ok == true) );
+ }
+
+
+
+template<typename oT>
inline
bool
field<oT>::save(const std::string name, const file_type type, const bool print_status) const
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/field_proto.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/field_proto.hpp 2011-03-02 13:11:24 UTC (rev 2919)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/field_proto.hpp 2011-03-02 13:26:50 UTC (rev 2920)
@@ -1,5 +1,5 @@
-// Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
-// Copyright (C) 2008-2010 Conrad Sanderson
+// Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
+// Copyright (C) 2008-2011 Conrad Sanderson
// Copyright (C) 2009-2010 Ian Cullinan
//
// This file is part of the Armadillo C++ library.
@@ -84,6 +84,7 @@
inline field_injector<field> operator<<(const oT& val);
inline field_injector<field> operator<<(const injector_end_of_row& x);
+
inline subview_field<oT> row(const u32 row_num);
inline const subview_field<oT> row(const u32 row_num) const;
@@ -99,6 +100,13 @@
inline subview_field<oT> subfield(const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2);
inline const subview_field<oT> subfield(const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2) const;
+ inline subview_field<oT> subfield (const span& row_span, const span& col_span);
+ inline const subview_field<oT> subfield (const span& row_span, const span& col_span) const;
+
+ inline subview_field<oT> operator()(const span& row_span, const span& col_span);
+ inline const subview_field<oT> operator()(const span& row_span, const span& col_span) const;
+
+
inline void print(const std::string extra_text = "") const;
inline void print(std::ostream& user_stream, const std::string extra_text = "") const;
@@ -109,9 +117,13 @@
arma_inline bool is_empty() const;
- arma_inline bool in_range(const u32 i) const;
- arma_inline bool in_range(const u32 in_row, const u32 in_col) const;
+ arma_inline arma_warn_unused bool in_range(const u32 i) const;
+ arma_inline arma_warn_unused bool in_range(const span& x) const;
+ arma_inline arma_warn_unused bool in_range(const u32 in_row, const u32 in_col ) const;
+ arma_inline arma_warn_unused bool in_range(const span& row_span, const u32 in_col ) const;
+ arma_inline arma_warn_unused bool in_range(const u32 in_row, const span& col_span) const;
+ arma_inline arma_warn_unused bool in_range(const span& row_span, const span& col_span) const;
inline bool save(const std::string name, const file_type type = arma_binary, const bool print_status = true) const;
inline bool save( std::ostream& os, const file_type type = arma_binary, const bool print_status = true) const;
More information about the Rcpp-commits
mailing list