[Rcpp-commits] r3765 - in pkg/RcppArmadillo: . inst inst/include/armadillo_bits man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 6 13:13:48 CEST 2012


Author: edd
Date: 2012-09-06 13:13:48 +0200 (Thu, 06 Sep 2012)
New Revision: 3765

Modified:
   pkg/RcppArmadillo/ChangeLog
   pkg/RcppArmadillo/DESCRIPTION
   pkg/RcppArmadillo/inst/NEWS.Rd
   pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.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/SpCol_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/SpCol_meat.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/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/SpValProxy_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/SpValProxy_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/access.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/arma_config.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/config.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/fn_conv_to.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_elem.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/operator_div.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/operator_minus.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/operator_plus.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/operator_schur.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/operator_times.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/subview_elem2_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_elem2_meat.hpp
   pkg/RcppArmadillo/man/RcppArmadillo-package.Rd
Log:
Release 0.3.4.0 with Armadillo 3.4.0


Modified: pkg/RcppArmadillo/ChangeLog
===================================================================
--- pkg/RcppArmadillo/ChangeLog	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/ChangeLog	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,3 +1,9 @@
+2012-09-06  Dirk Eddelbuettel  <edd at debian.org>
+
+	* DESCRIPTION: Release 0.3.4.0
+
+	* inst/include/*: Upgraded to new release 3.4.0 of Armadillo
+
 2012-08-31  Dirk Eddelbuettel  <edd at debian.org>
 
 	* inst/NEWS.Rd: Converted to Rd format

Modified: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/DESCRIPTION	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,7 +1,7 @@
 Package: RcppArmadillo
 Type: Package
 Title: Rcpp integration for Armadillo templated linear algebra library
-Version: 0.3.3.91
+Version: 0.3.4.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.3.19). Thus users do not need to
+ Armadillo library (currently version 3.4.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-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/NEWS.Rd	2012-09-06 11:13:48 UTC (rev 3765)
@@ -2,8 +2,16 @@
 \title{News for Package 'RcppArmadillo'}
 \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
 
-\section{Changes in RcppArmadillo version 0.3.x.yy (2012-09-zz)}{
+\section{Changes in RcppArmadillo version 0.3.4.0 (2012-09-06)}{
   \itemize{
+    \item Upgraded to Armadillo release 3.4.0 (Ku De Ta)
+    \itemize{
+      \item added economical QR decomposition: qr_econ()
+      \item added .each_col() & .each_row() for vector operations repeated on each column or row
+      \item added preliminary support for sparse matrices, contributed by Ryan Curtin et al. (Georgia Institute of Technology)
+      \item faster singular value decomposition via divide-and-conquer algorithm
+      \item faster .randn()
+    }
     \item NEWS file converted to Rd format
   }
 }

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -38,6 +38,9 @@
   inline                  Col(const std::string& text);
   inline const Col& operator=(const std::string& text);
   
+  inline                  Col(const std::vector<eT>& x);
+  inline const Col& operator=(const std::vector<eT>& x);
+  
   #if defined(ARMA_USE_CXX11)
   inline                  Col(const std::initializer_list<eT>& list);
   inline const Col& operator=(const std::initializer_list<eT>& list);

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -139,6 +139,42 @@
 
 
 
+//! create a column vector from std::vector
+template<typename eT>
+inline
+Col<eT>::Col(const std::vector<eT>& x)
+  : Mat<eT>(arma_vec_indicator(), uword(x.size()), 1, 1)
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  if(x.size() > 0)
+    {
+    arrayops::copy( Mat<eT>::memptr(), &(x[0]), uword(x.size()) );
+    }
+  }
+  
+  
+  
+//! create a column vector from std::vector
+template<typename eT>
+inline
+const Col<eT>&
+Col<eT>::operator=(const std::vector<eT>& x)
+  {
+  arma_extra_debug_sigprint();
+  
+  Mat<eT>::init_warm(uword(x.size()), 1);
+  
+  if(x.size() > 0)
+    {
+    arrayops::copy( Mat<eT>::memptr(), &(x[0]), uword(x.size()) );
+    }
+  
+  return *this;
+  }
+
+
+
 #if defined(ARMA_USE_CXX11)
   
   template<typename eT>

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,5 +1,6 @@
 // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
 // Copyright (C) 2008-2012 Conrad Sanderson
+// Copyright (C) 2012 Ryan Curtin
 // 
 // This file is part of the Armadillo C++ library.
 // It is provided without any warranty of fitness
@@ -60,6 +61,9 @@
   inline                  Mat(const std::string& text);
   inline const Mat& operator=(const std::string& text);
   
+  inline                  Mat(const std::vector<eT>& x);
+  inline const Mat& operator=(const std::vector<eT>& x);
+  
   #if defined(ARMA_USE_CXX11)
   inline                  Mat(const std::initializer_list<eT>& list);
   inline const Mat& operator=(const std::initializer_list<eT>& list);

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,5 +1,6 @@
 // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
 // Copyright (C) 2008-2012 Conrad Sanderson
+// Copyright (C) 2012 Ryan Curtin
 // 
 // This file is part of the Armadillo C++ library.
 // It is provided without any warranty of fitness
@@ -439,6 +440,49 @@
 
 
 
+//! create the matrix from std::vector
+template<typename eT>
+inline
+Mat<eT>::Mat(const std::vector<eT>& x)
+  : n_rows(uword(x.size()))
+  , n_cols(1)
+  , n_elem(uword(x.size()))
+  , vec_state(0)
+  , mem_state(0)
+  , mem()
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  init_cold();
+  
+  if(n_elem > 0)
+    {
+    arrayops::copy( memptr(), &(x[0]), n_elem );
+    }
+  }
+  
+  
+  
+//! create the matrix from std::vector
+template<typename eT>
+inline
+const Mat<eT>&
+Mat<eT>::operator=(const std::vector<eT>& x)
+  {
+  arma_extra_debug_sigprint();
+  
+  init_warm(uword(x.size()), 1);
+  
+  if(x.size() > 0)
+    {
+    arrayops::copy( memptr(), &(x[0]), uword(x.size()) );
+    }
+  
+  return *this;
+  }
+
+
+
 #if defined(ARMA_USE_CXX11)
   
   template<typename eT>

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -38,6 +38,9 @@
   inline                  Row(const std::string& text);
   inline const Row& operator=(const std::string& text);
   
+  inline                  Row(const std::vector<eT>& x);
+  inline const Row& operator=(const std::vector<eT>& x);
+  
   #if defined(ARMA_USE_CXX11)
   inline                  Row(const std::initializer_list<eT>& list);
   inline const Row& operator=(const std::initializer_list<eT>& list);

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -115,6 +115,42 @@
 
 
 
+//! create a row vector from std::vector
+template<typename eT>
+inline
+Row<eT>::Row(const std::vector<eT>& x)
+  : Mat<eT>(arma_vec_indicator(), 1, uword(x.size()), 2)
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  if(x.size() > 0)
+    {
+    arrayops::copy( Mat<eT>::memptr(), &(x[0]), uword(x.size()) );
+    }
+  }
+  
+  
+  
+//! create a row vector from std::vector
+template<typename eT>
+inline
+const Row<eT>&
+Row<eT>::operator=(const std::vector<eT>& x)
+  {
+  arma_extra_debug_sigprint();
+  
+  Mat<eT>::init_warm(1, uword(x.size()));
+  
+  if(x.size() > 0)
+    {
+    arrayops::copy( Mat<eT>::memptr(), &(x[0]), uword(x.size()) );
+    }
+  
+  return *this;
+  }
+
+
+
 #if defined(ARMA_USE_CXX11)
   
   template<typename eT>

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpCol_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpCol_bones.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpCol_bones.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2012 Ryan Curtin <ryan at igglybob.com>
+// Copyright (C) 2011-2012 Ryan Curtin
 // Copyright (C) 2011 Matthew Amidon
 //
 // This file is part of the Armadillo C++ library.
@@ -43,11 +43,14 @@
   template<typename T1> inline                  SpCol(const Base<eT,T1>& X);
   template<typename T1> inline const SpCol& operator=(const Base<eT,T1>& X);
 
+  template<typename T1> inline                  SpCol(const SpBase<eT,T1>& X);
+  template<typename T1> inline const SpCol& operator=(const SpBase<eT,T1>& X);
+
   template<typename T1, typename T2>
-  inline explicit SpCol(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
+  inline explicit SpCol(const SpBase<pod_type,T1>& A, const SpBase<pod_type,T2>& B);
 
-  arma_inline SpValProxy<SpMat<eT> >& row(const uword row_num);
-  arma_inline eT                      row(const uword row_num) const;
+  inline SpValProxy<SpMat<eT> > row(const uword row_num);
+  inline eT                     row(const uword row_num) const;
 
 //  arma_inline       subview_col<eT> rows(const uword in_row1, const uword in_row2);
 //  arma_inline const subview_col<eT> rows(const uword in_row1, const uword in_row2) const;
@@ -61,8 +64,8 @@
   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);
+//                         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;

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpCol_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpCol_meat.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpCol_meat.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2012 Ryan Curtin <ryan at igglybob.com>
+// Copyright (C) 2011-2012 Ryan Curtin
 // Copyright (C) 2011 Matthew Amidon
 // 
 // This file is part of the Armadillo C++ library.
@@ -163,12 +163,43 @@
 
 
 template<typename eT>
+template<typename T1>
+inline
+SpCol<eT>::SpCol(const SpBase<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+
+  access::rw(SpMat<eT>::vec_state) = 1;
+
+  SpMat<eT>::operator=(X.get_ref());
+  }
+
+
+
+template<typename eT>
+template<typename T1>
+inline
+const SpCol<eT>&
+SpCol<eT>::operator=(const SpBase<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+
+  access::rw(SpMat<eT>::vec_state) = 1;
+
+  SpMat<eT>::operator=(X.get_ref());
+
+  return *this;
+  }
+
+
+
+template<typename eT>
 template<typename T1, typename T2>
 inline
 SpCol<eT>::SpCol
   (
-  const Base<typename SpCol<eT>::pod_type, T1>& A,
-  const Base<typename SpCol<eT>::pod_type, T2>& B
+  const SpBase<typename SpCol<eT>::pod_type, T1>& A,
+  const SpBase<typename SpCol<eT>::pod_type, T2>& B
   )
   {
   arma_extra_debug_sigprint();
@@ -181,8 +212,8 @@
 
 
 template<typename eT>
-arma_inline
-SpValProxy<SpMat<eT> >&
+inline
+SpValProxy< SpMat<eT> >
 SpCol<eT>::row(const uword row_num)
   {
   arma_debug_check( (row_num >= SpMat<eT>::n_rows), "SpCol::row(): out of bounds" );
@@ -193,7 +224,7 @@
 
 
 template<typename eT>
-arma_inline
+inline
 eT
 SpCol<eT>::row(const uword row_num) const
   {
@@ -409,50 +440,50 @@
 
 
 
-//! insert N rows at the specified row position,
-//! optionally setting the elements of the inserted rows to zero
-template<typename eT>
-inline
-void
-SpCol<eT>::insert_rows(const uword row_num, const uword N, const bool set_to_zero)
-  {
-  arma_extra_debug_sigprint();
+// //! insert N rows at the specified row position,
+// //! optionally setting the elements of the inserted rows to zero
+// template<typename eT>
+// inline
+// void
+// SpCol<eT>::insert_rows(const uword row_num, const uword N, const bool set_to_zero)
+//   {
+//   arma_extra_debug_sigprint();
+// 
+//   arma_debug_check(set_to_zero == false, "SpCol::insert_rows(): cannot set nonzero values");
+// 
+//   arma_debug_check((row_num > SpMat<eT>::n_rows), "SpCol::insert_rows(): out of bounds");
+// 
+//   for(uword row = 0; row < SpMat<eT>::n_rows; ++row)
+//     {
+//     if (SpMat<eT>::row_indices[row] >= row_num)
+//       {
+//       access::rw(SpMat<eT>::row_indices[row]) += N;
+//       }
+//     }
+// 
+//   access::rw(SpMat<eT>::n_rows) += N;
+//   access::rw(SpMat<eT>::n_elem) += N;
+//   }
+// 
+// 
+// 
+// //! insert the given object at the specified row position;
+// //! the given object must have one column
+// template<typename eT>
+// template<typename T1>
+// inline
+// void
+// SpCol<eT>::insert_rows(const uword row_num, const Base<eT,T1>& X)
+//   {
+//   arma_extra_debug_sigprint();
+// 
+//   SpMat<eT>::insert_rows(row_num, X);
+//   }
 
-  arma_debug_check(set_to_zero == false, "SpCol::insert_rows(): cannot set nonzero values");
 
-  arma_debug_check((row_num > SpMat<eT>::n_rows), "SpCol::insert_rows(): out of bounds");
 
-  for(uword row = 0; row < SpMat<eT>::n_rows; ++row)
-    {
-    if (SpMat<eT>::row_indices[row] >= row_num)
-      {
-      access::rw(SpMat<eT>::row_indices[row]) += N;
-      }
-    }
-
-  access::rw(SpMat<eT>::n_rows) += N;
-  access::rw(SpMat<eT>::n_elem) += N;
-  }
-
-
-
-//! insert the given object at the specified row position;
-//! the given object must have one column
 template<typename eT>
-template<typename T1>
 inline
-void
-SpCol<eT>::insert_rows(const uword row_num, const Base<eT,T1>& X)
-  {
-  arma_extra_debug_sigprint();
-
-  SpMat<eT>::insert_rows(row_num, X);
-  }
-
-
-
-template<typename eT>
-inline
 typename SpCol<eT>::row_iterator
 SpCol<eT>::begin_row(const uword row_num)
   {
@@ -506,8 +537,8 @@
   }
 
 
-#ifdef ARMA_EXTRA_COL_MEAT
-  #include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_MEAT)
+#ifdef ARMA_EXTRA_SPCOL_MEAT
+  #include ARMA_INCFILE_WRAP(ARMA_EXTRA_SPCOL_MEAT)
 #endif
 
 

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_bones.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_bones.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2012 Ryan Curtin <ryan at igglybob.com>
+// Copyright (C) 2011-2012 Ryan Curtin
 // Copyright (C) 2011 Matthew Amidon
 // Copyright (C) 2012 Conrad Sanderson
 //
@@ -14,7 +14,7 @@
 //! \addtogroup SpMat
 //! @{
 
-//! Sparse matrix class, which uses the compressed sparse column (CSC) format.  For external solvers we depend on GMM++.
+//! Sparse matrix class, with data stored in compressed sparse column (CSC) format
 
 template<typename eT>
 class SpMat : public SpBase< eT, SpMat<eT> >
@@ -507,4 +507,8 @@
 
 
 
+#define ARMA_HAS_SPMAT
+
+
+
 //! @}

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2012 Ryan Curtin <ryan at igglybob.com>
+// Copyright (C) 2011-2012 Ryan Curtin
 // Copyright (C) 2011 Matthew Amidon
 // Copyright (C) 2012 Conrad Sanderson
 //

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2012 Ryan Curtin <ryan at igglybob.com>
+// Copyright (C) 2011-2012 Ryan Curtin
 // Copyright (C) 2011 Matthew Amidon
 // Copyright (C) 2012 Conrad Sanderson
 //
@@ -302,11 +302,11 @@
   arma_extra_debug_sigprint();
   
   arma_debug_assert_mul_size(n_rows, n_cols, y.n_rows, y.n_cols, "matrix multiplication");
-
-  SpMat z;
+  
+  SpMat<eT> z;
   z = (*this) * y;
   steal_mem(z);
-
+  
   return *this;
   }
 
@@ -339,7 +339,7 @@
       x_it++;
       }
 
-    else if ((it.col() <= x_it.col()) && (it.row() < x_it.row()))
+    else if ((it.col() < x_it.col()) || ((it.col() == x_it.col()) && (it.row() < x_it.row())))
       {
       // This case is when our matrix has an element which the other matrix does not.
       // So we must delete this element.
@@ -520,33 +520,20 @@
   {
   //No easy init function, will have to generate matrix manually.
   arma_extra_debug_sigprint();
-
+  
   const Proxy<T1> p(x.get_ref());
   
   const uword x_n_rows = p.get_n_rows();
   const uword x_n_cols = p.get_n_cols();
-  const uword x_n_elem = p.get_n_elem();
   
   init(x_n_rows, x_n_cols);
-
-  if(Proxy<T1>::prefer_at_accessor == true)
+  
+  for(uword j = 0; j < x_n_cols; ++j)
+  for(uword i = 0; i < x_n_rows; ++i)
     {
-    for(uword j = 0; j < x_n_cols; ++j)
-      {
-        for(uword i = 0; i < x_n_rows; ++i)
-        {
-        at(i) = p.at(i, j); // Let the proxy handle 0's.
-        }
-      }
+    at(i,j) = p.at(i,j); // let SpValProxy handle 0's.
     }
-  else
-    {
-    for(uword i = 0; i < x_n_elem; ++i)
-      {
-      at(i) = p[i];
-      }
-    }
-
+  
   return *this;
   }
 
@@ -591,7 +578,7 @@
     last_index = index[last_index];
     }
 
-  SpMat z(n_rows, p.get_n_cols());
+  SpMat<eT> z(n_rows, p.get_n_cols());
 
   z.mem_resize(nonzero_rows * p.get_n_cols()); // upper bound on size
 
@@ -622,7 +609,7 @@
         access::rw(z.values[cur_pos]) = partial_sums[i];
         access::rw(z.row_indices[cur_pos]) = i;
         ++access::rw(z.col_ptrs[col + 1]);
-        printf("colptr %d now %d\n", col + 1, z.col_ptrs[col + 1]);
+        //printf("colptr %d now %d\n", col + 1, z.col_ptrs[col + 1]);
         ++cur_pos;
         partial_sums[i] = 0; // Would it be faster to do this in batch later?
         }
@@ -662,23 +649,11 @@
    */
   arma_debug_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(), "element-wise division");
   
