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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 25 03:04:15 CEST 2011


Author: edd
Date: 2011-05-25 03:04:14 +0200 (Wed, 25 May 2011)
New Revision: 3031

Added:
   pkg/RcppArmadillo/inst/include/armadillo_bits/undefine_conflicts.hpp
Modified:
   pkg/RcppArmadillo/inst/include/armadillo
   pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/Proxy.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/ProxyCube.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/arma_static_assert.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/auxlib_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/compiler_setup.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/debug.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/diagmat_proxy.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/eGlueCube_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/eGlueCube_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/eGlue_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/eGlue_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/eOpCube_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/eOp_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/eglue_core_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/eop_core_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_accu.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_diagmat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_max.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_mean.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_median.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_min.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_prod.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_stddev.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_strans.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trans.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/fn_var.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/gemm.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/gemv.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/glue_conv_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/glue_cor_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/glue_cross_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/glue_toeplitz_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_cor_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_diagmat_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_max_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_mean_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_median_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_min_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_pinv_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_prod_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_shuffle_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_stddev_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_sum_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/op_var_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/promote_type.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/running_stat_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_bones.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_cube_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_elem1_meat.hpp
   pkg/RcppArmadillo/inst/include/armadillo_bits/subview_field_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:
upgraded to Armadillo 1.99.2


Modified: pkg/RcppArmadillo/inst/include/armadillo
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo	2011-05-24 16:18:18 UTC (rev 3030)
+++ pkg/RcppArmadillo/inst/include/armadillo	2011-05-25 01:04:14 UTC (rev 3031)
@@ -97,6 +97,7 @@
 
 
 #include "armadillo_bits/itpp_wrap.hpp"
+#include "armadillo_bits/undefine_conflicts.hpp"
 
 
 //! \namespace arma namespace for Armadillo classes and functions

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp	2011-05-24 16:18:18 UTC (rev 3030)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp	2011-05-25 01:04:14 UTC (rev 3031)
@@ -85,37 +85,40 @@
     {
     private:
     
-    arma_aligned eT mem_local_extra[ (fixed_n_elem > arma_config::mat_prealloc) ? fixed_n_elem : 1 ];
+    static const bool use_extra = (fixed_n_elem > arma_config::mat_prealloc);
     
+    arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ];
+    
     arma_inline void mem_setup();
-    arma_inline void swap_rows_cols() { access::rw(Mat<eT>::n_cols) = fixed_n_elem; access::rw(Mat<eT>::n_rows) = 1; }
+    arma_inline void change_to_row();
     
+    
     public:
     
-    inline fixed() { mem_setup(); }
+    static const u32 n_rows = fixed_n_elem;
+    static const u32 n_cols = 1;
+    static const u32 n_elem = fixed_n_elem;
     
-    inline                fixed(const char*        text) { mem_setup(); swap_rows_cols(); Col<eT>::operator=(text);               }
-    inline const Col& operator=(const char*        text) {              swap_rows_cols(); Col<eT>::operator=(text); return *this; }
-    inline                fixed(const std::string& text) { mem_setup(); swap_rows_cols(); Col<eT>::operator=(text);               }
-    inline const Col& operator=(const std::string& text) {              swap_rows_cols(); Col<eT>::operator=(text); return *this; }
+    arma_inline fixed();
+    arma_inline fixed(const fixed<fixed_n_elem>& X);
+         inline fixed(const subview_cube<eT>& X);
     
-    inline const Col& operator=(const eT val) { Col<eT>::operator=(val); return *this; }
+    template<typename T1>              inline fixed(const Base<eT,T1>& A);
+    template<typename T1, typename T2> inline fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
     
-    template<typename T1>
-    inline fixed(const Base<eT,T1>& A) { mem_setup(); Col<eT>::operator=(A.get_ref()); }
+    inline fixed(      eT* aux_mem, const bool copy_aux_mem = true);
+    inline fixed(const eT* aux_mem);
     
