[Rcpp-commits] r3407 - in pkg/RcppArmadillo: . inst inst/include inst/include/armadillo_bits
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Dec 7 17:08:27 CET 2011
Author: edd
Date: 2011-12-07 17:08:27 +0100 (Wed, 07 Dec 2011)
New Revision: 3407
Added:
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_resize.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/op_resize_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/op_resize_meat.hpp
Modified:
pkg/RcppArmadillo/ChangeLog
pkg/RcppArmadillo/DESCRIPTION
pkg/RcppArmadillo/inst/NEWS
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_bones.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/Row_bones.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp
Log:
RcppArmadillo 0.2.33 containing Armadillo 2.4.1
Modified: pkg/RcppArmadillo/ChangeLog
===================================================================
--- pkg/RcppArmadillo/ChangeLog 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/ChangeLog 2011-12-07 16:08:27 UTC (rev 3407)
@@ -1,3 +1,9 @@
+2011-12-07 Dirk Eddelbuettel <edd at debian.org>
+
+ * DESCRIPTION: Release 0.2.33
+
+ * inst/include/*: Upgraded to new test release 2.4.1 of Armadillo
+
2011-12-04 Dirk Eddelbuettel <edd at debian.org>
* DESCRIPTION: Release 0.2.32
Modified: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/DESCRIPTION 2011-12-07 16:08:27 UTC (rev 3407)
@@ -1,7 +1,7 @@
Package: RcppArmadillo
Type: Package
Title: Rcpp integration for Armadillo templated linear algebra library
-Version: 0.2.32
+Version: 0.2.33
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 2.4.0). Thus users do not need to
+ Armadillo library (currently version 2.4.1). 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-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/NEWS 2011-12-07 16:08:27 UTC (rev 3407)
@@ -1,3 +1,10 @@
+0.2.33 2011-12-07
+
+ o Upgraded to Armadillo release 2.4.1
+
+ * added .resize()
+ * fix for vector initialisation
+
0.2.32 2011-12-04
o Upgraded to Armadillo test release 2.4.0 "Loco Lounge Lizard"
Modified: pkg/RcppArmadillo/inst/include/armadillo
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/include/armadillo 2011-12-07 16:08:27 UTC (rev 3407)
@@ -177,6 +177,7 @@
#include "armadillo_bits/op_var_bones.hpp"
#include "armadillo_bits/op_repmat_bones.hpp"
#include "armadillo_bits/op_reshape_bones.hpp"
+ #include "armadillo_bits/op_resize_bones.hpp"
#include "armadillo_bits/op_cov_bones.hpp"
#include "armadillo_bits/op_cor_bones.hpp"
#include "armadillo_bits/op_shuffle_bones.hpp"
@@ -326,6 +327,7 @@
#include "armadillo_bits/fn_solve.hpp"
#include "armadillo_bits/fn_repmat.hpp"
#include "armadillo_bits/fn_reshape.hpp"
+ #include "armadillo_bits/fn_resize.hpp"
#include "armadillo_bits/fn_cov.hpp"
#include "armadillo_bits/fn_cor.hpp"
#include "armadillo_bits/fn_shuffle.hpp"
@@ -396,6 +398,7 @@
#include "armadillo_bits/op_var_meat.hpp"
#include "armadillo_bits/op_repmat_meat.hpp"
#include "armadillo_bits/op_reshape_meat.hpp"
+ #include "armadillo_bits/op_resize_meat.hpp"
#include "armadillo_bits/op_cov_meat.hpp"
#include "armadillo_bits/op_cor_meat.hpp"
#include "armadillo_bits/op_shuffle_meat.hpp"
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -26,6 +26,7 @@
inline Col();
+ inline Col(const Col<eT>& X);
inline explicit Col(const uword n_elem);
inline Col(const uword in_rows, const uword in_cols);
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -28,6 +28,20 @@
+template<typename eT>
+inline
+Col<eT>::Col(const Col<eT>& X)
+ : Mat<eT>(X.n_elem, 1)
+ {
+ arma_extra_debug_sigprint();
+
+ access::rw(Mat<eT>::vec_state) = 1;
+
+ arrayops::copy((*this).memptr(), X.memptr(), X.n_elem);
+ }
+
+
+
//! construct a column vector with the specified number of n_elem
template<typename eT>
inline
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_bones.hpp 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_bones.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -211,6 +211,7 @@
inline void set_size(const uword in_rows, const uword in_cols, const uword in_slices);
inline void reshape(const uword in_rows, const uword in_cols, const uword in_slices, const uword dim = 0);
+ inline void resize(const uword in_rows, const uword in_cols, const uword in_slices);
template<typename eT2> inline void copy_size(const Cube<eT2>& m);
@@ -322,8 +323,9 @@
inline void delete_mat();
inline void create_mat();
+ friend class glue_join;
friend class op_reshape;
- friend class glue_join;
+ friend class op_resize;
public:
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -2433,6 +2433,19 @@
+//! change the cube to have user specified dimensions (data is preserved)
+template<typename eT>
+inline
+void
+Cube<eT>::resize(const uword in_rows, const uword in_cols, const uword in_slices)
+ {
+ arma_extra_debug_sigprint();
+
+ *this = arma::resize(*this, in_rows, in_cols, in_slices);
+ }
+
+
+
//! change the cube (without preserving data) to have the same dimensions as the given cube
template<typename eT>
template<typename eT2>
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -305,10 +305,14 @@
template<typename eT2>
inline void copy_size(const Mat<eT2>& m);
- inline void set_size(const uword in_elem);
- inline void set_size(const uword in_rows, const uword in_cols);
- inline void reshape(const uword in_rows, const uword in_cols, const uword dim = 0);
+ inline void set_size(const uword in_elem);
+ inline void set_size(const uword in_rows, const uword in_cols);
+ inline void resize(const uword in_elem);
+ inline void resize(const uword in_rows, const uword in_cols);
+ inline void reshape(const uword in_rows, const uword in_cols, const uword dim = 0);
+
+
arma_hot inline const Mat& fill(const eT val);
inline const Mat& zeros();
@@ -531,6 +535,7 @@
friend class glue_join;
friend class op_strans;
friend class op_htrans;
+ friend class op_resize;
public:
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -4247,6 +4247,45 @@
template<typename eT>
inline
void
+Mat<eT>::resize(const uword in_elem)
+ {
+ arma_extra_debug_sigprint();
+
+ switch(vec_state)
+ {
+ case 0:
+ case 1:
+ (*this).resize(in_elem, 1);
+ break;
+
+ case 2:
+ (*this).resize(1, in_elem);
+ break;
+
+ default:
+ ;
+ }
+ }
+
+
+
+//! change the matrix to have user specified dimensions (data is preserved)
+template<typename eT>
+inline
+void
+Mat<eT>::resize(const uword in_rows, const uword in_cols)
+ {
+ arma_extra_debug_sigprint();
+
+ *this = arma::resize(*this, in_rows, in_cols);
+ }
+
+
+
+//! change the matrix to have user specified dimensions (data is preserved)
+template<typename eT>
+inline
+void
Mat<eT>::reshape(const uword in_rows, const uword in_cols, const uword dim)
{
arma_extra_debug_sigprint();
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -26,6 +26,7 @@
inline Row();
+ inline Row(const Row<eT>& X);
inline explicit Row(const uword N);
inline Row(const uword in_rows, const uword in_cols);
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -15,7 +15,7 @@
//! @{
-
+//! construct an empty row vector
template<typename eT>
inline
Row<eT>::Row()
@@ -30,6 +30,21 @@
template<typename eT>
inline
+Row<eT>::Row(const Row<eT>& X)
+ : Mat<eT>(1, X.n_elem)
+ {
+ arma_extra_debug_sigprint();
+
+ access::rw(Mat<eT>::vec_state) = 2;
+
+ arrayops::copy((*this).memptr(), X.memptr(), X.n_elem);
+ }
+
+
+
+//! construct a row vector with the specified number of n_elem
+template<typename eT>
+inline
Row<eT>::Row(const uword in_n_elem)
: Mat<eT>(1, in_n_elem)
{
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp 2011-12-05 11:28:22 UTC (rev 3406)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -18,7 +18,7 @@
#define ARMA_VERSION_MAJOR 2
#define ARMA_VERSION_MINOR 4
-#define ARMA_VERSION_PATCH 0
+#define ARMA_VERSION_PATCH 1
#define ARMA_VERSION_NAME "Loco Lounge Lizard"
Added: pkg/RcppArmadillo/inst/include/armadillo_bits/fn_resize.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/fn_resize.hpp (rev 0)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/fn_resize.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -0,0 +1,43 @@
+// Copyright (C) 2011 NICTA (www.nicta.com.au)
+// Copyright (C) 2011 Conrad Sanderson
+//
+// This file is part of the Armadillo C++ library.
+// It is provided without any warranty of fitness
+// for any purpose. You can redistribute this file
+// and/or modify it under the terms of the GNU
+// Lesser General Public License (LGPL) as published
+// by the Free Software Foundation, either version 3
+// of the License or (at your option) any later version.
+// (see http://www.opensource.org/licenses for more info)
+
+
+//! \addtogroup fn_resize
+//! @{
+
+
+
+template<typename T1>
+inline
+const Op<T1, op_resize>
+resize(const Base<typename T1::elem_type,T1>& X, const uword in_n_rows, const uword in_n_cols)
+ {
+ arma_extra_debug_sigprint();
+
+ return Op<T1, op_resize>(X.get_ref(), in_n_rows, in_n_cols);
+ }
+
+
+
+template<typename T1>
+inline
+const OpCube<T1, op_resize>
+resize(const BaseCube<typename T1::elem_type,T1>& X, const uword in_n_rows, const uword in_n_cols, const uword in_n_slices)
+ {
+ arma_extra_debug_sigprint();
+
+ return OpCube<T1, op_resize>(X.get_ref(), in_n_rows, in_n_cols, in_n_slices);
+ }
+
+
+
+//! @}
Added: pkg/RcppArmadillo/inst/include/armadillo_bits/op_resize_bones.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/op_resize_bones.hpp (rev 0)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/op_resize_bones.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -0,0 +1,30 @@
+// Copyright (C) 2011 NICTA (www.nicta.com.au)
+// Copyright (C) 2011 Conrad Sanderson
+//
+// This file is part of the Armadillo C++ library.
+// It is provided without any warranty of fitness
+// for any purpose. You can redistribute this file
+// and/or modify it under the terms of the GNU
+// Lesser General Public License (LGPL) as published
+// by the Free Software Foundation, either version 3
+// of the License or (at your option) any later version.
+// (see http://www.opensource.org/licenses for more info)
+
+
+
+//! \addtogroup op_resize
+//! @{
+
+
+
+class op_resize
+ {
+ public:
+
+ template<typename T1> inline static void apply( Mat<typename T1::elem_type>& out, const Op<T1,op_resize>& in);
+ template<typename T1> inline static void apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_resize>& in);
+ };
+
+
+
+//! @}
Added: pkg/RcppArmadillo/inst/include/armadillo_bits/op_resize_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/op_resize_meat.hpp (rev 0)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/op_resize_meat.hpp 2011-12-07 16:08:27 UTC (rev 3407)
@@ -0,0 +1,119 @@
+// Copyright (C) 2011 NICTA (www.nicta.com.au)
+// Copyright (C) 2011 Conrad Sanderson
+//
+// This file is part of the Armadillo C++ library.
+// It is provided without any warranty of fitness
+// for any purpose. You can redistribute this file
+// and/or modify it under the terms of the GNU
+// Lesser General Public License (LGPL) as published
+// by the Free Software Foundation, either version 3
+// of the License or (at your option) any later version.
+// (see http://www.opensource.org/licenses for more info)
+
+
+
+//! \addtogroup op_resize
+//! @{
+
+
+
+template<typename T1>
+inline
+void
+op_resize::apply(Mat<typename T1::elem_type>& actual_out, const Op<T1,op_resize>& in)
+ {
+ arma_extra_debug_sigprint();
+
+ typedef typename T1::elem_type eT;
+
+ const uword out_n_rows = in.aux_uword_a;
+ const uword out_n_cols = in.aux_uword_b;
+
+ const unwrap<T1> tmp(in.m);
+ const Mat<eT>& A = tmp.M;
+
+ const uword A_n_rows = A.n_rows;
+ const uword A_n_cols = A.n_cols;
+
+ Mat<eT> B;
+
+ const bool alias = (&actual_out == &A);
+
+ Mat<eT>& out = alias ? B : actual_out;
+
+ out.set_size(out_n_rows, out_n_cols);
+
+ if( (out_n_rows > A_n_rows) || (out_n_cols > A_n_cols) )
+ {
+ out.zeros();
+ }
+
+ if(out.n_elem > 0)
+ {
+ const uword end_row = (std::min)(out_n_rows, A_n_rows) - 1;
+ const uword end_col = (std::min)(out_n_cols, A_n_cols) - 1;
+
+ out.submat(0, 0, end_row, end_col) = A.submat(0, 0, end_row, end_col);
+ }
+
+ if(alias)
+ {
+ actual_out.steal_mem(B);
+ }
+
+ }
+
+
+
+template<typename T1>
+inline
+void
+op_resize::apply(Cube<typename T1::elem_type>& actual_out, const OpCube<T1,op_resize>& in)
+ {
+ arma_extra_debug_sigprint();
+
+ typedef typename T1::elem_type eT;
+
+ const uword out_n_rows = in.aux_uword_a;
+ const uword out_n_cols = in.aux_uword_b;
+ const uword out_n_slices = in.aux_uword_c;
+
+ const unwrap_cube<T1> tmp(in.m);
+ const Cube<eT>& A = tmp.M;
+
+ const uword A_n_rows = A.n_rows;
+ const uword A_n_cols = A.n_cols;
+ const uword A_n_slices = A.n_slices;
+
+ Cube<eT> B;
+
+ const bool alias = (&actual_out == &A);
+
+ Cube<eT>& out = alias ? B : actual_out;
+
+ out.set_size(out_n_rows, out_n_cols, out_n_slices);
+
+ if( (out_n_rows > A_n_rows) || (out_n_cols > A_n_cols) || (out_n_slices > A_n_slices) )
+ {
+ out.zeros();
+ }
+
+ if(out.n_elem > 0)
+ {
+ const uword end_row = (std::min)(out_n_rows, A_n_rows) - 1;
+ const uword end_col = (std::min)(out_n_cols, A_n_cols) - 1;
+ const uword end_slice = (std::min)(out_n_slices, A_n_slices) - 1;
+
+ out.subcube(0, 0, 0, end_row, end_col, end_slice) = A.subcube(0, 0, 0, end_row, end_col, end_slice);
+ }
+
+ if(alias)
+ {
+ actual_out.steal_mem(B);
+ }
+
+ }
+
+
+
+//! @}
More information about the Rcpp-commits
mailing list