-  if(Proxy<T1>::prefer_at_accessor == true)
+  for(uword j = 0; j < n_cols; j++)
+  for(uword i = 0; i < n_rows; i++)
     {
-    for(uword j = 0; j < n_cols; j++)
-      {
-      for(uword i = 0; i < n_rows; i++)
-        {
-        at(i, j) /= p.at(i, j);
-        }
-      }
+    at(i, j) /= p.at(i, j);
     }
-  else
-    {
-    for(uword i = 0; i < n_elem; ++i)
-      {
-      at(i) /= p[i];
-      }
-    }
   
   return *this;
   }
@@ -874,7 +849,7 @@
   arma_debug_assert_mul_size(n_rows, n_cols, y.n_rows, y.n_cols, "matrix multiplication");
   
   // Cannot be done in-place (easily).
-  SpMat z = (*this) * y;
+  SpMat<eT> z = (*this) * y;
   steal_mem(z);
   
   return *this;
@@ -1043,7 +1018,7 @@
 
   arma_debug_assert_mul_size(n_rows, n_cols, y.n_rows, y.n_cols, "matrix multiplication");
 
-  SpMat z(n_rows, y.n_cols);
+  SpMat<eT> z(n_rows, y.n_cols);
 
   // Performed in the same fashion as operator*=(SpMat).
   for (const_row_iterator x_row_it = begin_row(); x_row_it.pos() < n_nonzero; ++x_row_it)