-    template<typename T1>
-    inline const Col& operator=(const Base<eT,T1>& A) { Col<eT>::operator=(A.get_ref()); return *this; }
+    inline fixed(const char*        text);
+    inline fixed(const std::string& text);
     
-    template<typename T1, typename T2>
-    inline explicit fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B) { mem_setup(); Col<eT>::init(A,B); }
+    template<typename T1> inline const Col& operator=(const Base<eT,T1>& A);
     
-    inline fixed(      eT* aux_mem, const bool copy_aux_mem = true);
-    inline fixed(const eT* aux_mem);
+    inline const Col& operator=(const eT val);
+    inline const Col& operator=(const char*        text);
+    inline const Col& operator=(const std::string& text);
+    inline const Col& operator=(const subview_cube<eT>& X);
     
-    inline                fixed(const subview_cube<eT>& X) { mem_setup(); Col<eT>::operator=(X);               }
-    inline const Col& operator=(const subview_cube<eT>& X) {              Col<eT>::operator=(X); return *this; }
-    
     inline       subview_row<eT> operator()(const u32   row_num,  const span& col_span);
     inline const subview_row<eT> operator()(const u32   row_num,  const span& col_span) const;
     
@@ -125,6 +128,8 @@
     inline       subview<eT>     operator()(const span& row_span, const span& col_span);
     inline const subview<eT>     operator()(const span& row_span, const span& col_span) const;
     
+    arma_inline arma_warn_unused eT& operator[] (const u32 i);
+    arma_inline arma_warn_unused eT  operator[] (const u32 i) const;
     arma_inline arma_warn_unused eT& at         (const u32 i);
     arma_inline arma_warn_unused eT  at         (const u32 i) const;
     arma_inline arma_warn_unused eT& operator() (const u32 i);
@@ -134,6 +139,10 @@
     arma_inline arma_warn_unused eT  at         (const u32 in_row, const u32 in_col) const;
     arma_inline arma_warn_unused eT& operator() (const u32 in_row, const u32 in_col);
     arma_inline arma_warn_unused eT  operator() (const u32 in_row, const u32 in_col) const;
+    
+    arma_hot inline const Col<eT>& fill(const eT val);
+    arma_hot inline const Col<eT>& zeros();
+    arma_hot inline const Col<eT>& ones();
     };
   
   

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp	2011-05-24 16:18:18 UTC (rev 3030)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp	2011-05-25 01:04:14 UTC (rev 3031)
@@ -36,7 +36,7 @@
   
   access::rw(Mat<eT>::vec_state) = 1;
   
-  Mat<eT>::init(in_n_elem, 1);
+  Mat<eT>::init(in_n_elem, (in_n_elem > 0) ? 1 : 0);
   }
 
 
