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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri May 27 17:18:31 CEST 2011


Author: edd
Date: 2011-05-27 17:18:30 +0200 (Fri, 27 May 2011)
New Revision: 3037

Modified:
   pkg/RcppArmadillo/ChangeLog
   pkg/RcppArmadillo/DESCRIPTION
   pkg/RcppArmadillo/inst/NEWS
   pkg/RcppArmadillo/inst/include/armadillo
   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_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/diagview_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/diagview_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_accu.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_det.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_prod.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/promote_type.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/running_stat_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/running_stat_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/running_stat_vec_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/running_stat_vec_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/traits.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/typedef_u64.hpp
Log:
Release 0.2.21 using Armadillo 1.99.3


Modified: pkg/RcppArmadillo/ChangeLog
===================================================================
--- pkg/RcppArmadillo/ChangeLog	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/ChangeLog	2011-05-27 15:18:30 UTC (rev 3037)
@@ -1,3 +1,9 @@
+2011-05-27  Dirk Eddelbuettel  <edd at debian.org>
+
+	* DESCRIPTION: Release 0.2.21
+
+	* inst/include/*: Updated to release 1.99.3 of Armadillo
+
 2011-05-25  Dirk Eddelbuettel  <edd at debian.org>
 
 	* DESCRIPTION: Release 0.2.20
@@ -2,3 +8,3 @@
 
-	* inst/include/*: Updated to test release 1.99.2 of Armadillo
+	* inst/include/*: Updated to release 1.99.2 of Armadillo
 

Modified: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/DESCRIPTION	2011-05-27 15:18:30 UTC (rev 3037)
@@ -1,7 +1,7 @@
 Package: RcppArmadillo
 Type: Package
 Title: Rcpp integration for Armadillo templated linear algebra library
-Version: 0.2.20
+Version: 0.2.21
 Date: $Date$
 Author: Romain Francois, Dirk Eddelbuettel and Doug Bates
 Maintainer: Romain Francois, Dirk Eddelbuettel and Doug Bates <RcppArmadillo-authors at r-enthusiasts.com>

Modified: pkg/RcppArmadillo/inst/NEWS
===================================================================
--- pkg/RcppArmadillo/inst/NEWS	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/NEWS	2011-05-27 15:18:30 UTC (rev 3037)
@@ -1,3 +1,10 @@
+0.2.21  2011-05-27
+
+    o   Upgraded to Armadillo release 1.99.3 "v2.0 beta 3" 
+
+          * stricter size checking for row and column vectors
+          * added .count() member function to running_stat and running_stat_vec
+
 0.2.20  2011-05-25
 
     o   Upgraded to Armadillo release 1.99.2 "v2.0 beta 2" (and 1.99.1 before)

Modified: pkg/RcppArmadillo/inst/include/armadillo
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo	2011-05-27 15:18:30 UTC (rev 3037)
@@ -109,7 +109,7 @@
   #include "armadillo_bits/forward_bones.hpp"
   #include "armadillo_bits/arma_static_assert.hpp"
   #include "armadillo_bits/typedef.hpp"
-  #include "armadillo_bits/typedef_u64.hpp"
+  //#include "armadillo_bits/typedef_u64.hpp"
   #include "armadillo_bits/format_wrap.hpp"
   #include "armadillo_bits/arma_version.hpp"
   #include "armadillo_bits/arma_config.hpp"

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -22,6 +22,7 @@
   {
   arma_extra_debug_sigprint();
   
+  access::rw(Mat<eT>::n_cols)    = 1;
   access::rw(Mat<eT>::vec_state) = 1;
   }
 
@@ -36,7 +37,7 @@
   
   access::rw(Mat<eT>::vec_state) = 1;
   
-  Mat<eT>::init(in_n_elem, (in_n_elem > 0) ? 1 : 0);
+  Mat<eT>::init(in_n_elem, 1);
   }
 
 
@@ -179,7 +180,7 @@
 template<typename eT>
 inline
 Col<eT>::Col(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, const bool strict)
-  : Mat<eT>(aux_mem, aux_length, ((aux_length > 0) ? 1 : 0), copy_aux_mem, strict)
+  : Mat<eT>(aux_mem, aux_length, 1, copy_aux_mem, strict)
   {
   arma_extra_debug_sigprint();
   
@@ -192,7 +193,7 @@
 template<typename eT>
 inline
 Col<eT>::Col(const eT* aux_mem, const u32 aux_length)
-  : Mat<eT>(aux_mem, aux_length, ((aux_length > 0) ? 1 : 0))
+  : Mat<eT>(aux_mem, aux_length, 1)
   {
   arma_extra_debug_sigprint();
   
@@ -550,7 +551,7 @@
   arma_extra_debug_sigprint();
   
   access::rw(Mat<eT>::n_rows)    = fixed_n_elem;
-  access::rw(Mat<eT>::n_cols)    = (fixed_n_elem > 0) ? 1 : 0;
+  access::rw(Mat<eT>::n_cols)    = 1;
   access::rw(Mat<eT>::n_elem)    = fixed_n_elem;
   access::rw(Mat<eT>::vec_state) = 1;
   access::rw(Mat<eT>::mem_state) = 3;
@@ -568,7 +569,7 @@
   arma_extra_debug_sigprint();
   
   access::rw(Mat<eT>::n_cols) = fixed_n_elem;
-  access::rw(Mat<eT>::n_rows) = (fixed_n_elem > 0) ? 1 : 0;
+  access::rw(Mat<eT>::n_rows) = 1;
   }
 
 
@@ -653,7 +654,7 @@
   arma_extra_debug_sigprint_this(this);
   
   access::rw(Mat<eT>::n_rows)    = fixed_n_elem;
-  access::rw(Mat<eT>::n_cols)    = (fixed_n_elem > 0) ? 1 : 0;
+  access::rw(Mat<eT>::n_cols)    = 1;
   access::rw(Mat<eT>::n_elem)    = fixed_n_elem;
   access::rw(Mat<eT>::vec_state) = 1;
   access::rw(Mat<eT>::mem_state) = 3;

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -493,7 +493,7 @@
   
   protected:
   
-  inline void init(const u32 in_rows, const u32 in_cols);
+  inline void init(u32 in_rows, u32 in_cols);
   inline void init(const std::string& text);
   inline void init(const Mat& x);
   

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -82,7 +82,7 @@
 template<typename eT>
 inline
 void
-Mat<eT>::init(const u32 in_n_rows, const u32 in_n_cols)
+Mat<eT>::init(u32 in_n_rows, u32 in_n_cols)
   {
   arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols = %d") % in_n_rows % in_n_cols );
   
@@ -104,21 +104,32 @@
       "Mat::init(): size is fixed and hence cannot be changed"
       );
     
-    arma_debug_set_error
-      (
-      err_state,
-      err_msg,
-        (
-        (t_vec_state > 0) &&
+    if(t_vec_state > 0)
+      {
+      if( (in_n_rows == 0) && (in_n_cols == 0) )
+        {
+        if(t_vec_state == 1)
+          {
+          in_n_cols = 1;
+          }
+        else
+        if(t_vec_state == 2)
+          {
+          in_n_rows = 1;
+          }
+        }
+      else
+        {
+        arma_debug_set_error
           (
-          ((t_vec_state == 1) && (in_n_cols > 1)) ||
-          ((t_vec_state == 2) && (in_n_rows > 1))
-          )
-        ),
-      "Mat::init(): object is a vector; requested size is not compatible"
-      );
+          err_state,
+          err_msg,
+          ( ((t_vec_state == 1) && (in_n_cols != 1)) || ((t_vec_state == 2) && (in_n_rows != 1)) ),
+          "Mat::init(): object is a vector; requested size is not compatible"
+          );
+        }
+      }
     
-    
     // ensure that n_elem can hold the result of (n_rows * n_cols)
     // (due to a limitation in the C++98 standard: there is no official "long long" variable type)
     arma_debug_set_error
@@ -542,12 +553,12 @@
       }
     else
       {
-      if( (t_vec_state == 1) && ( x_n_cols <= 1) )
+      if( (t_vec_state == 1) && ( x_n_cols == 1) )
         {
         layout_ok = true;
         }
       
-      if( (t_vec_state == 2) && ( x_n_rows <= 1) )
+      if( (t_vec_state == 2) && ( x_n_rows == 1) )
         {
         layout_ok = true;
         }
@@ -2101,25 +2112,18 @@
   {
   arma_extra_debug_sigprint();
   
-  if(n_elem > 0)
-    {
-    const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0;
-    const u32 col_offset = (in_id > 0) ? u32( in_id) : 0;
-    
-    arma_debug_check
-      (
-      (row_offset >= n_rows) || (col_offset >= n_cols),
-      "Mat::diag(): requested diagonal out of bounds"
-      );
-    
-    const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset);
-    
-    return diagview<eT>(*this, row_offset, col_offset, len);
-    }
-  else
-    {
-    return diagview<eT>(*this, 0, 0, 0);
-    }
+  const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0;
+  const u32 col_offset = (in_id > 0) ? u32( in_id) : 0;
+  
+  arma_debug_check
+    (
+    ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (col_offset >= n_cols)),
+    "Mat::diag(): requested diagonal out of bounds"
+    );
+  
+  const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset);
+  
+  return diagview<eT>(*this, row_offset, col_offset, len);
   }
 
 
@@ -2132,25 +2136,18 @@
   {
   arma_extra_debug_sigprint();
   
-  if(n_elem > 0)
-    {
-    const u32 row_offset = (in_id < 0) ? -in_id : 0;
-    const u32 col_offset = (in_id > 0) ?  in_id : 0;
-    
-    arma_debug_check
-      (
-      (row_offset >= n_rows) || (col_offset >= n_cols),
-      "Mat::diag(): requested diagonal out of bounds"
-      );
-    
-    const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset);
-    
-    return diagview<eT>(*this, row_offset, col_offset, len);
-    }
-  else
-    {
-    return diagview<eT>(*this, 0, 0, 0);
-    }
+  const u32 row_offset = (in_id < 0) ? -in_id : 0;
+  const u32 col_offset = (in_id > 0) ?  in_id : 0;
+  
+  arma_debug_check
+    (
+    ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (col_offset >= n_cols)),
+    "Mat::diag(): requested diagonal out of bounds"
+    );
+  
+  const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset);
+  
+  return diagview<eT>(*this, row_offset, col_offset, len);
   }
 
 
@@ -2196,16 +2193,18 @@
     "Mat::swap_cols(): out of bounds"
     );
   
-  eT* ptr1 = colptr(in_col1);
-  eT* ptr2 = colptr(in_col2);
-  
-  for(u32 row=0; row<n_rows; ++row)
+  if(n_elem > 0)
     {
-    const eT tmp = ptr1[row];
-    ptr1[row]    = ptr2[row];
-    ptr2[row]    = tmp;
+    eT* ptr1 = colptr(in_col1);
+    eT* ptr2 = colptr(in_col2);
+    
+    for(u32 row=0; row<n_rows; ++row)
+      {
+      const eT tmp = ptr1[row];
+      ptr1[row]    = ptr2[row];
+      ptr2[row]    = tmp;
+      }
     }
-  
   }
 
 
@@ -3463,10 +3462,7 @@
 bool
 Mat<eT>::is_vec() const
   {
-  const u32 t_n_rows = n_rows;
-  const u32 t_n_cols = n_cols;
-  
-  return ( (t_n_rows == 1) || (t_n_cols == 1) || ( (t_n_rows == 0) && (t_n_cols == 0) ) );
+  return ( (n_rows == 1) || (n_cols == 1) );
   }
 
 
@@ -3847,11 +3843,11 @@
     {
     case 0:
     case 1:
-      init(in_elem, (in_elem > 0) ? 1 : 0);
+      init(in_elem, 1);
       break;
     
     case 2:
-      init((in_elem > 0) ? 1 : 0, in_elem);
+      init(1, in_elem);
       break;
       
     default:
@@ -4143,7 +4139,20 @@
   {
   arma_extra_debug_sigprint();
   
-  init(0,0);
+  switch(vec_state)
+    {
+    default:
+      init(0, 0);
+      break;
+      
+    case 1:
+      init(0, 1);
+      break;
+    
+    case 2:
+      init(1, 0);
+      break;
+    }
   }
 
 

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -22,6 +22,7 @@
   {
   arma_extra_debug_sigprint();
   
+  access::rw(Mat<eT>::n_rows)    = 1;
   access::rw(Mat<eT>::vec_state) = 2;
   }
 
@@ -35,7 +36,7 @@
   
   access::rw(Mat<eT>::vec_state) = 2;
   
-  Mat<eT>::init((in_n_elem > 0) ? 1 : 0, in_n_elem);
+  Mat<eT>::init(1, in_n_elem);
   }
 
 
@@ -154,7 +155,7 @@
 template<typename eT>
 inline
 Row<eT>::Row(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, const bool strict)
-  : Mat<eT>(aux_mem, ((aux_length > 0) ? 1 : 0), aux_length, copy_aux_mem, strict)
+  : Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem, strict)
   {
   arma_extra_debug_sigprint();
   
@@ -167,7 +168,7 @@
 template<typename eT>
 inline
 Row<eT>::Row(const eT* aux_mem, const u32 aux_length)
-  : Mat<eT>(aux_mem, ((aux_length > 0) ? 1 : 0), aux_length)
+  : Mat<eT>(aux_mem, 1, aux_length)
   {
   arma_extra_debug_sigprint();
   
@@ -524,7 +525,7 @@
   {
   arma_extra_debug_sigprint();
   
-  access::rw(Mat<eT>::n_rows)    = (fixed_n_elem > 0) ? 1 : 0;
+  access::rw(Mat<eT>::n_rows)    = 1;
   access::rw(Mat<eT>::n_cols)    = fixed_n_elem;
   access::rw(Mat<eT>::n_elem)    = fixed_n_elem;
   access::rw(Mat<eT>::vec_state) = 2;
@@ -613,7 +614,7 @@
   {
   arma_extra_debug_sigprint_this(this);
   
-  access::rw(Mat<eT>::n_rows)    = (fixed_n_elem > 0) ? 1 : 0;
+  access::rw(Mat<eT>::n_rows)    = 1;
   access::rw(Mat<eT>::n_cols)    = fixed_n_elem;
   access::rw(Mat<eT>::n_elem)    = fixed_n_elem;
   access::rw(Mat<eT>::vec_state) = 2;

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -18,8 +18,8 @@
 
 #define ARMA_VERSION_MAJOR 1
 #define ARMA_VERSION_MINOR 99
-#define ARMA_VERSION_PATCH 2
-#define ARMA_VERSION_NAME  "v2.0 beta 2"
+#define ARMA_VERSION_PATCH 3
+#define ARMA_VERSION_NAME  "v2.0 beta 3"
 
 
 

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/diagview_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/diagview_bones.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/diagview_bones.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -31,7 +31,7 @@
   const u32 col_offset;
   
   const u32 n_rows;  // equal to n_elem
-  const u32 n_cols;  // equal to one if n_elem > 0, otherwise equal to zero
+  const u32 n_cols;  // always 1
   const u32 n_elem;
   
   

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/diagview_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/diagview_meat.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/diagview_meat.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -31,7 +31,7 @@
   , row_offset(in_row_offset)
   , col_offset(in_col_offset)
   , n_rows(in_len)
-  , n_cols( (in_len > 0) ? 1 : 0 )
+  , n_cols(1)
   , n_elem(in_len)
   {
   arma_extra_debug_sigprint();
@@ -47,7 +47,7 @@
   , row_offset(in_row_offset)
   , col_offset(in_col_offset)
   , n_rows(in_len)
-  , n_cols( (in_len > 0) ? 1 : 0 )
+  , n_cols(1)
   , n_elem(in_len)
   {
   arma_extra_debug_sigprint();

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -59,12 +59,12 @@
     {
     return std::string("ARMA_MAT_TXT_IS004");
     }
+  // else
+  // if(is_u64<eT>::value == true)
+  //   {
+  //   return std::string("ARMA_MAT_TXT_IU008");
+  //   }
   else
-  if(is_u64<eT>::value == true)
-    {
-    return std::string("ARMA_MAT_TXT_IU008");
-    }
-  else
   if(is_float<eT>::value == true)
     {
     return std::string("ARMA_MAT_TXT_FN004");
@@ -136,12 +136,12 @@
     {
     return std::string("ARMA_MAT_BIN_IS004");
     }
+  // else
+  // if(is_u64<eT>::value == true)
+  //   {
+  //   return std::string("ARMA_MAT_BIN_IU008");
+  //   }
   else
-  if(is_u64<eT>::value == true)
-    {
-    return std::string("ARMA_MAT_BIN_IU008");
-    }
-  else
   if(is_float<eT>::value == true)
     {
     return std::string("ARMA_MAT_BIN_FN004");
@@ -213,12 +213,12 @@
     {
     return std::string("ARMA_CUB_TXT_IS004");
     }
+  // else
+  // if(is_u64<eT>::value == true)
+  //   {
+  //   return std::string("ARMA_CUB_TXT_IU008");
+  //   }
   else
-  if(is_u64<eT>::value == true)
-    {
-    return std::string("ARMA_CUB_TXT_IU008");
-    }
-  else
   if(is_float<eT>::value == true)
     {
     return std::string("ARMA_CUB_TXT_FN004");
@@ -290,12 +290,12 @@
     {
     return std::string("ARMA_CUB_BIN_IS004");
     }
+  // else
+  // if(is_u64<eT>::value == true)
+  //   {
+  //   return std::string("ARMA_CUB_BIN_IU008");
+  //   }
   else
-  if(is_u64<eT>::value == true)
-    {
-    return std::string("ARMA_CUB_BIN_IU008");
-    }
-  else
   if(is_float<eT>::value == true)
     {
     return std::string("ARMA_CUB_BIN_FN004");

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/fn_accu.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/fn_accu.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/fn_accu.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -30,26 +30,46 @@
   
   const Proxy<T1> A(X.get_ref());
   
-        ea_type P      = A.get_ea();
-  const u32     n_elem = A.get_n_elem();
-  
-  eT val1 = eT(0);
-  eT val2 = eT(0);
-  
-  u32 i,j;
-  
-  for(i=0, j=1; j<n_elem; i+=2, j+=2)
+  if(Proxy<T1>::prefer_at_accessor == false)
     {
-    val1 += P[i];
-    val2 += P[j];
+          ea_type P      = A.get_ea();
+    const u32     n_elem = A.get_n_elem();
+    
+    eT val1 = eT(0);
+    eT val2 = eT(0);
+    
+    u32 i,j;
+    
+    for(i=0, j=1; j<n_elem; i+=2, j+=2)
+      {
+      val1 += P[i];
+      val2 += P[j];
+      }
+    
+    if(i < n_elem)
+      {
+      val1 += P[i];
+      }
+    
+    return val1 + val2;
     }
-  
-  if(i < n_elem)
+  else
     {
-    val1 += P[i];
+    const u32 n_rows = A.get_n_rows();
+    const u32 n_cols = A.get_n_cols();
+    
+    eT val = eT(0);
+    
+    for(u32 col=0; col<n_cols; ++col)
+      {
+      for(u32 row=0; row<n_rows; ++row)
+        {
+        val += A.at(row,col);
+        }
+      }
+    
+    return val;
     }
-  
-  return val1 + val2;
   }
 
 
@@ -99,26 +119,51 @@
   
   const ProxyCube<T1> A(X.get_ref());
   
-        ea_type P      = A.get_ea();
-  const u32     n_elem = A.get_n_elem();
-  
-  eT val1 = eT(0);
-  eT val2 = eT(0);
-  
-  u32 i,j;
-  
-  for(i=0, j=1; j<n_elem; i+=2, j+=2)
+  if(ProxyCube<T1>::prefer_at_accessor == false)
     {
-    val1 += P[i];
-    val2 += P[j];
+    
+          ea_type P      = A.get_ea();
+    const u32     n_elem = A.get_n_elem();
+    
+    eT val1 = eT(0);
+    eT val2 = eT(0);
+    
+    u32 i,j;
+    
+    for(i=0, j=1; j<n_elem; i+=2, j+=2)
+      {
+      val1 += P[i];
+      val2 += P[j];
+      }
+    
+    if(i < n_elem)
+      {
+      val1 += P[i];
+      }
+    
+    return val1 + val2;
     }
-  
-  if(i < n_elem)
+  else
     {
-    val1 += P[i];
+    const u32 n_rows   = A.get_n_rows();
+    const u32 n_cols   = A.get_n_cols();
+    const u32 n_slices = A.get_n_slices();
+    
+    eT val = eT(0);
+    
+    for(u32 slice=0; slice<n_slices; ++slice)
+      {
+      for(u32 col=0; col<n_cols; ++col)
+        {
+        for(u32 row=0; row<n_rows; ++row)
+          {
+          val += A.at(row,col,slice);
+          }
+        }
+      }
+    
+    return val;
     }
-  
-  return val1 + val2;
   }
 
 
@@ -157,24 +202,21 @@
   {
   arma_extra_debug_sigprint();  
   
-  if(S.n_elem > 0)
+  const u32 S_n_rows = S.n_rows;
+  const u32 S_n_cols = S.n_cols;
+  const u32 S_n_elem = S.n_elem;
+  
+  eT val = eT(0);
+  
+  if(S_n_elem > 0)
     {
-    const u32 S_n_rows = S.n_rows;
-    const u32 S_n_cols = S.n_cols;
-    
-    eT val = eT(0);
-    
     for(u32 col=0; col<S_n_cols; ++col)
       {
       val += arrayops::accumulate( S.colptr(col), S_n_rows );
       }
-    
-    return val;
     }
-  else
-    {
-    return eT(0);
-    }
+  
+  return val;
   }
 
 
@@ -191,28 +233,29 @@
   
   const Mat<eT>& X = S.m;
   
-  const u32 row            = S.aux_row1;
-  const u32 start_col      = S.aux_col1;
-  const u32 end_col_plus_1 = start_col + S.n_cols;
+  const u32 n_elem     = S.n_elem;
+  const u32 row        = S.aux_row1;
+  const u32 start_col  = S.aux_col1;
+  const u32 end_col_p1 = start_col + S.n_cols;
   
-  // S.n_cols might be equal to zero,
-  // hence the loop below has a "less than" condition
-  
   eT val = eT(0);
-  
-  u32 i,j;
-  
-  for(i=start_col, j=start_col+1; j < end_col_plus_1; i+=2, j+=2)
+    
+  if(n_elem > 0)
     {
-    val += X.at(row,i);
-    val += X.at(row,j);
+    u32 i,j;
+    
+    for(i=start_col, j=start_col+1; j < end_col_p1; i+=2, j+=2)
+      {
+      val += X.at(row,i);
+      val += X.at(row,j);
+      }
+    
+    if(i < end_col_p1)
+      {
+      val += X.at(row,i);
+      }
     }
   
-  if(i < end_col_plus_1)
-    {
-    val += X.at(row,i);
-    }
-  
   return val;
   }
 
@@ -228,7 +271,7 @@
   {
   arma_extra_debug_sigprint();
   
-  return arrayops::accumulate( S.colptr(0), S.n_rows );
+  return (S.n_elem > 0) ? arrayops::accumulate( S.colptr(0), S.n_rows ) : eT(0);
   }
 
 

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/fn_det.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/fn_det.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/fn_det.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -1,5 +1,5 @@
-// Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
-// Copyright (C) 2008-2010 Conrad Sanderson
+// Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
+// Copyright (C) 2008-2011 Conrad Sanderson
 // 
 // This file is part of the Armadillo C++ library.
 // It is provided without any warranty of fitness
@@ -45,14 +45,16 @@
   
   const diagmat_proxy<T1> A(X.m);
   
-  if(A.n_elem == 0)
+  const u32 A_n_elem = A.n_elem;
+  
+  if(A_n_elem == 0)
     {
     return eT(1);
     }
   
   eT val = A[0];
   
-  for(u32 i=1; i<A.n_elem; ++i)
+  for(u32 i=1; i<A_n_elem; ++i)
     {
     val *= A[i];
     }

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/fn_prod.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/fn_prod.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/fn_prod.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -39,6 +39,7 @@
 //! Immediate 'product of all values' operation for a row vector
 template<typename eT>
 inline
+arma_warn_unused
 eT
 prod(const Row<eT>& X)
   {
@@ -53,6 +54,7 @@
 //! Immediate 'product of all values' operation for a column vector
 template<typename eT>
 inline
+arma_warn_unused
 eT
 prod(const Col<eT>& X)
   {
@@ -100,6 +102,7 @@
 //! product of all values of a subview_row
 template<typename eT>
 inline
+arma_warn_unused
 eT
 prod(const subview_row<eT>& S)
   {
@@ -107,15 +110,19 @@
   
   const Mat<eT>& X = S.m;
   
+  const u32 n_elem         = S.n_elem;
   const u32 row            = S.aux_row1;
   const u32 start_col      = S.aux_col1;
   const u32 end_col_plus_1 = start_col + S.n_cols;
   
   eT val = eT(1);
   
-  for(u32 col=start_col; col<end_col_plus_1; ++col)
+  if(n_elem > 0)
     {
-    val *= X.at(row,col);
+    for(u32 col=start_col; col<end_col_plus_1; ++col)
+      {
+      val *= X.at(row,col);
+      }
     }
   
   return val;
@@ -126,18 +133,20 @@
 //! product of all values of a subview_col
 template<typename eT>
 inline
+arma_warn_unused
 eT
 prod(const subview_col<eT>& S)
   {
   arma_extra_debug_sigprint();
   
-  return arrayops::product( S.colptr(0), S.n_rows );
+  return (S.n_elem > 0) ? arrayops::product( S.colptr(0), S.n_rows ) : eT(1);
   }
 
 
 
 //! product of all values of a diagview
 template<typename eT>
+arma_warn_unused
 inline
 eT
 prod(const diagview<eT>& X)

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_bones.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_bones.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -1,5 +1,5 @@
-// Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
-// Copyright (C) 2008-2010 Conrad Sanderson
+// Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
+// Copyright (C) 2008-2011 Conrad Sanderson
 // 
 // This file is part of the Armadillo C++ library.
 // It is provided without any warranty of fitness
@@ -60,7 +60,10 @@
   public:
   
   template<typename T1, typename T2>
-  arma_hot arma_inline static typename T1::elem_type apply(const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
+  arma_hot inline static typename T1::elem_type apply       (const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
+  
+  template<typename T1, typename T2>
+  arma_hot inline static typename T1::elem_type apply_unwrap(const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
   };
 
 

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_meat.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_meat.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -1,5 +1,5 @@
-// Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
-// Copyright (C) 2008-2010 Conrad Sanderson
+// Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
+// Copyright (C) 2008-2011 Conrad Sanderson
 // 
 // This file is part of the Armadillo C++ library.
 // It is provided without any warranty of fitness
@@ -208,29 +208,38 @@
   const Proxy<T1> A(X.get_ref());
   const Proxy<T2> B(Y.get_ref());
   
-  arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "dot(): objects must have the same number of elements" );
+  const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor) && (Proxy<T2>::prefer_at_accessor);
   
-  const u32      N  = A.get_n_elem();
-        ea_type1 PA = A.get_ea();
-        ea_type2 PB = B.get_ea();
+  if(prefer_at_accessor == false)
+    {
+    arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "dot(): objects must have the same number of elements" );
   
-  eT val1 = eT(0);
-  eT val2 = eT(0);
-  
-  u32 i,j;
-  
-  for(i=0, j=1; j<N; i+=2, j+=2)
-    {
-    val1 += PA[i] * PB[i];
-    val2 += PA[j] * PB[j];
+    const u32      N  = A.get_n_elem();
+          ea_type1 PA = A.get_ea();
+          ea_type2 PB = B.get_ea();
+    
+    eT val1 = eT(0);
+    eT val2 = eT(0);
+    
+    u32 i,j;
+    
+    for(i=0, j=1; j<N; i+=2, j+=2)
+      {
+      val1 += PA[i] * PB[i];
+      val2 += PA[j] * PB[j];
+      }
+    
+    if(i < N)
+      {
+      val1 += PA[i] * PB[i];
+      }
+    
+    return val1 + val2;
     }
-  
-  if(i < N)
+  else
     {
-    val1 += PA[i] * PB[i];
+    return op_dot::apply_unwrap(A.Q, B.Q);
     }
-  
-  return val1 + val2;
   }
 
 
@@ -242,7 +251,7 @@
 
 template<typename T1, typename T2>
 arma_hot
-arma_inline
+inline
 typename T1::elem_type
 op_norm_dot::apply(const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y)
   {
@@ -252,23 +261,75 @@
   typedef typename Proxy<T1>::ea_type ea_type1;
   typedef typename Proxy<T2>::ea_type ea_type2;
   
-  const Proxy<T1> A(X.get_ref());
-  const Proxy<T2> B(Y.get_ref());
+  const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor) && (Proxy<T2>::prefer_at_accessor);
   
-  arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "norm_dot(): objects must have the same number of elements" );
+  if(prefer_at_accessor == false)
+    {
+    const Proxy<T1> A(X.get_ref());
+    const Proxy<T2> B(Y.get_ref());
+    
+    arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "norm_dot(): objects must have the same number of elements" );
+    
+    const u32      N  = A.get_n_elem();
+          ea_type1 PA = A.get_ea();
+          ea_type2 PB = B.get_ea();
+    
+    eT acc1 = eT(0);
+    eT acc2 = eT(0);
+    eT acc3 = eT(0);
+    
+    for(u32 i=0; i<N; ++i)
+      {
+      const eT tmpA = PA[i];
+      const eT tmpB = PB[i];
+      
+      acc1 += tmpA * tmpA;
+      acc2 += tmpB * tmpB;
+      acc3 += tmpA * tmpB;
+      }
+      
+    return acc3 / ( std::sqrt(acc1 * acc2) );
+    }
+  else
+    {
+    return op_norm_dot::apply_unwrap(X, Y);
+    }
+  }
+
+
+
+template<typename T1, typename T2>
+arma_hot
+inline
+typename T1::elem_type
+op_norm_dot::apply_unwrap(const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y)
+  {
+  arma_extra_debug_sigprint();
   
-  const u32      N  = A.get_n_elem();
-        ea_type1 PA = A.get_ea();
-        ea_type2 PB = B.get_ea();
+  typedef typename T1::elem_type eT;
   
+  const unwrap<T1> tmp1(X.get_ref());
+  const unwrap<T2> tmp2(Y.get_ref());
+  
+  const Mat<eT>& A = tmp1.M;
+  const Mat<eT>& B = tmp2.M;
+  
+  
+  arma_debug_check( (A.n_elem != B.n_elem), "norm_dot(): objects must have the same number of elements" );
+  
+  const u32 N = A.n_elem;
+  
+  const eT* A_mem = A.memptr();
+  const eT* B_mem = B.memptr();
+  
   eT acc1 = eT(0);
   eT acc2 = eT(0);
   eT acc3 = eT(0);
   
   for(u32 i=0; i<N; ++i)
     {
-    const eT tmpA = PA[i];
-    const eT tmpB = PB[i];
+    const eT tmpA = A_mem[i];
+    const eT tmpB = B_mem[i];
     
     acc1 += tmpA * tmpA;
     acc2 += tmpB * tmpB;

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/promote_type.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/promote_type.hpp	2011-05-25 21:48:49 UTC (rev 3036)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/promote_type.hpp	2011-05-27 15:18:30 UTC (rev 3037)
@@ -43,7 +43,7 @@
 template<> struct promote_type<std::complex<double>, float>                : public promote_type_ok { typedef std::complex<double> result; };
 template<> struct promote_type<std::complex<float>,  double>               : public promote_type_ok { typedef std::complex<double> result; };
 
-template<typename T> struct promote_type<std::complex<T>, u64> : public promote_type_ok { typedef std::complex<T> result; };
+// template<typename T> struct promote_type<std::complex<T>, u64> : public promote_type_ok { typedef std::complex<T> result; };
 template<typename T> struct promote_type<std::complex<T>, s32> : public promote_type_ok { typedef std::complex<T> result; };
 template<typename T> struct promote_type<std::complex<T>, u32> : public promote_type_ok { typedef std::complex<T> result; };
 template<typename T> struct promote_type<std::complex<T>, s16> : public promote_type_ok { typedef std::complex<T> result; };
@@ -53,7 +53,7 @@
 
 
 template<> struct promote_type<double, float> : public promote_type_ok { typedef double result; };
-template<> struct promote_type<double, u64  > : public promote_type_ok { typedef double result; };
+// template<> struct promote_type<double, u64  > : public promote_type_ok { typedef double result; };
 template<> struct promote_type<double, s32  > : public promote_type_ok { typedef double result; };
 template<> struct promote_type<double, u32  > : public promote_type_ok { typedef double result; };
 template<> struct promote_type<double, s16  > : public promote_type_ok { typedef double result; };
@@ -61,7 +61,7 @@
 template<> struct promote_type<double, s8   > : public promote_type_ok { typedef double result; };
 template<> struct promote_type<double, u8   > : public promote_type_ok { typedef double result; };
 
-template<> struct promote_type<float, u64> : public promote_type_ok { typedef float result; };
+// template<> struct promote_type<float, u64> : public promote_type_ok { typedef float result; };
 template<> struct promote_type<float, s32> : public promote_type_ok { typedef float result; };
 template<> struct promote_type<float, u32> : public promote_type_ok { typedef float result; };
 template<> struct promote_type<float, s16> : public promote_type_ok { typedef float result; };
@@ -69,9 +69,9 @@
 template<> struct promote_type<float, s8 > : public promote_type_ok { typedef float result; };
 template<> struct promote_type<float, u8 > : public promote_type_ok { typedef float result; };
 
-template<> struct promote_type<u64, u32> : public promote_type_ok { typedef u64 result; };
-template<> struct promote_type<u64, u16> : public promote_type_ok { typedef u64 result; };
-template<> struct promote_type<u64, u8 > : public promote_type_ok { typedef u64 result; };
+// template<> struct promote_type<u64, u32> : public promote_type_ok { typedef u64 result; };
+// template<> struct promote_type<u64, u16> : public promote_type_ok { typedef u64 result; };
+// template<> struct promote_type<u64, u8 > : public promote_type_ok { typedef u64 result; };
 
 template<> struct promote_type<s32, u32> : public promote_type_ok { typedef s32 result; };  // float ?  
 template<> struct promote_type<s32, s16> : public promote_type_ok { typedef s32 result; };
@@ -105,7 +105,7 @@
 template<> struct promote_type<float,               std::complex<double> > : public promote_type_ok { typedef std::complex<double> result; };
 template<> struct promote_type<double,              std::complex<float>  > : public promote_type_ok { typedef std::complex<double> result; };
 
-template<typename T> struct promote_type<u64, std::complex<T> > : public promote_type_ok { typedef std::complex<T> result; };
+// template<typename T> struct promote_type<u64, std::complex<T> > : public promote_type_ok { typedef std::complex<T> result; };
 template<typename T> struct promote_type<s32, std::complex<T> > : public promote_type_ok { typedef std::complex<T> result; };
 template<typename T> struct promote_type<u32, std::complex<T> > : public promote_type_ok { typedef std::complex<T> result; };
 template<typename T> struct promote_type<s16, std::complex<T> > : public promote_type_ok { typedef std::complex<T> result; };
@@ -115,7 +115,7 @@
 
 
 template<> struct promote_type<float, double> : public promote_type_ok { typedef double result; };
[TRUNCATED]

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


More information about the Rcpp-commits mailing list