@@ -1053,7 +1028,7 @@
       // At this moment in the loop, we are calculating anything that is contributed to by *x_row_it and *y_col_it.
       // Given that our position is x_ab and y_bc, there will only be a contribution if x.col == y.row, and that
       // contribution will be in location z_ac.
-      z(x_row_it.row, col) += (*x_row_it) * y.at(x_row_it.col, col);
+      z.at(x_row_it.row, col) += (*x_row_it) * y.at(x_row_it.col, col);
       }
     }
 

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpRow_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpRow_bones.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpRow_bones.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2012 Ryan Curtin <ryan at igglybob.com>
+// Copyright (C) 2011-2012 Ryan Curtin
 // Copyright (C) 2011 Matthew Amidon
 // 
 // This file is part of the Armadillo C++ library.
@@ -40,14 +40,17 @@
 
   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> inline                  SpRow(const Base<eT,T1>& X);
+  template<typename T1> inline const SpRow& operator=(const Base<eT,T1>& X);
 
+  template<typename T1> inline                  SpRow(const SpBase<eT,T1>& X);
+  template<typename T1> inline const SpRow& operator=(const SpBase<eT,T1>& X);
+  
   template<typename T1, typename T2>
-  inline explicit SpRow(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
+  inline explicit SpRow(const SpBase<pod_type,T1>& A, const SpBase<pod_type,T2>& B);
 
-  arma_inline SpValProxy<SpMat<eT> > col(const uword col_num);
-  arma_inline eT                     col(const uword col_num) const;
+  inline SpValProxy<SpMat<eT> > col(const uword col_num);
+  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;
@@ -64,8 +67,8 @@
   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);
