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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Feb 19 01:20:13 CET 2011


Author: edd
Date: 2011-02-19 01:20:12 +0100 (Sat, 19 Feb 2011)
New Revision: 2904

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/arrayops_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/debug.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/field_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/field_proto.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_accu.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_prod.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/forward_proto.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/injector_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/injector_proto.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_sort_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_sort_proto.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/span.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_cube_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_cube_proto.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_field_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_field_proto.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_proto.hpp
Log:
RcppArmadillo 0.2.13 with Armadillo 1.1.4


Modified: pkg/RcppArmadillo/ChangeLog
===================================================================
--- pkg/RcppArmadillo/ChangeLog	2011-02-16 14:14:24 UTC (rev 2903)
+++ pkg/RcppArmadillo/ChangeLog	2011-02-19 00:20:12 UTC (rev 2904)
@@ -1,3 +1,9 @@
+2011-02-18  Dirk Eddelbuettel  <edd at debian.org>
+
+	* DESCRIPTION: Release 0.2.13
+
+	* inst/include/*: Updated to Armadillo 1.1.4 "Manta Lodge"
+
 2011-02-15  Dirk Eddelbuettel  <edd at debian.org>
 
 	* DESCRIPTION: Release 0.2.12

Modified: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION	2011-02-16 14:14:24 UTC (rev 2903)
+++ pkg/RcppArmadillo/DESCRIPTION	2011-02-19 00:20:12 UTC (rev 2904)
@@ -1,7 +1,7 @@
 Package: RcppArmadillo
 Type: Package
 Title: Rcpp integration for Armadillo templated linear algebra library
-Version: 0.2.12
+Version: 0.2.13
 Date: $Date$
 Author: Romain Francois, Dirk Eddelbuettel and Doug Bates
 Maintainer: Romain Francois, Dirk Eddelbuettel and Doug Bates <RcppArmadillo-authors at r-enthusiasts.com>
@@ -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 1.1.20). Thus users do not need to
+ Armadillo library (currently version 1.1.4). 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
===================================================================
--- pkg/RcppArmadillo/inst/NEWS	2011-02-16 14:14:24 UTC (rev 2903)
+++ pkg/RcppArmadillo/inst/NEWS	2011-02-19 00:20:12 UTC (rev 2904)
@@ -1,3 +1,11 @@
+0.2.13  2011-02-18
+
+    o   Upgraded to Armadillo Version 1.1.4   “Manta Lodge”
+
+         * Faster sort()
+         * Updated installation to detect recent versions of Intel's MKL
+         * Added interpretation of arbitrary "flat" subcubes as matrices
+
 0.2.12  2011-02-15
 
     o   Upgraded to Armadillo Version 1.1.2   “Flood Kayak”

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp	2011-02-16 14:14:24 UTC (rev 2903)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp	2011-02-19 00:20:12 UTC (rev 2904)
@@ -219,9 +219,37 @@
 
 
 
-//! construct a column vector from given a subcube; the subcube must have exactly one column
 template<typename eT>
+template<typename T1>
 inline
+Col<eT>::Col(const BaseCube<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+  
+  access::rw(Mat<eT>::vec_state) = 1;
+  
+  Mat<eT>::operator=(X);
+  }
+
+
+
+template<typename eT>
+template<typename T1>
+inline
+const Col<eT>&
+Col<eT>::operator=(const BaseCube<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+  
+  Mat<eT>::operator=(X);
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
+inline
 Col<eT>::Col(const subview_cube<eT>& X)
   {
   arma_extra_debug_sigprint();
@@ -233,7 +261,6 @@
 
 
 
-//! construct a column vector from given a subcube; the subcube must have exactly one column
 template<typename eT>
 inline
 const Col<eT>&
@@ -273,8 +300,7 @@
 template<typename eT>
 arma_inline
 eT
-Col<eT>::row(const u32 row_num)
-  const
+Col<eT>::row(const u32 row_num) const
   {
   arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): out of bounds" );
   
@@ -288,9 +314,13 @@
 subview_col<eT>
 Col<eT>::rows(const u32 in_row1, const u32 in_row2)
   {
+  arma_extra_debug_sigprint();
+  
   arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ), "Col::rows(): indices out of bounds or incorrectly used");
   
-  return subview_col<eT>(*this, 0, in_row1, in_row2);
+  const u32 subview_n_rows = in_row2 - in_row1 + 1;
+  
+  return subview_col<eT>(*this, 0, in_row1, subview_n_rows);
   }
 
 
@@ -298,12 +328,15 @@
 template<typename eT>
 arma_inline
 const subview_col<eT>
-Col<eT>::rows(const u32 in_row1, const u32 in_row2)
-  const
+Col<eT>::rows(const u32 in_row1, const u32 in_row2) const
   {
+  arma_extra_debug_sigprint();
+  
   arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ), "Col::rows(): indices out of bounds or incorrectly used");
   
-  return subview_col<eT>(*this, 0, in_row1, in_row2);
+  const u32 subview_n_rows = in_row2 - in_row1 + 1;
+  
+  return subview_col<eT>(*this, 0, in_row1, subview_n_rows);
   }
 
 
@@ -313,9 +346,13 @@
 subview_col<eT>
 Col<eT>::subvec(const u32 in_row1, const u32 in_row2)
   {
+  arma_extra_debug_sigprint();
+  
   arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ), "Col::subvec(): indices out of bounds or incorrectly used");
   
-  return subview_col<eT>(*this, 0, in_row1, in_row2);
+  const u32 subview_n_rows = in_row2 - in_row1 + 1;
+  
+  return subview_col<eT>(*this, 0, in_row1, subview_n_rows);
   }
 
 
@@ -323,12 +360,15 @@
 template<typename eT>
 arma_inline
 const subview_col<eT>
-Col<eT>::subvec(const u32 in_row1, const u32 in_row2)
-  const
+Col<eT>::subvec(const u32 in_row1, const u32 in_row2) const
   {
+  arma_extra_debug_sigprint();
+  
   arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ), "Col::subvec(): indices out of bounds or incorrectly used");
   
-  return subview_col<eT>(*this, 0, in_row1, in_row2);
+  const u32 subview_n_rows = in_row2 - in_row1 + 1;
+  
+  return subview_col<eT>(*this, 0, in_row1, subview_n_rows);
   }
 
 

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_proto.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_proto.hpp	2011-02-16 14:14:24 UTC (rev 2903)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_proto.hpp	2011-02-19 00:20:12 UTC (rev 2904)
@@ -45,6 +45,9 @@
   template<typename T1, typename T2>
   inline explicit Col(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
   
+  template<typename T1> inline                  Col(const BaseCube<eT,T1>& X);
+  template<typename T1> inline const Col& operator=(const BaseCube<eT,T1>& X);
+  
   inline                  Col(const subview_cube<eT>& X);
   inline const Col& operator=(const subview_cube<eT>& X);
   

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp	2011-02-16 14:14:24 UTC (rev 2903)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp	2011-02-19 00:20:12 UTC (rev 2904)
@@ -750,7 +750,9 @@
     "Cube::slices(): indices out of bounds or incorrectly used"
     );
   
-  return subview_cube<eT>(*this, 0, 0, in_slice1, ( (n_rows>0) ? n_rows-1 : 0 ), ( (n_cols>0) ? n_cols-1 : 0 ), in_slice2);
+  const u32 subcube_n_slices = in_slice2 - in_slice1 + 1;
+  
+  return subview_cube<eT>(*this, 0, 0, in_slice1, n_rows, n_cols, subcube_n_slices);
   }
 
 
@@ -769,7 +771,9 @@
     "Cube::rows(): indices out of bounds or incorrectly used"
     );
   
-  return subview_cube<eT>(*this, 0, 0, in_slice1, ( (n_rows>0) ? n_rows-1 : 0 ), ( (n_cols>0) ? n_cols-1 : 0 ), in_slice2);
+  const u32 subcube_n_slices = in_slice2 - in_slice1 + 1;
+  
+  return subview_cube<eT>(*this, 0, 0, in_slice1, n_rows, n_cols, subcube_n_slices);
   }
 
 
@@ -789,7 +793,11 @@
     "Cube::subcube(): indices out of bounds or incorrectly used"
     );
   
-  return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, in_row2, in_col2, in_slice2);
+  const u32 subcube_n_rows   = in_row2   - in_row1   + 1;
+  const u32 subcube_n_cols   = in_col2   - in_col1   + 1;
+  const u32 subcube_n_slices = in_slice2 - in_slice1 + 1;
+  
+  return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, subcube_n_rows, subcube_n_cols, subcube_n_slices);
   }
 
 
@@ -809,69 +817,127 @@
     "Cube::subcube(): indices out of bounds or incorrectly used"
     );
     
-  return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, in_row2, in_col2, in_slice2);
+  const u32 subcube_n_rows   = in_row2   - in_row1   + 1;
+  const u32 subcube_n_cols   = in_col2   - in_col1   + 1;
+  const u32 subcube_n_slices = in_slice2 - in_slice1 + 1;
+  
+  return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, subcube_n_rows, subcube_n_cols, subcube_n_slices);
   }
 
 
 
 //! creation of subview_cube (generic subcube)
 template<typename eT>
-arma_inline
+inline
 subview_cube<eT>
 Cube<eT>::subcube(const span& row_span, const span& col_span, const span& slice_span)
   {
   arma_extra_debug_sigprint();
   
-  const u32 in_row1 = row_span.a;
-  const u32 in_row2 = row_span.b;
+  const bool row_all   = row_span.whole;
+  const bool col_all   = col_span.whole;
+  const bool slice_all = slice_span.whole;
   
-  const u32 in_col1 = col_span.a;
-  const u32 in_col2 = col_span.b;
+  const u32 local_n_rows   = n_rows;
+  const u32 local_n_cols   = n_cols;
+  const u32 local_n_slices = n_slices;
   
-  const u32 in_slice1 = slice_span.a;
-  const u32 in_slice2 = slice_span.b;
+  const u32 in_row1          = row_all   ? 0              : row_span.a;
+  const u32 in_row2          =                              row_span.b;
+  const u32 subcube_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 subcube_n_cols   = col_all   ? local_n_cols   : in_col2 - in_col1 + 1;
+  
+  const u32 in_slice1        = slice_all ? 0              : slice_span.a;
+  const u32 in_slice2        =                              slice_span.b;
+  const u32 subcube_n_slices = slice_all ? local_n_slices : in_slice2 - in_slice1 + 1;
+  
   arma_debug_check
     (
-    (in_row1 >  in_row2) || (in_col1 >  in_col2) || (in_slice1 >  in_slice2) ||
-    (in_row2 >= n_rows)  || (in_col2 >= n_cols)  || (in_slice2 >= n_slices),
+    ( row_all   ? false : ((in_row1   >  in_row2)   || (in_row2   >= local_n_rows))   )
+    ||
+    ( col_all   ? false : ((in_col1   >  in_col2)   || (in_col2   >= local_n_cols))   )
+    ||
+    ( slice_all ? false : ((in_slice1 >  in_slice2) || (in_slice2 >= local_n_slices)) )
+    ,
     "Cube::subcube(): indices out of bounds or incorrectly used"
     );
   
-  return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, in_row2, in_col2, in_slice2);
+  return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, subcube_n_rows, subcube_n_cols, subcube_n_slices);
   }
 
 
 
 //! creation of subview_cube (generic subcube)
 template<typename eT>
-arma_inline
+inline
 const subview_cube<eT>
 Cube<eT>::subcube(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 bool row_all   = row_span.whole;
+  const bool col_all   = col_span.whole;
+  const bool slice_all = slice_span.whole;
   
-  const u32 in_col1 = col_span.a;
-  const u32 in_col2 = col_span.b;
+  const u32 local_n_rows   = n_rows;
+  const u32 local_n_cols   = n_cols;
+  const u32 local_n_slices = n_slices;
   
-  const u32 in_slice1 = slice_span.a;
-  const u32 in_slice2 = slice_span.b;
+  const u32 in_row1          = row_all   ? 0              : row_span.a;
+  const u32 in_row2          =                              row_span.b;
+  const u32 subcube_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 subcube_n_cols   = col_all   ? local_n_cols   : in_col2 - in_col1 + 1;
+  
+  const u32 in_slice1        = slice_all ? 0              : slice_span.a;
+  const u32 in_slice2        =                              slice_span.b;
+  const u32 subcube_n_slices = slice_all ? local_n_slices : in_slice2 - in_slice1 + 1;
+  
   arma_debug_check
     (
-    (in_row1 >  in_row2) || (in_col1 >  in_col2) || (in_slice1 >  in_slice2) ||
-    (in_row2 >= n_rows)  || (in_col2 >= n_cols)  || (in_slice2 >= n_slices),
+    ( row_all   ? false : ((in_row1   >  in_row2)   || (in_row2   >= local_n_rows))   )
+    ||
+    ( col_all   ? false : ((in_col1   >  in_col2)   || (in_col2   >= local_n_cols))   )
+    ||
+    ( slice_all ? false : ((in_slice1 >  in_slice2) || (in_slice2 >= local_n_slices)) )
+    ,
     "Cube::subcube(): indices out of bounds or incorrectly used"
     );
-    
-  return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, in_row2, in_col2, in_slice2);
+  
+  return subview_cube<eT>(*this, in_row1, in_col1, in_slice1, subcube_n_rows, subcube_n_cols, subcube_n_slices);
   }
 
 
 
+template<typename eT>
+inline
+subview_cube<eT>
+Cube<eT>::operator()(const span& row_span, const span& col_span, const span& slice_span)
+  {
+  arma_extra_debug_sigprint();
+  
+  return (*this).subcube(row_span, col_span, slice_span);
+  }
+
+
+
+template<typename eT>
+inline
+const subview_cube<eT>
+Cube<eT>::operator()(const span& row_span, const span& col_span, const span& slice_span) const
+  {
+  arma_extra_debug_sigprint();
+  
+  return (*this).subcube(row_span, col_span, slice_span);
+  }
+
+
+
 //! remove specified slice
 template<typename eT>
 inline

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_proto.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_proto.hpp	2011-02-16 14:14:24 UTC (rev 2903)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_proto.hpp	2011-02-19 00:20:12 UTC (rev 2904)
@@ -97,10 +97,13 @@
   arma_inline       subview_cube<eT> subcube(const u32 in_row1, const u32 in_col1, const u32 in_slice1, const u32 in_row2, const u32 in_col2, const u32 in_slice2);
   arma_inline const subview_cube<eT> subcube(const u32 in_row1, const u32 in_col1, const u32 in_slice1, const u32 in_row2, const u32 in_col2, const u32 in_slice2) const;
   
-  arma_inline       subview_cube<eT> subcube(const span& row_span, const span& col_span, const span& slice_span);
-  arma_inline const subview_cube<eT> subcube(const span& row_span, const span& col_span, const span& slice_span) const;
+  inline            subview_cube<eT> subcube(const span& row_span, const span& col_span, const span& slice_span);
+  inline      const subview_cube<eT> subcube(const span& row_span, const span& col_span, const span& slice_span) const;
   
+  inline            subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span);
+  inline      const subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span) const;
   
+  
   inline void shed_slice(const u32 slice_num);
   
   inline void shed_slices(const u32 in_slice1, const u32 in_slice2);

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp	2011-02-16 14:14:24 UTC (rev 2903)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp	2011-02-19 00:20:12 UTC (rev 2904)
@@ -640,7 +640,7 @@
   {
   arma_extra_debug_sigprint();
   
-  arma_debug_assert_same_size(*this, m, "matrix addition");
+  arma_debug_assert_same_size(*this, m, "addition");
   
   arrayops::inplace_plus( memptr(), m.memptr(), n_elem );
   
@@ -657,7 +657,7 @@
   {
   arma_extra_debug_sigprint();
   
-  arma_debug_assert_same_size(*this, m, "matrix subtraction");
+  arma_debug_assert_same_size(*this, m, "subtraction");
   
   arrayops::inplace_minus( memptr(), m.memptr(), n_elem );
   
@@ -689,7 +689,7 @@
   {
   arma_extra_debug_sigprint();
   
-  arma_debug_assert_same_size(*this, m, "element-wise matrix multplication");
+  arma_debug_assert_same_size(*this, m, "element-wise multiplication");
   
   arrayops::inplace_mul( memptr(), m.memptr(), n_elem );
   
@@ -706,7 +706,7 @@
   {
   arma_extra_debug_sigprint();
   
-  arma_debug_assert_same_size(*this, m, "element-wise matrix division");
+  arma_debug_assert_same_size(*this, m, "element-wise division");
   
   arrayops::inplace_div( memptr(), m.memptr(), n_elem );
   
@@ -715,6 +715,402 @@
 
 
 
+template<typename eT>
+template<typename T1>
+inline
+Mat<eT>::Mat(const BaseCube<eT,T1>& X)
+  : n_rows(0)
+  , n_cols(0)
+  , n_elem(0)
+  , vec_state(0)
+  , mem_state(0)
+  , mem(mem)  //, mem(0)
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  (*this).operator=(X);
+  }
+
+
+
+template<typename eT>
+template<typename T1>
+inline
+const Mat<eT>&
+Mat<eT>::operator=(const BaseCube<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+  
+  Mat<eT>& out = *this;
+  
+  const unwrap_cube<T1> tmp(X.get_ref());
+  const Cube<eT>& in  = tmp.M;
+  
+  arma_debug_assert_cube_as_mat(out, in, "copy into matrix", false);
+  
+  const u32 in_n_rows   = in.n_rows;
+  const u32 in_n_cols   = in.n_cols;
+  const u32 in_n_slices = in.n_slices;
+  
+  const u32 out_vec_state = out.vec_state;
+  
+  if(in_n_slices == 1)
+    {
+    out.set_size(in_n_rows, in_n_cols);
+    
+    for(u32 col=0; col < in_n_cols; ++col)
+      {
+      arrayops::copy( out.colptr(col), in.slice_colptr(0, col), in_n_rows );
+      }
+    }
+  else
+    {
+    if(out_vec_state == 0)
+      {
+      if(in_n_cols == 1)
+        {
+        out.set_size(in_n_rows, in_n_slices);
+        
+        for(u32 i=0; i < in_n_slices; ++i)
+          {
+          arrayops::copy( out.colptr(i), in.slice_colptr(i, 0), in_n_rows );
+          }
+        }
+      else
+      if(in_n_rows == 1)
+        {
+        out.set_size(in_n_slices, in_n_cols);
+        
+        for(u32 col=0; col < in_n_cols; ++col)
+          {
+          eT* out_colptr = out.colptr(col);
+          
+          for(u32 i=0; i < in_n_slices; ++i)
+            {
+            out_colptr[i] = in.at(0, col, i);
+            }
+          }
+        }
+      }
+    else
+      {
+      out.set_size(in_n_slices);
+      
+      eT* out_mem = out.memptr();
+      
+      for(u32 i=0; i<in_n_slices; ++i)
+        {
+        out_mem[i] = in.at(0, 0, i);
+        }
+      }
+    }
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
+template<typename T1>
+inline
+const Mat<eT>&
+Mat<eT>::operator+=(const BaseCube<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+  
+  Mat<eT>& out = *this;
+  
+  const unwrap_cube<T1> tmp(X.get_ref());
+  const Cube<eT>& in  = tmp.M;
+  
+  arma_debug_assert_cube_as_mat(out, in, "addition", true);
+  
+  const u32 in_n_rows   = in.n_rows;
+  const u32 in_n_cols   = in.n_cols;
+  const u32 in_n_slices = in.n_slices;
+  
+  const u32 out_n_rows    = out.n_rows;
+  const u32 out_n_cols    = out.n_cols;
+  const u32 out_vec_state = out.vec_state;
+  
+  if(in_n_slices == 1)
+    {
+    for(u32 col=0; col < in_n_cols; ++col)
+      {
+      arrayops::inplace_plus( out.colptr(col), in.slice_colptr(0, col), in_n_rows );
+      }
+    }
+  else
+    {
+    if(out_vec_state == 0)
+      {
+      if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
+        {
+        for(u32 i=0; i < in_n_slices; ++i)
+          {
+          arrayops::inplace_plus( out.colptr(i), in.slice_colptr(i, 0), in_n_rows );
+          }
+        }
+      else
+      if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
+        {
+        for(u32 col=0; col < in_n_cols; ++col)
+          {
+          eT* out_colptr = out.colptr(col);
+          
+          for(u32 i=0; i < in_n_slices; ++i)
+            {
+            out_colptr[i] += in.at(0, col, i);
+            }
+          }
+        }
+      }
+    else
+      {
+      eT* out_mem = out.memptr();
+      
+      for(u32 i=0; i<in_n_slices; ++i)
+        {
+        out_mem[i] += in.at(0, 0, i);
+        }
+      }
+    }
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
+template<typename T1>
+inline
+const Mat<eT>&
+Mat<eT>::operator-=(const BaseCube<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+  
+  Mat<eT>& out = *this;
+  
+  const unwrap_cube<T1> tmp(X.get_ref());
+  const Cube<eT>& in  = tmp.M;
+  
+  arma_debug_assert_cube_as_mat(out, in, "subtraction", true);
+  
+  const u32 in_n_rows   = in.n_rows;
+  const u32 in_n_cols   = in.n_cols;
+  const u32 in_n_slices = in.n_slices;
+  
+  const u32 out_n_rows    = out.n_rows;
+  const u32 out_n_cols    = out.n_cols;
+  const u32 out_vec_state = out.vec_state;
+  
+  if(in_n_slices == 1)
+    {
+    for(u32 col=0; col < in_n_cols; ++col)
+      {
+      arrayops::inplace_minus( out.colptr(col), in.slice_colptr(0, col), in_n_rows );
+      }
+    }
+  else
+    {
+    if(out_vec_state == 0)
+      {
+      if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
+        {
+        for(u32 i=0; i < in_n_slices; ++i)
+          {
+          arrayops::inplace_minus( out.colptr(i), in.slice_colptr(i, 0), in_n_rows );
+          }
+        }
+      else
+      if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
+        {
+        for(u32 col=0; col < in_n_cols; ++col)
+          {
+          eT* out_colptr = out.colptr(col);
+          
+          for(u32 i=0; i < in_n_slices; ++i)
+            {
+            out_colptr[i] -= in.at(0, col, i);
+            }
+          }
+        }
+      }
+    else
+      {
+      eT* out_mem = out.memptr();
+      
+      for(u32 i=0; i<in_n_slices; ++i)
+        {
+        out_mem[i] -= in.at(0, 0, i);
+        }
+      }
+    }
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
+template<typename T1>
+inline
+const Mat<eT>&
+Mat<eT>::operator*=(const BaseCube<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+  
+  const Mat<eT> B(X);
+  
+  (*this).operator*=(B);
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
+template<typename T1>
+inline
+const Mat<eT>&
+Mat<eT>::operator%=(const BaseCube<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+  
+  Mat<eT>& out = *this;
+  
+  const unwrap_cube<T1> tmp(X.get_ref());
+  const Cube<eT>& in  = tmp.M;
+  
+  arma_debug_assert_cube_as_mat(out, in, "element-wise multiplication", true);
+  
+  const u32 in_n_rows   = in.n_rows;
+  const u32 in_n_cols   = in.n_cols;
+  const u32 in_n_slices = in.n_slices;
+  
+  const u32 out_n_rows    = out.n_rows;
+  const u32 out_n_cols    = out.n_cols;
+  const u32 out_vec_state = out.vec_state;
+  
+  if(in_n_slices == 1)
+    {
+    for(u32 col=0; col < in_n_cols; ++col)
+      {
+      arrayops::inplace_mul( out.colptr(col), in.slice_colptr(0, col), in_n_rows );
+      }
+    }
+  else
+    {
+    if(out_vec_state == 0)
+      {
+      if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
+        {
+        for(u32 i=0; i < in_n_slices; ++i)
+          {
+          arrayops::inplace_mul( out.colptr(i), in.slice_colptr(i, 0), in_n_rows );
+          }
+        }
+      else
+      if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
+        {
+        for(u32 col=0; col < in_n_cols; ++col)
+          {
+          eT* out_colptr = out.colptr(col);
+          
+          for(u32 i=0; i < in_n_slices; ++i)
+            {
+            out_colptr[i] *= in.at(0, col, i);
+            }
+          }
+        }
+      }
+    else
+      {
+      eT* out_mem = out.memptr();
+      
+      for(u32 i=0; i<in_n_slices; ++i)
+        {
+        out_mem[i] *= in.at(0, 0, i);
+        }
+      }
+    }
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
+template<typename T1>
+inline
+const Mat<eT>&
+Mat<eT>::operator/=(const BaseCube<eT,T1>& X)
+  {
+  arma_extra_debug_sigprint();
+  
+  Mat<eT>& out = *this;
+  
+  const unwrap_cube<T1> tmp(X.get_ref());
+  const Cube<eT>& in  = tmp.M;
+  
+  arma_debug_assert_cube_as_mat(out, in, "element-wise division", true);
+  
+  const u32 in_n_rows   = in.n_rows;
+  const u32 in_n_cols   = in.n_cols;
+  const u32 in_n_slices = in.n_slices;
+  
+  const u32 out_n_rows    = out.n_rows;
+  const u32 out_n_cols    = out.n_cols;
+  const u32 out_vec_state = out.vec_state;
+  
+  if(in_n_slices == 1)
+    {
+    for(u32 col=0; col < in_n_cols; ++col)
+      {
+      arrayops::inplace_div( out.colptr(col), in.slice_colptr(0, col), in_n_rows );
+      }
+    }
+  else
+    {
+    if(out_vec_state == 0)
+      {
+      if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
+        {
+        for(u32 i=0; i < in_n_slices; ++i)
+          {
+          arrayops::inplace_div( out.colptr(i), in.slice_colptr(i, 0), in_n_rows );
+          }
+        }
+      else
+      if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) )
+        {
+        for(u32 col=0; col < in_n_cols; ++col)
+          {
+          eT* out_colptr = out.colptr(col);
+          
+          for(u32 i=0; i < in_n_slices; ++i)
+            {
+            out_colptr[i] /= in.at(0, col, i);
+            }
+          }
+        }
+      }
+    else
+      {
+      eT* out_mem = out.memptr();
+      
+      for(u32 i=0; i<in_n_slices; ++i)
+        {
+        out_mem[i] /= in.at(0, 0, i);
+        }
+      }
+    }
+  
+  return *this;
+  }
+
+
+
 //! for constructing a complex matrix out of two non-complex matrices
 template<typename eT>
 template<typename T1, typename T2>
@@ -1186,7 +1582,7 @@
 template<typename eT>
 inline
 mat_injector< Mat<eT> >
-Mat<eT>::operator<<(const injector_helper x)
+Mat<eT>::operator<<(const injector_end_of_row& x)
   {
   return mat_injector< Mat<eT> >(*this, x);
   }
@@ -1224,71 +1620,59 @@
 
 
 template<typename eT>
-arma_inline
+inline
 subview_row<eT>
-Mat<eT>::operator()(const u32 row_num, const span_helper)
+Mat<eT>::operator()(const u32 row_num, const span& col_span)
   {
   arma_extra_debug_sigprint();
   
-  arma_debug_check( (row_num >= n_rows), "Mat::operator(): row out of bounds" );
+  const bool col_all = col_span.whole;
   
-  return subview_row<eT>(*this, row_num);
-  }
-
-
-
-template<typename eT>
-arma_inline
-const subview_row<eT>
-Mat<eT>::operator()(const u32 row_num, const span_helper) const
-  {
-  arma_extra_debug_sigprint();
+  const u32 local_n_cols = n_cols;
   
-  arma_debug_check( (row_num >= n_rows), "Mat::operator(): row out of bounds" );
+  const u32 in_col1       = col_all ? 0            : col_span.a;
+  const u32 in_col2       =                          col_span.b;
+  const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
   
-  return subview_row<eT>(*this, row_num);
-  }
-
-
-
-template<typename eT>
-arma_inline
-subview_row<eT>
-Mat<eT>::operator()(const u32 row_num, const span& col_span)
-  {
-  arma_extra_debug_sigprint();
-  
-  const u32 a = col_span.a;
-  const u32 b = col_span.b;
-  
   arma_debug_check
     (
-    (row_num >= n_rows) || (a > b) || (b >= n_cols),
+    (row_num >= n_rows)
+    ||
+    ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
+    ,
     "Mat::operator(): indices out of bounds or incorrectly used"
     );
   
-  return subview_row<eT>(*this, row_num, a, b);
+  return subview_row<eT>(*this, row_num, in_col1, submat_n_cols);
   }
 
 
 
 template<typename eT>
-arma_inline
+inline
 const subview_row<eT>
 Mat<eT>::operator()(const u32 row_num, const span& col_span) const
   {
   arma_extra_debug_sigprint();
   
-  const u32 a = col_span.a;
-  const u32 b = col_span.b;
+  const bool col_all = col_span.whole;
   
+  const u32 local_n_cols = n_cols;
+  
+  const u32 in_col1       = col_all ? 0            : col_span.a;
+  const u32 in_col2       =                          col_span.b;
+  const u32 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
+  
   arma_debug_check
     (
-    (row_num >= n_rows) || (a > b) || (b >= n_cols),
+    (row_num >= n_rows)
+    ||
+    ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
+    ,
     "Mat::operator(): indices out of bounds or incorrectly used"
     );
   
-  return subview_row<eT>(*this, row_num, a, b);
+  return subview_row<eT>(*this, row_num, in_col1, submat_n_cols);
   }
 
 
@@ -1324,71 +1708,59 @@
 
 
 template<typename eT>
-arma_inline
+inline
 subview_col<eT>
-Mat<eT>::operator()(const span_helper, const u32 col_num)
+Mat<eT>::operator()(const span& row_span, const u32 col_num)
   {
   arma_extra_debug_sigprint();
   
-  arma_debug_check( col_num >= n_cols, "Mat::operator(): column out of bounds");
+  const bool row_all = row_span.whole;
   
-  return subview_col<eT>(*this, col_num);
-  }
-
-
-
-template<typename eT>
-arma_inline
-const subview_col<eT>
-Mat<eT>::operator()(const span_helper, const u32 col_num) const
-  {
-  arma_extra_debug_sigprint();
+  const u32 local_n_rows = n_rows;
   
-  arma_debug_check( col_num >= n_cols, "Mat::operator(): column out of bounds");
+  const u32 in_row1       = row_all ? 0            : row_span.a;
+  const u32 in_row2       =                          row_span.b;
+  const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
   
-  return subview_col<eT>(*this, col_num);
-  }
-
-
-
-template<typename eT>
-arma_inline
-subview_col<eT>
-Mat<eT>::operator()(const span& row_span, const u32 col_num)
-  {
-  arma_extra_debug_sigprint();
-  
-  const u32 a = row_span.a;
-  const u32 b = row_span.b;
-  
   arma_debug_check
     (
-    (col_num >= n_cols) || (a > b) || (b >= n_rows),
+    (col_num >= n_cols)
+    ||
+    ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
+    ,
     "Mat::operator(): indices out of bounds or incorrectly used"
     );
   
-  return subview_col<eT>(*this, col_num, a, b);
+  return subview_col<eT>(*this, col_num, in_row1, submat_n_rows);
   }
 
 
 
 template<typename eT>
-arma_inline
+inline
 const subview_col<eT>
 Mat<eT>::operator()(const span& row_span, const u32 col_num) const
   {
   arma_extra_debug_sigprint();
   
-  const u32 a = row_span.a;
-  const u32 b = row_span.b;
+  const bool row_all = row_span.whole;
   
+  const u32 local_n_rows = n_rows;
+  
+  const u32 in_row1       = row_all ? 0            : row_span.a;
+  const u32 in_row2       =                          row_span.b;
+  const u32 submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
+  
   arma_debug_check
     (
-    (col_num >= n_cols) || (a > b) || (b >= n_rows),
+    (col_num >= n_cols)
+    ||
+    ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
+    ,
     "Mat::operator(): indices out of bounds or incorrectly used"
     );
   
-  return subview_col<eT>(*this, col_num, a, b);
+  return subview_col<eT>(*this, col_num, in_row1, submat_n_rows);
   }
 
 
@@ -1445,7 +1817,9 @@
     "Mat::rows(): indices out of bounds or incorrectly used"
     );
   
-  return subview<eT>(*this, in_row1, 0, in_row2, ((n_cols>0) ? n_cols-1 : 0) );
+  const u32 subview_n_rows = in_row2 - in_row1 + 1;
+  
+  return subview<eT>(*this, in_row1, 0, subview_n_rows, n_cols );
   }
 
 
@@ -1464,7 +1838,9 @@
     "Mat::rows(): indices out of bounds or incorrectly used"
     );
   
-  return subview<eT>(*this, in_row1, 0, in_row2, ((n_cols>0) ? n_cols-1 : 0) );
+  const u32 subview_n_rows = in_row2 - in_row1 + 1;
+  
+  return subview<eT>(*this, in_row1, 0, subview_n_rows, n_cols );
   }
 
 
@@ -1483,7 +1859,9 @@
     "Mat::cols(): indices out of bounds or incorrectly used"
     );
   
-  return subview<eT>(*this, 0, in_col1, ((n_rows>0) ? n_rows-1 : 0), in_col2);
+  const u32 subview_n_cols = in_col2 - in_col1 + 1;
+  
+  return subview<eT>(*this, 0, in_col1, n_rows, subview_n_cols);
   }
 
 
@@ -1502,7 +1880,9 @@
     "Mat::cols(): indices out of bounds or incorrectly used"
     );
   
-  return subview<eT>(*this, 0, in_col1, ((n_rows>0) ? n_rows-1 : 0), in_col2);
+  const u32 subview_n_cols = in_col2 - in_col1 + 1;
+  
+  return subview<eT>(*this, 0, in_col1, n_rows, subview_n_cols);
   }
 
 
@@ -1521,7 +1901,10 @@
     "Mat::submat(): indices out of bounds or incorrectly used"
     );
   
-  return subview<eT>(*this, in_row1, in_col1, in_row2, in_col2);
+  const u32 subview_n_rows = in_row2 - in_row1 + 1;
+  const u32 subview_n_cols = in_col2 - in_col1 + 1;
+  
+  return subview<eT>(*this, in_row1, in_col1, subview_n_rows, subview_n_cols);
   }
 
 
@@ -1540,81 +1923,106 @@
     "Mat::submat(): indices out of bounds or incorrectly used"
     );
     
-  return subview<eT>(*this, in_row1, in_col1, in_row2, in_col2);
+  const u32 subview_n_rows = in_row2 - in_row1 + 1;
+  const u32 subview_n_cols = in_col2 - in_col1 + 1;
+  
+  return subview<eT>(*this, in_row1, in_col1, subview_n_rows, subview_n_cols);
   }
 
 
 
 //! creation of subview (submatrix)
 template<typename eT>
-arma_inline
+inline
 subview<eT>
 Mat<eT>::submat(const span& row_span, const span& col_span)
   {
   arma_extra_debug_sigprint();
   
-  const u32 in_row1 = row_span.a;
-  const u32 in_row2 = row_span.b;
+  const bool row_all = row_span.whole;
+  const bool col_all = col_span.whole;
   
-  const u32 in_col1 = col_span.a;
-  const u32 in_col2 = col_span.b;
+  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 submat_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 submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
+  
   arma_debug_check
     (
-    (in_row1 > in_row2) || (in_col1 >  in_col2) || (in_row2 >= n_rows) || (in_col2 >= n_cols),
+    ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
+    ||
[TRUNCATED]

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


More information about the Rcpp-commits mailing list