@@ -179,7 +179,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, 1, copy_aux_mem, strict)
+  : Mat<eT>(aux_mem, aux_length, ((aux_length > 0) ? 1 : 0), copy_aux_mem, strict)
   {
   arma_extra_debug_sigprint();
   
@@ -192,7 +192,7 @@
 template<typename eT>
 inline
 Col<eT>::Col(const eT* aux_mem, const u32 aux_length)
-  : Mat<eT>(aux_mem, aux_length, 1)
+  : Mat<eT>(aux_mem, aux_length, ((aux_length > 0) ? 1 : 0))
   {
   arma_extra_debug_sigprint();
   
@@ -547,36 +547,124 @@
 void
 Col<eT>::fixed<fixed_n_elem>::mem_setup()
   {
-  arma_extra_debug_sigprint_this(this);
+  arma_extra_debug_sigprint();
   
   access::rw(Mat<eT>::n_rows)    = fixed_n_elem;
-  access::rw(Mat<eT>::n_cols)    = 1;
+  access::rw(Mat<eT>::n_cols)    = (fixed_n_elem > 0) ? 1 : 0;
   access::rw(Mat<eT>::n_elem)    = fixed_n_elem;
   access::rw(Mat<eT>::vec_state) = 1;
   access::rw(Mat<eT>::mem_state) = 3;
-  access::rw(Mat<eT>::mem)       = (fixed_n_elem > arma_config::mat_prealloc) ? mem_local_extra : Mat<eT>::mem_local;
+  access::rw(Mat<eT>::mem)       = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
   }
 
 
 
 template<typename eT>
 template<u32 fixed_n_elem>
+arma_inline
+void
+Col<eT>::fixed<fixed_n_elem>::change_to_row()
+  {
+  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;
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+arma_inline
+Col<eT>::fixed<fixed_n_elem>::fixed()
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  mem_setup();
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+arma_inline
+Col<eT>::fixed<fixed_n_elem>::fixed(const fixed<fixed_n_elem>& X)
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  mem_setup();
+  
+  eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
+  
+  arrayops::copy( dest, X.mem, fixed_n_elem );
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
 inline
+Col<eT>::fixed<fixed_n_elem>::fixed(const subview_cube<eT>& X)
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  mem_setup();
+  
+  Col<eT>::operator=(X);
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+template<typename T1>
+inline
+Col<eT>::fixed<fixed_n_elem>::fixed(const Base<eT,T1>& A)
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  mem_setup();
+  
+  Col<eT>::operator=(A.get_ref());
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+template<typename T1, typename T2>
+inline
+Col<eT>::fixed<fixed_n_elem>::fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B)
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  mem_setup();
+  
+  Col<eT>::init(A,B);
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+inline
 Col<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem)
   {
   arma_extra_debug_sigprint_this(this);
   
   access::rw(Mat<eT>::n_rows)    = fixed_n_elem;
-  access::rw(Mat<eT>::n_cols)    = 1;
+  access::rw(Mat<eT>::n_cols)    = (fixed_n_elem > 0) ? 1 : 0;
   access::rw(Mat<eT>::n_elem)    = fixed_n_elem;
   access::rw(Mat<eT>::vec_state) = 1;
   access::rw(Mat<eT>::mem_state) = 3;
   
   if(copy_aux_mem == true)
     {
-    access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_prealloc) ? mem_local_extra : Mat<eT>::mem_local;
+    eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
     
-    arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
+    access::rw(Mat<eT>::mem) = dest;
+    
+    arrayops::copy( dest, aux_mem, fixed_n_elem );
     }
   else
     {
@@ -591,6 +679,8 @@
 inline
 Col<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
   {
+  arma_extra_debug_sigprint_this(this);
+  
   mem_setup();
   
   arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
@@ -598,9 +688,122 @@
 
 
 
+//! NOTE: this function relies on
+//! Col::operator=(text), to change vec_state as well as swapping n_rows and n_cols,
+//! and Mat::init(), to check that the given vector will not have a different size than fixed_n_elem.
 template<typename eT>
 template<u32 fixed_n_elem>
 inline
+Col<eT>::fixed<fixed_n_elem>::fixed(const char* text)
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  mem_setup();
+  
+  change_to_row();
+  
+  Col<eT>::operator=(text);
+  }
+
+
+
+//! NOTE: this function relies on
+//! Col::operator=(text), to change vec_state as well as swapping n_rows and n_cols,
+//! and Mat::init(), to check that the given vector will not have a different size than fixed_n_elem.
+template<typename eT>
+template<u32 fixed_n_elem>
+inline
+Col<eT>::fixed<fixed_n_elem>::fixed(const std::string& text)
+  {
+  arma_extra_debug_sigprint_this(this);
+  
+  mem_setup();
+  
+  change_to_row();
+  
+  Col<eT>::operator=(text);
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+template<typename T1>
+const Col<eT>&
+Col<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A)
+  {
+  arma_extra_debug_sigprint();
+  
+  Col<eT>::operator=(A.get_ref());
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+const Col<eT>&
+Col<eT>::fixed<fixed_n_elem>::operator=(const eT val)
+  {
+  arma_extra_debug_sigprint();
+  
+  Col<eT>::operator=(val);
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+const Col<eT>&
+Col<eT>::fixed<fixed_n_elem>::operator=(const char* text)
+  {
+  arma_extra_debug_sigprint();
+  
+  change_to_row();
+  
+  Col<eT>::operator=(text);
+  
+  return *this; 
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+const Col<eT>&
+Col<eT>::fixed<fixed_n_elem>::operator=(const std::string& text)
+  {
+  arma_extra_debug_sigprint();
+  
+  change_to_row();
+  
+  Col<eT>::operator=(text);
+  
+  return *this; 
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+const Col<eT>&
+Col<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X)
+  {
+  arma_extra_debug_sigprint();
+  
+  Col<eT>::operator=(X);
+  
+  return *this; 
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+inline
 subview_row<eT>
 Col<eT>::fixed<fixed_n_elem>::operator()(const u32 row_num, const span& col_span)
   {
@@ -681,9 +884,33 @@
 arma_inline
 arma_warn_unused
 eT&
+Col<eT>::fixed<fixed_n_elem>::operator[] (const u32 i)
+  {
+  return access::rw( Mat<eT>::mem[i] );
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+arma_inline
+arma_warn_unused
+eT
+Col<eT>::fixed<fixed_n_elem>::operator[] (const u32 i) const
+  {
+  return ( Mat<eT>::mem[i] );
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+arma_inline
+arma_warn_unused
+eT&
 Col<eT>::fixed<fixed_n_elem>::at(const u32 i)
   {
-  return access::rw(Mat<eT>::mem[i]);
+  return access::rw( Mat<eT>::mem[i] );
   }
 
 
@@ -695,7 +922,7 @@
 eT
 Col<eT>::fixed<fixed_n_elem>::at(const u32 i) const
   {
-  return Mat<eT>::mem[i];
+  return ( Mat<eT>::mem[i] );
   }
 
 
@@ -708,7 +935,8 @@
 Col<eT>::fixed<fixed_n_elem>::operator() (const u32 i)
   {
   arma_debug_check( (i >= fixed_n_elem), "Col::fixed::operator(): out of bounds");
-  return access::rw(Mat<eT>::mem[i]);
+  
+  return access::rw( Mat<eT>::mem[i] );
   }
 
 
@@ -721,7 +949,8 @@
 Col<eT>::fixed<fixed_n_elem>::operator() (const u32 i) const
   {
   arma_debug_check( (i >= fixed_n_elem), "Col::fixed::operator(): out of bounds");
-  return Mat<eT>::mem[i];
+  
+  return ( Mat<eT>::mem[i] );
   }
 
 
@@ -733,7 +962,7 @@
 eT&
 Col<eT>::fixed<fixed_n_elem>::at(const u32 in_row, const u32 in_col)
   {
-  return access::rw(Mat<eT>::mem[in_row]);
+  return access::rw( Mat<eT>::mem[in_row] );
   }
 
 
@@ -745,7 +974,7 @@
 eT
 Col<eT>::fixed<fixed_n_elem>::at(const u32 in_row, const u32 in_col) const
   {
-  return Mat<eT>::mem[in_row];
+  return ( Mat<eT>::mem[in_row] );
   }
 
 
@@ -758,7 +987,8 @@
 Col<eT>::fixed<fixed_n_elem>::operator() (const u32 in_row, const u32 in_col)
   {
   arma_debug_check( ((in_row >= fixed_n_elem) || (in_col >= 1)), "Col::fixed::operator(): out of bounds" );
-  return access::rw(Mat<eT>::mem[in_row]);
+  
+  return access::rw( Mat<eT>::mem[in_row] );
   }
 
 
@@ -771,11 +1001,60 @@
 Col<eT>::fixed<fixed_n_elem>::operator() (const u32 in_row, const u32 in_col) const
   {
   arma_debug_check( ((in_row >= fixed_n_elem) || (in_col >= 1)), "Col::fixed::operator(): out of bounds" );
-  return Mat<eT>::mem[in_row];
+  
+  return ( Mat<eT>::mem[in_row] );
   }
 
 
 
+template<typename eT>
+template<u32 fixed_n_elem>
+arma_hot
+inline
+const Col<eT>&
+Col<eT>::fixed<fixed_n_elem>::fill(const eT val)
+  {
+  arma_extra_debug_sigprint();
+  
+  arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem );
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+arma_hot
+inline
+const Col<eT>&
+Col<eT>::fixed<fixed_n_elem>::zeros()
+  {
+  arma_extra_debug_sigprint();
+  
+  arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem );
+  
+  return *this;
+  }
+
+
+
+template<typename eT>
+template<u32 fixed_n_elem>
+arma_hot
+inline
+const Col<eT>&
+Col<eT>::fixed<fixed_n_elem>::ones()
+  {
+  arma_extra_debug_sigprint();
+  
+  arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem );
+  
+  return *this;
+  }
+
+
+
 #ifdef ARMA_EXTRA_COL_MEAT
   #include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_MEAT)
 #endif

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp	2011-05-24 16:18:18 UTC (rev 3030)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp	2011-05-25 01:04:14 UTC (rev 3031)
@@ -43,7 +43,7 @@
     access::rw(mem)          = 0;
     }
   
-  isnt_supported_elem_type<eT>::check();
+  arma_type_check< is_supported_elem_type<eT>::value == false >::apply();
   }
 
 
@@ -98,8 +98,30 @@
   
   if(same_size == false)
     {
-    arma_debug_check( (mem_state == 3), "Cube::init(): size can't be changed as template based size specification is in use" );
+    const u32 t_mem_state = mem_state;
     
+    bool  err_state = false;
+    char* err_msg   = 0;
+    
+    arma_debug_set_error
+      (
+      err_state,
+      err_msg,
+      (t_mem_state == 3),
+      "Cube::init(): size is fixed and hence cannot be changed"
+      );
+    
+    arma_debug_set_error
+      (
+      err_state,
+      err_msg,
+      (double(in_n_rows) * double(in_n_cols) * double(in_n_slices)) > double(0xFFFFFFFF), 
+      "Cube::init(): requested size is too large"
+      );
+    
+    arma_debug_check(err_state, err_msg);
+    
+    
     const u32 old_n_elem = n_elem;
     const u32 new_n_elem = in_n_rows * in_n_cols * in_n_slices;
     
@@ -122,11 +144,11 @@
       }
     else
       {
-      arma_debug_check( (mem_state == 2), "Cube::init(): requested size is not compatible with the size of auxiliary memory" );
+      arma_debug_check( (t_mem_state == 2), "Cube::init(): requested size is not compatible with the size of auxiliary memory" );
       
       delete_mat();
       
-      if(mem_state == 0)
+      if(t_mem_state == 0)
         {
         if(n_elem > Cube_prealloc::mem_n_elem )
           {
@@ -197,7 +219,7 @@
   arma_type_check< is_complex<eT>::value == false >::apply();   //!< compile-time abort if eT isn't std::complex
   arma_type_check< is_complex< T>::value == true  >::apply();   //!< compile-time abort if T is std::complex
   
-  isnt_same_type<std::complex<T>, eT>::check();   //!< compile-time abort if types are not compatible
+  arma_type_check< is_same_type< std::complex<T>, eT >::value == false >::apply();   //!< compile-time abort if types are not compatible
   
   const ProxyCube<T1> X(A.get_ref());
   const ProxyCube<T2> Y(B.get_ref());
@@ -1101,7 +1123,7 @@
   {
   arma_extra_debug_sigprint_this(this);
 
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   op_type::apply(*this, X);
   }
@@ -1117,7 +1139,7 @@
   {
   arma_extra_debug_sigprint();
 
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   op_type::apply(*this, X);
   
@@ -1135,7 +1157,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   const Cube<eT> m(X);
   
@@ -1153,7 +1175,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   const Cube<eT> m(X);
   
@@ -1171,7 +1193,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   const Cube<eT> m(X);
   
@@ -1189,7 +1211,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   const Cube<eT> m(X);
   
@@ -1214,7 +1236,7 @@
   {
   arma_extra_debug_sigprint_this(this);
 
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   eop_type::apply(*this, X);
   }
@@ -1230,7 +1252,7 @@
   {
   arma_extra_debug_sigprint();
 
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   eop_type::apply(*this, X);
   
@@ -1248,7 +1270,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   eop_type::apply_inplace_plus(*this, X);
   
@@ -1266,7 +1288,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   eop_type::apply_inplace_minus(*this, X);
   
@@ -1284,7 +1306,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
 
   eop_type::apply_inplace_schur(*this, X);
   
@@ -1302,7 +1324,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
 
   eop_type::apply_inplace_div(*this, X);
   
@@ -1441,8 +1463,8 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
-  isnt_same_type<eT, typename T2::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
+  arma_type_check< is_same_type< eT, typename T2::elem_type >::value == false >::apply();
   
   glue_type::apply(*this, X);
   
@@ -1459,8 +1481,8 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
-  isnt_same_type<eT, typename T2::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
+  arma_type_check< is_same_type< eT, typename T2::elem_type >::value == false >::apply();
   
   const Cube<eT> m(X);
   
@@ -1478,8 +1500,8 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
-  isnt_same_type<eT, typename T2::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
+  arma_type_check< is_same_type< eT, typename T2::elem_type >::value == false >::apply();
   
   const Cube<eT> m(X);
   
@@ -1497,8 +1519,8 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
-  isnt_same_type<eT, typename T2::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
+  arma_type_check< is_same_type< eT, typename T2::elem_type >::value == false >::apply();
   
   const Cube<eT> m(X);
   
@@ -1516,8 +1538,8 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
-  isnt_same_type<eT, typename T2::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
+  arma_type_check< is_same_type< eT, typename T2::elem_type >::value == false >::apply();
   
   const Cube<eT> m(X);
   
@@ -1555,8 +1577,8 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
-  isnt_same_type<eT, typename T2::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
+  arma_type_check< is_same_type< eT, typename T2::elem_type >::value == false >::apply();
   
   eglue_type::apply(*this, X);
   
@@ -1573,8 +1595,8 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
-  isnt_same_type<eT, typename T2::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
+  arma_type_check< is_same_type< eT, typename T2::elem_type >::value == false >::apply();
   
   eglue_type::apply_inplace_plus(*this, X);
   
@@ -1592,8 +1614,8 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
-  isnt_same_type<eT, typename T2::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
+  arma_type_check< is_same_type< eT, typename T2::elem_type >::value == false >::apply();
   
   eglue_type::apply_inplace_minus(*this, X);
   
@@ -1611,8 +1633,8 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
-  isnt_same_type<eT, typename T2::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
+  arma_type_check< is_same_type< eT, typename T2::elem_type >::value == false >::apply();
   
   eglue_type::apply_inplace_schur(*this, X);
   
@@ -1630,8 +1652,8 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
-  isnt_same_type<eT, typename T2::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
+  arma_type_check< is_same_type< eT, typename T2::elem_type >::value == false >::apply();
   
   eglue_type::apply_inplace_div(*this, X);
   

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp	2011-05-24 16:18:18 UTC (rev 3030)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp	2011-05-25 01:04:14 UTC (rev 3031)
@@ -428,36 +428,40 @@
     {
     private:
     
-    static const u32 fixed_n_elem = fixed_n_rows * fixed_n_cols;
+    static const u32  fixed_n_elem = fixed_n_rows * fixed_n_cols;
+    static const bool use_extra    = (fixed_n_elem > arma_config::mat_prealloc);
     
-    arma_aligned eT mem_local_extra[ (fixed_n_elem > arma_config::mat_prealloc) ? fixed_n_elem : 1 ];
+    arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ];
     
     arma_inline void mem_setup();
     
     
     public:
     
-    inline fixed() { mem_setup(); }
+    static const u32 n_rows = fixed_n_rows;
+    static const u32 n_cols = fixed_n_cols;
+    static const u32 n_elem = fixed_n_elem;
     
-    inline                fixed(const char*        text) { mem_setup(); Mat<eT>::operator=(text);               }
-    inline const Mat& operator=(const char*        text) {              Mat<eT>::operator=(text); return *this; }
-    inline                fixed(const std::string& text) { mem_setup(); Mat<eT>::operator=(text);               }
-    inline const Mat& operator=(const std::string& text) {              Mat<eT>::operator=(text); return *this; }
     
-    inline const Mat& operator=(const eT val) { Mat<eT>::operator=(val); return *this; }
+    arma_inline fixed();
+    arma_inline fixed(const fixed<fixed_n_rows, fixed_n_cols>& X);
     
-    template<typename T1>
-    inline fixed(const Base<eT,T1>& A) { mem_setup(); Mat<eT>::operator=(A.get_ref()); }
+    template<typename T1>              inline fixed(const Base<eT,T1>& A);
+    template<typename T1, typename T2> inline fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
     
-    template<typename T1>
-    inline const Mat& operator=(const Base<eT,T1>& A) { Mat<eT>::operator=(A.get_ref()); return *this; }
-    
-    template<typename T1, typename T2>
-    inline explicit fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B) { mem_setup(); Mat<eT>::init(A,B); }
-    
     inline fixed(      eT* aux_mem, const bool copy_aux_mem = true);
     inline fixed(const eT* aux_mem);
     
+    inline fixed(const char*        text);
+    inline fixed(const std::string& text);
+    
+    template<typename T1> inline const Mat& operator=(const Base<eT,T1>& A);
+    
+    inline const Mat& operator=(const eT val);
+    inline const Mat& operator=(const char*        text);
+    inline const Mat& operator=(const std::string& text);
+    
+    
     inline       subview_row<eT> operator()(const u32   row_num,  const span& col_span);
     inline const subview_row<eT> operator()(const u32   row_num,  const span& col_span) const;
     
@@ -467,6 +471,9 @@
     inline       subview<eT>     operator()(const span& row_span, const span& col_span);
     inline const subview<eT>     operator()(const span& row_span, const span& col_span) const;
     
+    
+    arma_inline arma_warn_unused eT& operator[] (const u32 i);
+    arma_inline arma_warn_unused eT  operator[] (const u32 i) const;
     arma_inline arma_warn_unused eT& at         (const u32 i);
     arma_inline arma_warn_unused eT  at         (const u32 i) const;
     arma_inline arma_warn_unused eT& operator() (const u32 i);
@@ -476,6 +483,11 @@
     arma_inline arma_warn_unused eT  at         (const u32 in_row, const u32 in_col) const;
     arma_inline arma_warn_unused eT& operator() (const u32 in_row, const u32 in_col);
     arma_inline arma_warn_unused eT  operator() (const u32 in_row, const u32 in_col) const;
+    
+    
+    arma_hot inline const Mat<eT>& fill(const eT val);
+    arma_hot inline const Mat<eT>& zeros();
+    arma_hot inline const Mat<eT>& ones();
     };
   
   

Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp	2011-05-24 16:18:18 UTC (rev 3030)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp	2011-05-25 01:04:14 UTC (rev 3031)
@@ -38,7 +38,7 @@
     access::rw(mem)    = 0;
     }
   
-  isnt_supported_elem_type<eT>::check();
+  arma_type_check< is_supported_elem_type<eT>::value == false >::apply();
   }
 
 
@@ -93,14 +93,21 @@
     const u32 t_vec_state = vec_state;
     const u32 t_mem_state = mem_state;
     
-    arma_debug_check
+    bool  err_state = false;
+    char* err_msg   = 0;
+    
+    arma_debug_set_error
       (
+      err_state,
+      err_msg,
       (t_mem_state == 3),
       "Mat::init(): size is fixed and hence cannot be changed"
       );
     
-    arma_debug_check
+    arma_debug_set_error
       (
+      err_state,
+      err_msg,
         (
         (t_vec_state > 0) &&
           (
@@ -108,21 +115,23 @@
           ((t_vec_state == 2) && (in_n_rows > 1))
           )
         ),
-      "Mat::init(): object is a row or column vector; requested size is not compatible"
+      "Mat::init(): object is a vector; requested size is not compatible"
       );
     
     
-    // ensure that n_elem can hold the result of (n_rows * n_cols);
-    // on systems where sizeof(u32)*CHAR_BIT > 32,
-    // the code below in effect also checks for in_n_rows > 0xFFFFFFFF
-    arma_debug_check
+    // 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
       (
-      // (double(in_n_rows) * double(in_n_cols)) > double(0xFFFFFFFF), 
-      ( 0xFFFFFFFF / ((in_n_rows > 0) ? in_n_rows : 1) ) < in_n_cols,
+      err_state,
+      err_msg,
+      (double(in_n_rows) * double(in_n_cols)) > double(0xFFFFFFFF), 
       "Mat::init(): requested size is too large"
       );
     
+    arma_debug_check(err_state, err_msg);
     
+    
     const u32 old_n_elem = n_elem;
     const u32 new_n_elem = in_n_rows * in_n_cols;
     
@@ -138,7 +147,7 @@
       arma_debug_check
         (
         (t_mem_state == 2),
-        "Mat::init(): requested size is not compatible with the size of auxiliary memory"
+        "Mat::init(): mismatch between size of auxiliary memory and requested size"
         );
       
       if(t_mem_state == 0)
@@ -484,7 +493,7 @@
   arma_type_check< is_complex<eT>::value == false >::apply();   //!< compile-time abort if eT isn't std::complex
   arma_type_check< is_complex< T>::value == true  >::apply();   //!< compile-time abort if T is std::complex
   
-  isnt_same_type<std::complex<T>, eT>::check();   //!< compile-time abort if types are not compatible
+  arma_type_check< is_same_type< std::complex<T>, eT >::value == false >::apply();   //!< compile-time abort if types are not compatible
   
   const Proxy<T1> X(A.get_ref());
   const Proxy<T2> Y(B.get_ref());
@@ -2092,11 +2101,11 @@
   {
   arma_extra_debug_sigprint();
   
-  const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0;
-  const u32 col_offset = (in_id > 0) ? u32( in_id) : 0;
-  
   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),
@@ -2123,19 +2132,25 @@
   {
   arma_extra_debug_sigprint();
   
-  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);
+  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);
+    }
   }
 
 
@@ -2488,7 +2503,7 @@
   {
   arma_extra_debug_sigprint_this(this);
 
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   op_type::apply(*this, X);
   }
@@ -2504,7 +2519,7 @@
   {
   arma_extra_debug_sigprint();
 
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   op_type::apply(*this, X);
   
@@ -2522,7 +2537,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   const Mat<eT> m(X);
   
@@ -2540,7 +2555,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
+  arma_type_check< is_same_type< eT, typename T1::elem_type >::value == false >::apply();
   
   const Mat<eT> m(X);
   
@@ -2558,7 +2573,7 @@
   {
   arma_extra_debug_sigprint();
   
-  isnt_same_type<eT, typename T1::elem_type>::check();
[TRUNCATED]

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


More information about the Rcpp-commits mailing list