+//                         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;
@@ -77,8 +80,8 @@
   inline       row_iterator end_row();
   inline const_row_iterator end_row() const;
   
-  #ifdef ARMA_EXTRA_ROW_PROTO
-    #include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_PROTO)
+  #ifdef ARMA_EXTRA_SPROW_PROTO
+    #include ARMA_INCFILE_WRAP(ARMA_EXTRA_SPROW_PROTO)
   #endif
   };
 

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpRow_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpRow_meat.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpRow_meat.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2012 Ryan Curtin <ryan at igglybob.com>
+// Copyright (C) 2011-2012 Ryan Curtin
 // Copyright (C) 2011 Matthew Amidon
 // 
 // This file is part of the Armadillo C++ library.
@@ -156,12 +156,41 @@
 
 
 template<typename eT>
+template<typename T1>
+inline
+SpRow<eT>::SpRow(const SpBase<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+
+  access::rw(SpMat<eT>::vec_state) = 2;
+  
+  SpMat<eT>::operator=(X.get_ref());
+  }
+
+
+
+template<typename eT>
+template<typename T1>
+inline
+const SpRow<eT>&
+SpRow<eT>::operator=(const SpBase<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+  
+  SpMat<eT>::operator=(X.get_ref());
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
 template<typename T1, typename T2>
 inline
 SpRow<eT>::SpRow
   (
-  const Base<typename SpRow<eT>::pod_type, T1>& A,
-  const Base<typename SpRow<eT>::pod_type, T2>& B
+  const SpBase<typename SpRow<eT>::pod_type, T1>& A,
+  const SpBase<typename SpRow<eT>::pod_type, T2>& B
   )
   {
   arma_extra_debug_sigprint();
@@ -174,8 +203,8 @@
 
 
 template<typename eT>
-arma_inline
-SpValProxy<SpMat<eT> >
+inline
+SpValProxy< SpMat<eT> >
 SpRow<eT>::col(const uword col_num)
   {
   arma_debug_check( (col_num >= SpMat<eT>::n_cols), "SpRow::col(): out of bounds" );
@@ -186,7 +215,7 @@
 
 
 template<typename eT>
-arma_inline
+inline
 eT
 SpRow<eT>::col(const uword col_num) const
   {
@@ -421,54 +450,54 @@
 
 
 
-//! insert N cols at the specified col position,
-//! optionally setting the elements of the inserted cols to zero
-template<typename eT>
-inline
-void
-SpRow<eT>::insert_cols(const uword col_num, const uword N, const bool set_to_zero)
-  {
-  arma_extra_debug_sigprint();
+// //! insert N cols at the specified col position,
+// //! optionally setting the elements of the inserted cols to zero
+// template<typename eT>
+// inline
+// void
+// SpRow<eT>::insert_cols(const uword col_num, const uword N, const bool set_to_zero)
+//   {
+//   arma_extra_debug_sigprint();
+// 
+//   // insertion at col_num == n_cols is in effect an append operation
+//   arma_debug_check( (col_num > SpMat<eT>::n_cols), "SpRow::insert_cols(): out of bounds");
+// 
+//   arma_debug_check( (set_to_zero == false), "SpRow::insert_cols(): cannot set elements to nonzero values");
+// 
+//   uword newVal = (col_num == 0) ? 0 : SpMat<eT>::col_ptrs[col_num];
+//   SpMat<eT>::col_ptrs.insert(col_num, N, newVal);
+//   uword* new_col_ptrs = memory::acquire<uword>(SpMat<eT>::n_cols + N);
+// 
+//   arrayops::copy(new_col_ptrs, SpMat<eT>::col_ptrs, col_num);
+// 
+//   uword fill_value = (col_num == 0) ? 0 : SpMat<eT>::col_ptrs[col_num - 1];
+//   arrayops::inplace_set(new_col_ptrs + col_num, fill_value, N);
+// 
+//   arrayops::copy(new_col_ptrs + col_num + N, SpMat<eT>::col_ptrs + col_num, SpMat<eT>::n_cols - col_num);
+// 
+//   access::rw(SpMat<eT>::n_cols) += N;
+//   access::rw(SpMat<eT>::n_elem) += N;
+//   }
+// 
+// 
+// 
+// //! insert the given object at the specified col position; 
+// //! the given object must have one row
+// template<typename eT>
+// template<typename T1>
+// inline
+// void
+// SpRow<eT>::insert_cols(const uword col_num, const Base<eT,T1>& X)
+//   {
+//   arma_extra_debug_sigprint();
+//   
+//   SpMat<eT>::insert_cols(col_num, X);
+//   }
 
-  // insertion at col_num == n_cols is in effect an append operation
-  arma_debug_check( (col_num > SpMat<eT>::n_cols), "SpRow::insert_cols(): out of bounds");
 
-  arma_debug_check( (set_to_zero == false), "SpRow::insert_cols(): cannot set elements to nonzero values");
 
-  uword newVal = (col_num == 0) ? 0 : SpMat<eT>::col_ptrs[col_num];
-  SpMat<eT>::col_ptrs.insert(col_num, N, newVal);
-  uword* new_col_ptrs = memory::acquire<uword>(SpMat<eT>::n_cols + N);
-
-  arrayops::copy(new_col_ptrs, SpMat<eT>::col_ptrs, col_num);
-
-  uword fill_value = (col_num == 0) ? 0 : SpMat<eT>::col_ptrs[col_num - 1];
-  arrayops::inplace_set(new_col_ptrs + col_num, fill_value, N);
-
-  arrayops::copy(new_col_ptrs + col_num + N, SpMat<eT>::col_ptrs + col_num, SpMat<eT>::n_cols - col_num);
-
-  access::rw(SpMat<eT>::n_cols) += N;
-  access::rw(SpMat<eT>::n_elem) += N;
-  }
-
-
-
-//! insert the given object at the specified col position; 
-//! the given object must have one row
 template<typename eT>
-template<typename T1>
 inline
-void
-SpRow<eT>::insert_cols(const uword col_num, const Base<eT,T1>& X)
-  {
-  arma_extra_debug_sigprint();
-  
-  SpMat<eT>::insert_cols(col_num, X);
-  }
-
-
-
-template<typename eT>
-inline
 typename SpRow<eT>::row_iterator
 SpRow<eT>::begin_row()
   {

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_bones.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_bones.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2012 Ryan Curtin <ryan at igglybob.com>
+// Copyright (C) 2011-2012 Ryan Curtin
 // Copyright (C) 2011 Matthew Amidon
 // Copyright (C) 2012 Conrad Sanderson
 //
@@ -81,20 +81,20 @@
   inline void ones();
   inline void eye();
 
-  inline SpValProxy<SpSubview<eT> > operator[](const uword i);
-  inline eT                         operator[](const uword i) const;
+  arma_hot inline SpValProxy<SpSubview<eT> > operator[](const uword i);
+  arma_hot inline eT                         operator[](const uword i) const;
 
-  inline SpValProxy<SpSubview<eT> > operator()(const uword i);
-  inline eT                         operator()(const uword i) const;
+  arma_hot inline SpValProxy<SpSubview<eT> > operator()(const uword i);
+  arma_hot inline eT                         operator()(const uword i) const;
 
-  inline SpValProxy<SpSubview<eT> > operator()(const uword in_row, const uword in_col);
-  inline eT                         operator()(const uword in_row, const uword in_col) const;
+  arma_hot inline SpValProxy<SpSubview<eT> > operator()(const uword in_row, const uword in_col);
+  arma_hot inline eT                         operator()(const uword in_row, const uword in_col) const;
 
-  inline SpValProxy<SpSubview<eT> > at(const uword i);
-  inline eT                         at(const uword i) const;
+  arma_hot inline SpValProxy<SpSubview<eT> > at(const uword i);
+  arma_hot inline eT                         at(const uword i) const;
 
-  inline SpValProxy<SpSubview<eT> > at(const uword in_row, const uword in_col);
-  inline eT                         at(const uword in_row, const uword in_col) const;
+  arma_hot inline SpValProxy<SpSubview<eT> > at(const uword in_row, const uword in_col);
+  arma_hot inline eT                         at(const uword in_row, const uword in_col) const;
 
   inline bool check_overlap(const SpSubview& x) const;
 

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_iterators_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_iterators_meat.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_iterators_meat.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Ryan Curtin <ryan at igglybob.com>
+// Copyright (C) 2012 Ryan Curtin
 // Copyright (C) 2012 Conrad Sanderson
 //
 // This file is part of the Armadillo C++ library.

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_meat.hpp	2012-09-03 16:13:14 UTC (rev 3764)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_meat.hpp	2012-09-06 11:13:48 UTC (rev 3765)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2012 Ryan Curtin <ryan at igglybob.com>
+// Copyright (C) 2011-2012 Ryan Curtin
 // Copyright (C) 2011 Matthew Amidon
 // Copyright (C) 2012 Conrad Sanderson
 //
@@ -12,6 +12,8 @@
 // (see http://www.opensource.org/licenses for more info)
 
 
+//! \addtogroup SpSubview
+//! @{
 
 template<typename eT>
 arma_inline
@@ -167,12 +169,10 @@
   if(val == eT(0))
     {
     // Turn it all into zeros.
-    for(typename SpMat<eT>::iterator it(access::rw(m), aux_row1, aux_col1); it.col() < (aux_col1 + n_cols); ++it)
+    for(iterator it(*this); it.pos() < n_nonzero; ++it)
       {
-      if((it.row() >= aux_row1) && (it.row() < (aux_row1 + n_cols)))
-        {
-        (*it) = eT(0); // zero out the value.
-        }
+      (*it) = eT(0); // zero out the value.
+      it.internal_pos--;
       }
 
     return *this;
@@ -265,7 +265,7 @@
 
   const Proxy<T1> P(x.get_ref());
 
-  arma_debug_assert_same_size(n_rows, n_cols, P.get_n_rows(), P.get_n_cols(), "addition into sparse submatrix");
+  arma_debug_assert_same_size(n_rows, n_cols, P.get_n_rows(), P.get_n_cols(), "addition");
 
   const uword old_n_nonzero = m.n_nonzero;
 
@@ -296,7 +296,7 @@
 
   const Proxy<T1> P(x.get_ref());
 
-  arma_debug_assert_same_size(n_rows, n_cols, P.get_n_rows(), P.get_n_cols(), "subtraction into sparse submatrix");
+  arma_debug_assert_same_size(n_rows, n_cols, P.get_n_rows(), P.get_n_cols(), "subtraction");
 
   const uword old_n_nonzero = m.n_nonzero;
 
@@ -328,7 +328,7 @@
   const Proxy<T1> P(x.get_ref());
 
   // Must be exactly the same size for this (we can't modify our own size).
-  arma_debug_assert_same_size(n_rows, n_cols, P.get_n_rows(), P.get_n_cols(), "matrix multiplication into sparse submatrix");
+  arma_debug_assert_same_size(n_rows, n_cols, P.get_n_rows(), P.get_n_cols(), "matrix multiplication");
 
   SpMat<eT> tmp(*this);
   Mat<eT> other_tmp(x.get_ref());
@@ -350,15 +350,16 @@
 
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/rcpp -r 3765


More information about the Rcpp-commits mailing list