[Rcpp-commits] r4110 - in pkg/RcppArmadillo: . inst inst/examples inst/include inst/include/armadillo_bits man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Dec 7 13:30:59 CET 2012
Author: edd
Date: 2012-12-07 13:30:59 +0100 (Fri, 07 Dec 2012)
New Revision: 4110
Added:
pkg/RcppArmadillo/inst/include/armadillo_bits/mtSpOp_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/mtSpOp_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/spop_mean_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/spop_mean_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/spop_var_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/spop_var_meat.hpp
Modified:
pkg/RcppArmadillo/ChangeLog
pkg/RcppArmadillo/DESCRIPTION
pkg/RcppArmadillo/inst/NEWS.Rd
pkg/RcppArmadillo/inst/examples/fastLm.r
pkg/RcppArmadillo/inst/include/armadillo
pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpGlue_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpOp_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpProxy.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpRow_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpRow_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_iterators_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/compiler_setup.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/debug.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/eglue_core_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/eop_core_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_accu.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_elem.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_mean.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_norm.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_sort.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_sort_index.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_strans.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trans.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trunc_exp.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trunc_log.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_var.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/forward_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/glue_relational_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/hdf5_misc.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/memory.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/op_median_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/op_misc_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/op_relational_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/op_shuffle_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/spop_max_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/spop_min_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/spop_misc_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/spop_misc_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/spop_sum_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/spop_sum_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/traits.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/unwrap_spmat.hpp
pkg/RcppArmadillo/man/RcppArmadillo-package.Rd
Log:
Release 0.3.6.0 with Armadillo 3.6.0 released today
Modified: pkg/RcppArmadillo/ChangeLog
===================================================================
--- pkg/RcppArmadillo/ChangeLog 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/ChangeLog 2012-12-07 12:30:59 UTC (rev 4110)
@@ -1,3 +1,9 @@
+2012-12-07 Dirk Eddelbuettel <edd at debian.org>
+
+ * DESCRIPTION: Release 0.3.6.0
+
+ * inst/include/*: Upgraded to new release 3.6.0 of Armadillo
+
2012-11-15 Dirk Eddelbuettel <edd at debian.org>
* DESCRIPTION: Release 0.3.4.4
Modified: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/DESCRIPTION 2012-12-07 12:30:59 UTC (rev 4110)
@@ -1,7 +1,7 @@
Package: RcppArmadillo
Type: Package
Title: Rcpp integration for Armadillo templated linear algebra library
-Version: 0.3.4.4
+Version: 0.3.6.0
Date: $Date$
Author: Romain Francois, Dirk Eddelbuettel and Doug Bates
Maintainer: Dirk Eddelbuettel <edd at debian.org>
@@ -21,7 +21,7 @@
(due to speed and/or integration capabilities), rather than another language.
.
The RcppArmadillo package includes the header files from the templated
- Armadillo library (currently version 3.4.4). Thus users do not need to
+ Armadillo library (currently version 3.6.0). Thus users do not need to
install Armadillo itself in order to use RcppArmadillo.
.
This Armadillo integration provides a nice illustration of the
Modified: pkg/RcppArmadillo/inst/NEWS.Rd
===================================================================
--- pkg/RcppArmadillo/inst/NEWS.Rd 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/NEWS.Rd 2012-12-07 12:30:59 UTC (rev 4110)
@@ -2,12 +2,20 @@
\title{News for Package 'RcppArmadillo'}
\newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
-\section{Changes in RcppArmadillo version 0.3.4.4 (2012-11-15)}{
+
+\section{Changes in RcppArmadillo version 0.3.6.0 (2012-12-07)}{
\itemize{
- \item Upgraded to Armadillo release 3.4.4
+ \item Upgraded to Armadillo release Version 3.6.0 (Piazza del Duomo)
\itemize{
- \item fix for handling complex numbers by sparse matrices
- \item fix for minor memory leak by sparse matrices
+ \item faster handling of compound expressions with submatrices and
+ subcubes
+ \item added support for loading matrices as text files with
+ \code{NaN} and \code{Inf} elements
+ \item added \code{stable_sort_index()}, which preserves the relative
+ order of elements with equivalent values
+ \item added handling of sparse matrices by \code{mean()},
+ \code{var()}, \code{norm()}, \code{abs()}, \code{square()}, \code{sqrt()}
+ \item added saving and loading of sparse matrices in arma_binary format
}
}
}
Modified: pkg/RcppArmadillo/inst/examples/fastLm.r
===================================================================
--- pkg/RcppArmadillo/inst/examples/fastLm.r 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/examples/fastLm.r 2012-12-07 12:30:59 UTC (rev 4110)
@@ -73,7 +73,7 @@
fastLmPureDotCall <- function(X, y) {
- .Call("fastLm", X, y, package = "RcppArmadillo")
+ .Call("fastLm", X, y, PACKAGE = "RcppArmadillo")
}
Modified: pkg/RcppArmadillo/inst/include/armadillo
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/include/armadillo 2012-12-07 12:30:59 UTC (rev 4110)
@@ -176,6 +176,7 @@
#include "armadillo_bits/mtOp_bones.hpp"
#include "armadillo_bits/mtOpCube_bones.hpp"
+ #include "armadillo_bits/mtSpOp_bones.hpp"
#include "armadillo_bits/Glue_bones.hpp"
#include "armadillo_bits/eGlue_bones.hpp"
@@ -248,6 +249,8 @@
#include "armadillo_bits/spop_strans_bones.hpp"
#include "armadillo_bits/spop_htrans_bones.hpp"
#include "armadillo_bits/spop_misc_bones.hpp"
+ #include "armadillo_bits/spop_mean_bones.hpp"
+ #include "armadillo_bits/spop_var_bones.hpp"
#include "armadillo_bits/spglue_plus_bones.hpp"
#include "armadillo_bits/spglue_minus_bones.hpp"
@@ -284,6 +287,7 @@
#include "armadillo_bits/mtOp_meat.hpp"
#include "armadillo_bits/mtOpCube_meat.hpp"
+ #include "armadillo_bits/mtSpOp_meat.hpp"
#include "armadillo_bits/Glue_meat.hpp"
#include "armadillo_bits/GlueCube_meat.hpp"
@@ -518,6 +522,8 @@
#include "armadillo_bits/spop_strans_meat.hpp"
#include "armadillo_bits/spop_htrans_meat.hpp"
#include "armadillo_bits/spop_misc_meat.hpp"
+ #include "armadillo_bits/spop_mean_meat.hpp"
+ #include "armadillo_bits/spop_var_meat.hpp"
#include "armadillo_bits/spglue_plus_meat.hpp"
#include "armadillo_bits/spglue_minus_meat.hpp"
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp 2012-12-07 12:30:59 UTC (rev 4110)
@@ -45,8 +45,9 @@
inline Col(const std::initializer_list<eT>& list);
inline const Col& operator=(const std::initializer_list<eT>& list);
#endif
+
+ inline explicit Col(const SpCol<eT>& X);
-
inline const Col& operator=(const eT val);
template<typename T1> inline Col(const Base<eT,T1>& X);
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp 2012-12-07 12:30:59 UTC (rev 4110)
@@ -218,6 +218,21 @@
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);
+ }
+
+
+
+template<typename eT>
+inline
const Col<eT>&
Col<eT>::operator=(const eT val)
{
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp 2012-12-07 12:30:59 UTC (rev 4110)
@@ -247,39 +247,59 @@
void
Cube<eT>::init
(
- const BaseCube<typename Cube<eT>::pod_type,T1>& A,
- const BaseCube<typename Cube<eT>::pod_type,T2>& B
+ const BaseCube<typename Cube<eT>::pod_type,T1>& X,
+ const BaseCube<typename Cube<eT>::pod_type,T2>& Y
)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type T;
- typedef typename ProxyCube<T1>::ea_type ea_type1;
- typedef typename ProxyCube<T2>::ea_type ea_type2;
arma_type_check(( is_complex<eT>::value == false )); //!< compile-time abort if eT isn't std::complex
arma_type_check(( is_complex< T>::value == true )); //!< compile-time abort if T is std::complex
arma_type_check(( is_same_type< std::complex<T>, eT >::value == false )); //!< compile-time abort if types are not compatible
- const ProxyCube<T1> X(A.get_ref());
- const ProxyCube<T2> Y(B.get_ref());
+ const ProxyCube<T1> PX(X.get_ref());
+ const ProxyCube<T2> PY(Y.get_ref());
- arma_assert_same_size(X, Y, "Cube()");
+ arma_assert_same_size(PX, PY, "Cube()");
- init_warm(X.get_n_rows(), X.get_n_cols(), X.get_n_slices());
+ const uword local_n_rows = PX.get_n_rows();
+ const uword local_n_cols = PX.get_n_cols();
+ const uword local_n_slices = PX.get_n_slices();
- const uword N = n_elem;
- eT* out_mem = memptr();
- ea_type1 PX = X.get_ea();
- ea_type2 PY = Y.get_ea();
+ init_warm(local_n_rows, local_n_cols, local_n_slices);
- // TODO: add handling for prefer_at_accessor = true
+ eT* out_mem = (*this).memptr();
- for(uword i=0; i<N; ++i)
+ const bool prefer_at_accessor = ( ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor );
+
+ if(prefer_at_accessor == false)
{
- out_mem[i] = std::complex<T>(PX[i], PY[i]);
+ typedef typename ProxyCube<T1>::ea_type ea_type1;
+ typedef typename ProxyCube<T2>::ea_type ea_type2;
+
+ const uword N = n_elem;
+
+ ea_type1 A = PX.get_ea();
+ ea_type2 B = PY.get_ea();
+
+ for(uword i=0; i<N; ++i)
+ {
+ out_mem[i] = std::complex<T>(A[i], B[i]);
+ }
}
+ else
+ {
+ for(uword uslice = 0; uslice < local_n_slices; ++uslice)
+ for(uword ucol = 0; ucol < local_n_cols; ++ucol )
+ for(uword urow = 0; urow < local_n_rows; ++urow )
+ {
+ *out_mem = std::complex<T>( PX.at(urow,ucol,uslice), PY.at(urow,ucol,uslice) );
+ out_mem++;
+ }
+ }
}
@@ -3301,29 +3321,47 @@
{
arma_extra_debug_sigprint();
- typedef typename std::complex<T> eT;
- typedef typename ProxyCube<T1>::ea_type ea_type;
+ typedef typename std::complex<T> eT;
- const ProxyCube<T1> A(X.get_ref());
+ const ProxyCube<T1> P(X.get_ref());
+ const uword local_n_rows = P.get_n_rows();
+ const uword local_n_cols = P.get_n_cols();
+ const uword local_n_slices = P.get_n_slices();
+
arma_debug_assert_same_size
(
- out.n_rows, out.n_cols, out.n_slices,
- A.get_n_rows(), A.get_n_cols(), A.get_n_slices(),
+ out.n_rows, out.n_cols, out.n_slices,
+ local_n_rows, local_n_cols, local_n_slices,
"Cube::set_real()"
);
- const uword n_elem = out.n_elem;
- eT* out_mem = out.memptr();
- ea_type PA = A.get_ea();
+ eT* out_mem = out.memptr();
- // TODO: add handling for prefer_at_accessor = true
-
- for(uword i=0; i<n_elem; ++i)
+ if(ProxyCube<T1>::prefer_at_accessor == false)
{
- //out_mem[i].real() = PA[i];
- out_mem[i] = std::complex<T>( PA[i], out_mem[i].imag() );
+ typedef typename ProxyCube<T1>::ea_type ea_type;
+
+ ea_type A = P.get_ea();
+
+ const uword N = out.n_elem;
+
+ for(uword i=0; i<N; ++i)
+ {
+ //out_mem[i].real() = PA[i];
+ out_mem[i] = std::complex<T>( A[i], out_mem[i].imag() );
+ }
}
+ else
+ {
+ for(uword slice = 0; slice < local_n_slices; ++slice)
+ for(uword col = 0; col < local_n_cols; ++col )
+ for(uword row = 0; row < local_n_rows; ++row )
+ {
+ (*out_mem) = std::complex<T>( P.at(row,col,slice), (*out_mem).imag() );
+ out_mem++;
+ }
+ }
}
@@ -3335,29 +3373,47 @@
{
arma_extra_debug_sigprint();
- typedef typename std::complex<T> eT;
- typedef typename ProxyCube<T1>::ea_type ea_type;
+ typedef typename std::complex<T> eT;
- const ProxyCube<T1> A(X.get_ref());
+ const ProxyCube<T1> P(X.get_ref());
+ const uword local_n_rows = P.get_n_rows();
+ const uword local_n_cols = P.get_n_cols();
+ const uword local_n_slices = P.get_n_slices();
+
arma_debug_assert_same_size
(
- out.n_rows, out.n_cols, out.n_slices,
- A.get_n_rows(), A.get_n_cols(), A.get_n_slices(),
+ out.n_rows, out.n_cols, out.n_slices,
+ local_n_rows, local_n_cols, local_n_slices,
"Cube::set_imag()"
);
- const uword n_elem = out.n_elem;
- eT* out_mem = out.memptr();
- ea_type PA = A.get_ea();
+ eT* out_mem = out.memptr();
- // TODO: add handling for prefer_at_accessor = true
-
- for(uword i=0; i<n_elem; ++i)
+ if(ProxyCube<T1>::prefer_at_accessor == false)
{
- //out_mem[i].imag() = PA[i];
- out_mem[i] = std::complex<T>( out_mem[i].real(), PA[i] );
+ typedef typename ProxyCube<T1>::ea_type ea_type;
+
+ ea_type A = P.get_ea();
+
+ const uword N = out.n_elem;
+
+ for(uword i=0; i<N; ++i)
+ {
+ //out_mem[i].imag() = PA[i];
+ out_mem[i] = std::complex<T>( out_mem[i].real(), A[i] );
+ }
}
+ else
+ {
+ for(uword slice = 0; slice < local_n_slices; ++slice)
+ for(uword col = 0; col < local_n_cols; ++col )
+ for(uword row = 0; row < local_n_rows; ++row )
+ {
+ (*out_mem) = std::complex<T>( (*out_mem).real(), P.at(row,col,slice) );
+ out_mem++;
+ }
+ }
}
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2012-12-07 12:30:59 UTC (rev 4110)
@@ -705,12 +705,11 @@
}
else
{
- uword ii = 0;
-
for(uword ucol=0; ucol < local_n_cols; ++ucol)
- for(uword urow=0; urow < local_n_rows; ++urow, ++ii)
+ for(uword urow=0; urow < local_n_rows; ++urow)
{
- out_mem[ii] = std::complex<T>(PX.at(urow,ucol), PY.at(urow,ucol));
+ *out_mem = std::complex<T>(PX.at(urow,ucol), PY.at(urow,ucol));
+ out_mem++;
}
}
}
@@ -6516,12 +6515,11 @@
}
else
{
- uword i = 0;
-
for(uword col=0; col < local_n_cols; ++col)
- for(uword row=0; row < local_n_rows; ++row, ++i)
+ for(uword row=0; row < local_n_rows; ++row)
{
- out_mem[i] = std::complex<T>( P.at(row,col), out_mem[i].imag());
+ (*out_mem) = std::complex<T>( P.at(row,col), (*out_mem).imag() );
+ out_mem++;
}
}
}
@@ -6561,12 +6559,11 @@
}
else
{
- uword i = 0;
-
for(uword col=0; col < local_n_cols; ++col)
- for(uword row=0; row < local_n_rows; ++row, ++i)
+ for(uword row=0; row < local_n_rows; ++row)
{
- out_mem[i] = std::complex<T>( out_mem[i].real(), P.at(row,col) );
+ (*out_mem) = std::complex<T>( (*out_mem).real(), P.at(row,col) );
+ out_mem++;
}
}
}
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp 2012-12-07 12:30:59 UTC (rev 4110)
@@ -46,6 +46,7 @@
inline const Row& operator=(const std::initializer_list<eT>& list);
#endif
+ inline explicit Row(const SpRow<eT>& X);
inline const Row& operator=(const eT val);
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp 2012-12-07 12:30:59 UTC (rev 4110)
@@ -184,6 +184,21 @@
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);
+ }
+
+
+
+template<typename eT>
+inline
const Row<eT>&
Row<eT>::operator=(const eT val)
{
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpGlue_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpGlue_bones.hpp 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpGlue_bones.hpp 2012-12-07 12:30:59 UTC (rev 4110)
@@ -23,12 +23,9 @@
typedef typename T1::elem_type elem_type;
typedef typename get_pod_type<elem_type>::result pod_type;
- //static const bool is_row = (is_same_type<spglue_type, spglue_times>::value) ? T1::is_row : false;
- //static const bool is_col = (is_same_type<spglue_type, spglue_times>::value) ? T2::is_col : false;
+ static const bool is_row = ( (T1::is_row || T2::is_row) && is_spglue_elem<spglue_type>::value ) || ( (is_spglue_times<spglue_type>::value || is_spglue_times2<spglue_type>::value) ? T1::is_row : false );
+ static const bool is_col = ( (T1::is_col || T2::is_col) && is_spglue_elem<spglue_type>::value ) || ( (is_spglue_times<spglue_type>::value || is_spglue_times2<spglue_type>::value) ? T2::is_col : false );
- static const bool is_row = false;
- static const bool is_col = false;
-
arma_inline SpGlue(const T1& in_A, const T2& in_B);
arma_inline SpGlue(const T1& in_A, const T2& in_B, const elem_type in_aux);
arma_inline ~SpGlue();
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_bones.hpp 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_bones.hpp 2012-12-07 12:30:59 UTC (rev 4110)
@@ -140,6 +140,15 @@
template<typename T1, typename T2, typename spglue_type> inline const SpMat& operator*=(const SpGlue<T1, T2, spglue_type>& X);
template<typename T1, typename T2, typename spglue_type> inline const SpMat& operator%=(const SpGlue<T1, T2, spglue_type>& X);
template<typename T1, typename T2, typename spglue_type> inline const SpMat& operator/=(const SpGlue<T1, T2, spglue_type>& X);
+
+ // delayed mixted-type unary ops
+ template<typename T1, typename spop_type> inline SpMat(const mtSpOp<eT, T1, spop_type>& X);
+ template<typename T1, typename spop_type> inline const SpMat& operator=(const mtSpOp<eT, T1, spop_type>& X);
+ template<typename T1, typename spop_type> inline const SpMat& operator+=(const mtSpOp<eT, T1, spop_type>& X);
+ template<typename T1, typename spop_type> inline const SpMat& operator-=(const mtSpOp<eT, T1, spop_type>& X);
+ template<typename T1, typename spop_type> inline const SpMat& operator*=(const mtSpOp<eT, T1, spop_type>& X);
+ template<typename T1, typename spop_type> inline const SpMat& operator%=(const mtSpOp<eT, T1, spop_type>& X);
+ template<typename T1, typename spop_type> inline const SpMat& operator/=(const mtSpOp<eT, T1, spop_type>& X);
/**
* Submatrix methods.
@@ -289,7 +298,27 @@
inline arma_warn_unused eT max() const;
inline eT max(uword& index_of_max_val) const;
inline eT max(uword& row_of_min_val, uword& col_of_min_val) const;
-
+
+
+ // saving and loading
+
+ 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;
+
+ inline bool load(const std::string name, const file_type type = arma_binary, const bool print_status = true);
+ inline bool load( std::istream& is, const file_type type = arma_binary, const bool print_status = true);
+
+ inline bool quiet_save(const std::string name, const file_type type = arma_binary) const;
+ inline bool quiet_save( std::ostream& os, const file_type type = arma_binary) const;
+
+ inline bool quiet_load(const std::string name, const file_type type = arma_binary);
+ inline bool quiet_load( std::istream& is, const file_type type = arma_binary);
+
+ // TODO: speed up loading of sparse matrices stored as text files (ie. raw_ascii and coord_ascii)
+ // TODO: implement auto_detect for sparse matrices
+ // TODO: modify docs to specify which formats are not applicable to sparse matrices
+
+
// These forward declarations are necessary.
class iterator_base;
class iterator;
@@ -297,9 +326,8 @@
class row_iterator;
class const_row_iterator;
- // Iterator base provides comparison operators but not the actual logic on how
- // to iterate. The validity of the position is not checked (that is left up
- // to the user).
+ // Iterator base provides basic operators but not how to compare or how to
+ // iterate.
class iterator_base
{
public:
@@ -308,12 +336,6 @@
inline iterator_base(const SpMat& in_M, const uword col, const uword pos);
inline arma_hot eT operator*() const;
-
- inline arma_hot bool operator==(const iterator_base& rhs) const;
- inline arma_hot bool operator!=(const iterator_base& rhs) const;
-
- inline arma_hot bool operator==(const typename SpSubview<eT>::iterator_base& rhs) const;
- inline arma_hot bool operator!=(const typename SpSubview<eT>::iterator_base& rhs) const;
// Don't hold location internally; call "dummy" methods to get that information.
arma_inline uword row() const { return M.row_indices[internal_pos]; }
@@ -323,6 +345,13 @@
arma_aligned const SpMat& M;
arma_aligned uword internal_col;
arma_aligned uword internal_pos;
+
+ // So that we satisfy the STL iterator types.
+ typedef std::bidirectional_iterator_tag iterator_category;
+ typedef eT value_type;
+ typedef uword difference_type; // not certain on this one
+ typedef const eT* pointer;
+ typedef const eT& reference;
};
class const_iterator : public iterator_base
@@ -337,10 +366,22 @@
inline const_iterator(const const_iterator& other);
inline arma_hot const_iterator& operator++();
- inline arma_hot void operator++(int);
+ inline arma_hot const_iterator operator++(int);
inline arma_hot const_iterator& operator--();
- inline arma_hot void operator--(int);
+ inline arma_hot const_iterator operator--(int);
+
+ inline arma_hot bool operator==(const const_iterator& rhs) const;
+ inline arma_hot bool operator!=(const const_iterator& rhs) const;
+
+ inline arma_hot bool operator==(const typename SpSubview<eT>::const_iterator& rhs) const;
+ inline arma_hot bool operator!=(const typename SpSubview<eT>::const_iterator& rhs) const;
+
+ inline arma_hot bool operator==(const const_row_iterator& rhs) const;
+ inline arma_hot bool operator!=(const const_row_iterator& rhs) const;
+
+ inline arma_hot bool operator==(const typename SpSubview<eT>::const_row_iterator& rhs) const;
+ inline arma_hot bool operator!=(const typename SpSubview<eT>::const_row_iterator& rhs) const;
};
/**
@@ -362,10 +403,15 @@
// overloads needed for return type correctness
inline arma_hot iterator& operator++();
- inline arma_hot void operator++(int);
+ inline arma_hot iterator operator++(int);
inline arma_hot iterator& operator--();
- inline arma_hot void operator--(int);
+ inline arma_hot iterator operator--(int);
+
+ // This has a different value_type than iterator_base.
+ typedef SpValProxy<SpMat<eT> > value_type;
+ typedef const SpValProxy<SpMat<eT> >* pointer;
+ typedef const SpValProxy<SpMat<eT> >& reference;
};
class const_row_iterator : public iterator_base
@@ -378,10 +424,10 @@
inline const_row_iterator(const const_row_iterator& other);
inline arma_hot const_row_iterator& operator++();
- inline arma_hot void operator++(int);
+ inline arma_hot const_row_iterator operator++(int);
inline arma_hot const_row_iterator& operator--();
- inline arma_hot void operator--(int);
+ inline arma_hot const_row_iterator operator--(int);
uword internal_row; // Hold row internally because we use internal_pos differently.
uword actual_pos; // Actual position in matrix.
@@ -389,6 +435,18 @@
arma_inline eT operator*() const { return iterator_base::M.values[actual_pos]; }
arma_inline uword row() const { return internal_row; }
+
+ inline arma_hot bool operator==(const const_iterator& rhs) const;
+ inline arma_hot bool operator!=(const const_iterator& rhs) const;
+
+ inline arma_hot bool operator==(const typename SpSubview<eT>::const_iterator& rhs) const;
+ inline arma_hot bool operator!=(const typename SpSubview<eT>::const_iterator& rhs) const;
+
+ inline arma_hot bool operator==(const const_row_iterator& rhs) const;
+ inline arma_hot bool operator!=(const const_row_iterator& rhs) const;
+
+ inline arma_hot bool operator==(const typename SpSubview<eT>::const_row_iterator& rhs) const;
+ inline arma_hot bool operator!=(const typename SpSubview<eT>::const_row_iterator& rhs) const;
};
class row_iterator : public const_row_iterator
@@ -404,10 +462,15 @@
// overloads required for return type correctness
inline arma_hot row_iterator& operator++();
- inline arma_hot void operator++(int);
+ inline arma_hot row_iterator operator++(int);
inline arma_hot row_iterator& operator--();
- inline arma_hot void operator--(int);
+ inline arma_hot row_iterator operator--(int);
+
+ // This has a different value_type than iterator_base.
+ typedef SpValProxy<SpMat<eT> > value_type;
+ typedef const SpValProxy<SpMat<eT> >* pointer;
+ typedef const SpValProxy<SpMat<eT> >& reference;
};
inline iterator begin();
@@ -443,9 +506,14 @@
*/
inline void mem_resize(const uword new_n_nonzero);
- inline void steal_mem(SpMat& X); //!< don't use this unless you're writing internal Armadillo code
+ //! don't use this unless you're writing internal Armadillo code
+ inline void steal_mem(SpMat& X);
+ //! don't use this unless you're writing internal Armadillo code
+ template< typename T1, typename Functor> arma_hot inline void init_xform (const SpBase<eT, T1>& x, const Functor& func);
+ template<typename eT2, typename T1, typename Functor> arma_hot inline void init_xform_mt(const SpBase<eT2,T1>& x, const Functor& func);
+
protected:
/**
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp 2012-12-06 20:15:48 UTC (rev 4109)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp 2012-12-07 12:30:59 UTC (rev 4110)
@@ -53,50 +53,6 @@
-template<typename eT>
-inline
-arma_hot
-bool
-SpMat<eT>::iterator_base::operator==(const iterator_base& rhs) const
- {
- return (rhs.row() == row()) && (rhs.col() == internal_col);
- }
-
-
-
-template<typename eT>
-inline
-arma_hot
-bool
-SpMat<eT>::iterator_base::operator!=(const iterator_base& rhs) const
- {
- return (rhs.row() != row()) || (rhs.col() != internal_col);
- }
-
-
-
-template<typename eT>
-inline
-arma_hot
-bool
-SpMat<eT>::iterator_base::operator==(const typename SpSubview<eT>::iterator_base& rhs) const
- {
- return (rhs.row() == row()) && (rhs.col() == internal_col);
- }
-
-
-
-template<typename eT>
-inline
-arma_hot
-bool
-SpMat<eT>::iterator_base::operator!=(const typename SpSubview<eT>::iterator_base& rhs) const
- {
- return (rhs.row() != row()) || (rhs.col() != internal_col);
- }
-
-
-
///////////////////////////////////////////////////////////////////////////////
// SpMat::const_iterator implementation //
///////////////////////////////////////////////////////////////////////////////
@@ -193,10 +149,14 @@
template<typename eT>
inline
arma_hot
-void
+typename SpMat<eT>::const_iterator
SpMat<eT>::const_iterator::operator++(int)
{
+ typename SpMat<eT>::const_iterator tmp(*this);
+
++(*this);
+
+ return tmp;
}
@@ -232,14 +192,106 @@
template<typename eT>
inline
arma_hot
-void
+typename SpMat<eT>::const_iterator
SpMat<eT>::const_iterator::operator--(int)
{
+ typename SpMat<eT>::const_iterator tmp(*this);
+
--(*this);
+
+ return tmp;
}
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_iterator::operator==(const const_iterator& rhs) const
+ {
+ return (rhs.row() == (*this).row()) && (rhs.col() == iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_iterator::operator!=(const const_iterator& rhs) const
+ {
+ return (rhs.row() != (*this).row()) || (rhs.col() != iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_iterator::operator==(const typename SpSubview<eT>::const_iterator& rhs) const
+ {
+ return (rhs.row() == (*this).row()) && (rhs.col() == iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_iterator::operator!=(const typename SpSubview<eT>::const_iterator& rhs) const
+ {
+ return (rhs.row() != (*this).row()) || (rhs.col() != iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_iterator::operator==(const const_row_iterator& rhs) const
+ {
+ return (rhs.row() == (*this).row()) && (rhs.col() == iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_iterator::operator!=(const const_row_iterator& rhs) const
+ {
+ return (rhs.row() != (*this).row()) || (rhs.col() != iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_iterator::operator==(const typename SpSubview<eT>::const_row_iterator& rhs) const
+ {
+ return (rhs.row() == (*this).row()) && (rhs.col() == iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_iterator::operator!=(const typename SpSubview<eT>::const_row_iterator& rhs) const
+ {
+ return (rhs.row() != (*this).row()) || (rhs.col() != iterator_base::internal_col);
+ }
+
+
+
///////////////////////////////////////////////////////////////////////////////
// SpMat::iterator implementation //
///////////////////////////////////////////////////////////////////////////////
@@ -274,10 +326,14 @@
template<typename eT>
inline
arma_hot
-void
+typename SpMat<eT>::iterator
SpMat<eT>::iterator::operator++(int)
{
+ typename SpMat<eT>::iterator tmp(*this);
+
const_iterator::operator++();
+
+ return tmp;
}
@@ -297,10 +353,14 @@
template<typename eT>
inline
arma_hot
-void
+typename SpMat<eT>::iterator
SpMat<eT>::iterator::operator--(int)
{
+ typename SpMat<eT>::iterator tmp(*this);
+
const_iterator::operator--();
+
+ return tmp;
}
@@ -322,7 +382,8 @@
// Corner case for empty matrix.
if(in_M.n_nonzero == 0)
{
- iterator_base::internal_col = in_M.n_cols;
+ iterator_base::internal_col = 0;
+ internal_row = in_M.n_rows;
return;
}
@@ -476,10 +537,14 @@
template<typename eT>
inline
arma_hot
-void
+typename SpMat<eT>::const_row_iterator
SpMat<eT>::const_row_iterator::operator++(int)
{
+ typename SpMat<eT>::const_row_iterator tmp(*this);
+
++(*this);
+
+ return tmp;
}
@@ -532,12 +597,106 @@
template<typename eT>
inline
arma_hot
-void
+typename SpMat<eT>::const_row_iterator
SpMat<eT>::const_row_iterator::operator--(int)
{
+ typename SpMat<eT>::const_row_iterator tmp(*this);
+
--(*this);
+
+ return tmp;
}
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_row_iterator::operator==(const const_iterator& rhs) const
+ {
+ return (rhs.row() == row()) && (rhs.col() == iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_row_iterator::operator!=(const const_iterator& rhs) const
+ {
+ return (rhs.row() != row()) || (rhs.col() != iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_row_iterator::operator==(const typename SpSubview<eT>::const_iterator& rhs) const
+ {
+ return (rhs.row() == row()) && (rhs.col() == iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_row_iterator::operator!=(const typename SpSubview<eT>::const_iterator& rhs) const
+ {
+ return (rhs.row() != row()) || (rhs.col() != iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_row_iterator::operator==(const const_row_iterator& rhs) const
+ {
+ return (rhs.row() == row()) && (rhs.col() == iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_row_iterator::operator!=(const const_row_iterator& rhs) const
+ {
+ return (rhs.row() != row()) || (rhs.col() != iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_row_iterator::operator==(const typename SpSubview<eT>::const_row_iterator& rhs) const
+ {
+ return (rhs.row() == row()) && (rhs.col() == iterator_base::internal_col);
+ }
+
+
+
+template<typename eT>
+inline
+arma_hot
+bool
+SpMat<eT>::const_row_iterator::operator!=(const typename SpSubview<eT>::const_row_iterator& rhs) const
+ {
+ return (rhs.row() != row()) || (rhs.col() != iterator_base::internal_col);
+ }
+
+
+
///////////////////////////////////////////////////////////////////////////////
// SpMat::row_iterator implementation //
///////////////////////////////////////////////////////////////////////////////
@@ -572,10 +731,14 @@
template<typename eT>
inline
arma_hot
-void
+typename SpMat<eT>::row_iterator
SpMat<eT>::row_iterator::operator++(int)
{
+ typename SpMat<eT>::row_iterator tmp(*this);
+
const_row_iterator::operator++();
+
+ return tmp;
}
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/rcpp -r 4110
More information about the Rcpp-commits
mailing list