[Rcpp-commits] r2923 - in pkg/RcppArmadillo: . inst inst/include inst/include/armadillo_bits
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Mar 10 19:54:13 CET 2011
Author: edd
Date: 2011-03-10 19:54:12 +0100 (Thu, 10 Mar 2011)
New Revision: 2923
Modified:
pkg/RcppArmadillo/ChangeLog
pkg/RcppArmadillo/DESCRIPTION
pkg/RcppArmadillo/inst/NEWS
pkg/RcppArmadillo/inst/include/armadillo
pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_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/arrayops_proto.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/auxlib_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/constants.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/eglue_core_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/eop_aux.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/eop_core_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/eop_core_proto.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_elem.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_misc.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/fn_norm.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/format_wrap.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_min_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/op_var_meat.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/restrictors.hpp
pkg/RcppArmadillo/inst/include/armadillo_bits/traits.hpp
Log:
RcppArmadillo 0.2.16 with Armadillo 1.1.8
Modified: pkg/RcppArmadillo/ChangeLog
===================================================================
--- pkg/RcppArmadillo/ChangeLog 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/ChangeLog 2011-03-10 18:54:12 UTC (rev 2923)
@@ -1,3 +1,9 @@
+2011-03-10 Dirk Eddelbuettel <edd at debian.org>
+
+ * DESCRIPTION: Release 0.2.16
+
+ * inst/include/*: Updated to Armadillo 1.1.8 "Kangaroo Steak"
+
2011-03-04 Dirk Eddelbuettel <edd at debian.org>
* DESCRIPTION: Release 0.2.15
Modified: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/DESCRIPTION 2011-03-10 18:54:12 UTC (rev 2923)
@@ -1,7 +1,7 @@
Package: RcppArmadillo
Type: Package
Title: Rcpp integration for Armadillo templated linear algebra library
-Version: 0.2.15
+Version: 0.2.16
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.4). Thus users do not need to
+ Armadillo library (currently version 1.1.8). 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-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/NEWS 2011-03-10 18:54:12 UTC (rev 2923)
@@ -1,3 +1,14 @@
+0.2.16 2011-03-10
+
+ o Upgraded to Armadillo Version 1.1.8 "Kangaroo Steak"
+
+ * Added floor() and ceil()
+ * Added “not a number”: math::nan()
+ * Added infinity: math::inf()
+ * Added standalone is_finite()
+ * Faster min(), max(), mean()
+ * Bugfix for a corner case with NaNs in min() and max()
+
0.2.15 2011-03-04
o Upgraded to Armadillo Version 1.1.6 “Baby Carpet Shark”
Modified: pkg/RcppArmadillo/inst/include/armadillo
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo 2011-03-10 18:54:12 UTC (rev 2923)
@@ -109,7 +109,6 @@
#include "armadillo_bits/arma_static_assert.hpp"
#include "armadillo_bits/typedef.hpp"
#include "armadillo_bits/format_wrap.hpp"
- #include "armadillo_bits/constants.hpp"
#include "armadillo_bits/arma_version.hpp"
#include "armadillo_bits/arma_config.hpp"
#include "armadillo_bits/traits.hpp"
@@ -118,6 +117,7 @@
#include "armadillo_bits/restrictors.hpp"
#include "armadillo_bits/access.hpp"
#include "armadillo_bits/span.hpp"
+ #include "armadillo_bits/constants.hpp"
//
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp 2011-03-10 18:54:12 UTC (rev 2923)
@@ -1933,15 +1933,7 @@
bool
Cube<eT>::is_finite() const
{
- for(u32 i=0; i<n_elem; ++i)
- {
- if(arma_isfinite(mem[i]) == false)
- {
- return false;
- }
- }
-
- return true;
+ return arrayops::is_finite( memptr(), n_elem );
}
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2011-03-10 18:54:12 UTC (rev 2923)
@@ -2087,8 +2087,8 @@
{
arma_extra_debug_sigprint();
- const u32 row_offset = (in_id < 0) ? -in_id : 0;
- const u32 col_offset = (in_id > 0) ? in_id : 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
(
@@ -3460,31 +3460,7 @@
bool
Mat<eT>::is_finite() const
{
- const u32 N = n_elem;
- const eT* ptr = memptr();
-
- u32 i,j;
-
- for(i=0, j=1; j<N; i+=2, j+=2)
- {
- const eT val_i = ptr[i];
- const eT val_j = ptr[j];
-
- if( (arma_isfinite(val_i) == false) || (arma_isfinite(val_j) == false) )
- {
- return false;
- }
- }
-
- if(i<N)
- {
- if(arma_isfinite(ptr[i]) == false)
- {
- return false;
- }
- }
-
- return true;
+ return arrayops::is_finite( memptr(), n_elem );
}
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_meat.hpp 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_meat.hpp 2011-03-10 18:54:12 UTC (rev 2923)
@@ -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
@@ -142,6 +142,22 @@
+template<typename eT>
+inline
+void
+arma_ostream::print_elem_zero(std::ostream& o)
+ {
+ const std::streamsize orig_precision = o.precision();
+
+ o.precision(0);
+
+ o << eT(0);
+
+ o.precision(orig_precision);
+ }
+
+
+
//! Print an element to the specified stream
template<typename eT>
arma_inline
@@ -154,22 +170,15 @@
}
else
{
- const std::streamsize orig_precision = o.precision();
-
- o.precision(0);
-
- o << eT(0);
-
- o.precision(orig_precision);
+ arma_ostream::print_elem_zero<eT>(o);
}
}
//! Print a complex element to the specified stream
-//! EXPERIMENTAL !
template<typename T>
-arma_inline
+inline
void
arma_ostream::print_elem(std::ostream& o, const std::complex<T>& x)
{
@@ -200,45 +209,42 @@
arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o);
-
- u32 cell_width;
- if(modify == true)
- {
- cell_width = arma_ostream::modify_stream(o, m.memptr(), m.n_elem);
- }
- else
- {
- cell_width = o.width(); // copy the user's cell width
- }
+ const u32 cell_width = modify ? arma_ostream::modify_stream(o, m.memptr(), m.n_elem) : o.width();
- if(cell_width > 0)
+ const u32 m_n_rows = m.n_rows;
+ const u32 m_n_cols = m.n_cols;
+
+ if(m_n_cols > 0)
{
- for(u32 row=0; row < m.n_rows; ++row)
+ if(cell_width > 0)
{
- for(u32 col=0; col < m.n_cols; ++col)
+ for(u32 row=0; row < m_n_rows; ++row)
{
- // the cell width appears to be reset after each element is printed,
- // hence we need to restore it
- o.width(cell_width);
- arma_ostream::print_elem(o, m.at(row,col));
+ for(u32 col=0; col < m_n_cols; ++col)
+ {
+ // the cell width appears to be reset after each element is printed,
+ // hence we need to restore it
+ o.width(cell_width);
+ arma_ostream::print_elem(o, m.at(row,col));
+ }
+
+ o << '\n';
}
-
- o << '\n';
}
- }
- else
- {
- for(u32 row=0; row < m.n_rows; ++row)
+ else
{
- for(u32 col=0; col < m.n_cols-1; ++col)
+ for(u32 row=0; row < m_n_rows; ++row)
{
- arma_ostream::print_elem(o, m.at(row,col));
- o << ' ';
+ for(u32 col=0; col < m_n_cols-1; ++col)
+ {
+ arma_ostream::print_elem(o, m.at(row,col));
+ o << ' ';
+ }
+
+ arma_ostream::print_elem(o, m.at(row, m_n_cols-1));
+ o << '\n';
}
-
- arma_ostream::print_elem(o, m.at(row, m.n_cols-1));
- o << '\n';
}
}
@@ -258,17 +264,8 @@
const arma_ostream_state stream_state(o);
- u32 cell_width;
+ const u32 cell_width = modify ? arma_ostream::modify_stream(o, x.memptr(), x.n_elem) : o.width();
- if(modify == true)
- {
- cell_width = arma_ostream::modify_stream(o, x.memptr(), x.n_elem);
- }
- else
- {
- cell_width = o.width();
- }
-
for(u32 slice=0; slice < x.n_slices; ++slice)
{
o << "[cube slice " << slice << ']' << '\n';
@@ -293,13 +290,17 @@
arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o);
-
+
const std::streamsize cell_width = o.width();
-
- for(u32 col=0; col<x.n_cols; ++col)
+
+ const u32 x_n_rows = x.n_rows;
+ const u32 x_n_cols = x.n_cols;
+
+ for(u32 col=0; col<x_n_cols; ++col)
{
o << "[field column " << col << ']' << '\n';
- for(u32 row=0; row<x.n_rows; ++row)
+
+ for(u32 row=0; row<x_n_rows; ++row)
{
o.width(cell_width);
o << x.at(row,col) << '\n';
@@ -327,10 +328,13 @@
const std::streamsize cell_width = o.width();
- for(u32 col=0; col<x.n_cols; ++col)
+ const u32 x_n_rows = x.n_rows;
+ const u32 x_n_cols = x.n_cols;
+
+ for(u32 col=0; col<x_n_cols; ++col)
{
- o << "[subfield column " << col << ']' << '\n';
- for(u32 row=0; row<x.n_rows; ++row)
+ o << "[field column " << col << ']' << '\n';
+ for(u32 row=0; row<x_n_rows; ++row)
{
o.width(cell_width);
o << x.at(row,col) << '\n';
@@ -346,3 +350,4 @@
//! @}
+
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_proto.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_proto.hpp 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_proto.hpp 2011-03-10 18:54:12 UTC (rev 2923)
@@ -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
@@ -42,8 +42,10 @@
template<typename eT> inline static u32 modify_stream(std::ostream& o, const eT* data, const u32 n_elem);
template<typename T> inline static u32 modify_stream(std::ostream& o, const std::complex<T>* data, const u32 n_elem);
+ template<typename eT> inline static void print_elem_zero(std::ostream& o);
+
template<typename eT> arma_inline static void print_elem(std::ostream& o, const eT& x);
- template<typename T> arma_inline static void print_elem(std::ostream& o, const std::complex<T>& x);
+ template<typename T> inline static void print_elem(std::ostream& o, const std::complex<T>& x);
template<typename eT> inline static void print(std::ostream& o, const Mat<eT>& m, const bool modify);
template<typename eT> inline static void print(std::ostream& o, const Cube<eT>& m, const bool modify);
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp 2011-03-10 18:54:12 UTC (rev 2923)
@@ -18,13 +18,11 @@
#define ARMA_VERSION_MAJOR 1
#define ARMA_VERSION_MINOR 1
-#define ARMA_VERSION_PATCH 6
-#define ARMA_VERSION_NAME "Baby Carpet Shark"
+#define ARMA_VERSION_PATCH 8
+#define ARMA_VERSION_NAME "Kangaroo Steak"
-// http://en.wikipedia.org/wiki/Carpet_shark
-
struct arma_version
{
static const unsigned int major = ARMA_VERSION_MAJOR;
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/arrayops_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/arrayops_meat.hpp 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/arrayops_meat.hpp 2011-03-10 18:54:12 UTC (rev 2923)
@@ -431,6 +431,40 @@
arma_hot
arma_pure
inline
+bool
+arrayops::is_finite(const eT* src, const u32 n_elem)
+ {
+ u32 i,j;
+
+ for(i=0, j=1; j<n_elem; i+=2, j+=2)
+ {
+ const eT val_i = src[i];
+ const eT val_j = src[j];
+
+ if( (arma_isfinite(val_i) == false) || (arma_isfinite(val_j) == false) )
+ {
+ return false;
+ }
+ }
+
+ if(i < n_elem)
+ {
+ if(arma_isfinite(src[i]) == false)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+
+// TODO: this function is currently not used
+template<typename eT>
+arma_hot
+arma_pure
+inline
typename get_pod_type<eT>::result
arrayops::norm_1(const eT* src, const u32 n_elem)
{
@@ -456,6 +490,7 @@
+// TODO: this function is currently not used
template<typename eT>
arma_hot
arma_pure
@@ -490,6 +525,7 @@
+// TODO: this function is currently not used
template<typename T>
arma_hot
arma_pure
@@ -522,6 +558,7 @@
+// TODO: this function is currently not used
template<typename eT>
arma_hot
arma_pure
@@ -551,6 +588,7 @@
+// TODO: this function is currently not used
template<typename eT>
arma_hot
arma_pure
@@ -585,6 +623,7 @@
+// TODO: this function is currently not used
template<typename eT>
arma_hot
arma_pure
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/arrayops_proto.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/arrayops_proto.hpp 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/arrayops_proto.hpp 2011-03-10 18:54:12 UTC (rev 2923)
@@ -115,6 +115,11 @@
template<typename eT>
arma_hot arma_pure inline static
+ bool
+ is_finite(const eT* src, const u32 n_elem);
+
+ template<typename eT>
+ arma_hot arma_pure inline static
typename get_pod_type<eT>::result
norm_1(const eT* src, const u32 n_elem);
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/auxlib_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/auxlib_meat.hpp 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/auxlib_meat.hpp 2011-03-10 18:54:12 UTC (rev 2923)
@@ -877,12 +877,12 @@
for(u32 i=0; i<P_rows; ++i)
{
- ipiv2_mem[i] = i;
+ ipiv2_mem[i] = blas_int(i);
}
for(u32 i=0; i<n; ++i)
{
- const u32 k = ipiv1_mem[i];
+ const u32 k = u32(ipiv1_mem[i]);
if( ipiv2_mem[i] != ipiv2_mem[k] )
{
@@ -894,7 +894,7 @@
for(u32 row=0; row<P_rows; ++row)
{
- P.at(row, ipiv2_mem[row]) = eT(1);
+ P.at(row, u32(ipiv2_mem[row])) = eT(1);
}
if(L.n_cols > U.n_rows)
@@ -930,12 +930,12 @@
for(u32 i=0; i<P_rows; ++i)
{
- ipiv2_mem[i] = i;
+ ipiv2_mem[i] = blas_int(i);
}
for(u32 i=0; i<n; ++i)
{
- const u32 k = ipiv1_mem[i];
+ const u32 k = u32(ipiv1_mem[i]);
if( ipiv2_mem[i] != ipiv2_mem[k] )
{
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/constants.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/constants.hpp 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/constants.hpp 2011-03-10 18:54:12 UTC (rev 2923)
@@ -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
@@ -15,37 +15,143 @@
//! @{
-// the long lengths of the constants are for future support of "long double"
-// and any smart compiler that does high-precision computation at compile-time
+namespace priv
+ {
+ class Math_helper
+ {
+ public:
+
+ template<typename eT>
+ static
+ typename arma_float_only<eT>::result
+ nan(typename arma_float_only<eT>::result* junk = 0)
+ {
+ arma_ignore(junk);
+
+ if(std::numeric_limits<eT>::has_quiet_NaN == true)
+ {
+ return std::numeric_limits<eT>::quiet_NaN();
+ }
+ else
+ {
+ const eT a = eT(0);
+ const eT b = eT(0);
+
+ return a / b;
+ }
+ }
+
+
+ template<typename eT>
+ static
+ typename arma_cx_only<eT>::result
+ nan(typename arma_cx_only<eT>::result* junk = 0)
+ {
+ arma_ignore(junk);
+
+ typedef typename get_pod_type<eT>::result T;
+
+ return eT( Math_helper::nan<T>(), Math_helper::nan<T>() );
+ }
+
+
+ template<typename eT>
+ static
+ typename arma_integral_only<eT>::result
+ nan(typename arma_integral_only<eT>::result* junk = 0)
+ {
+ arma_ignore(junk);
+
+ return eT(0);
+ }
+
+
+ template<typename eT>
+ static
+ typename arma_float_only<eT>::result
+ inf(typename arma_float_only<eT>::result* junk = 0)
+ {
+ arma_ignore(junk);
+
+ if(std::numeric_limits<eT>::has_infinity == true)
+ {
+ return std::numeric_limits<eT>::infinity();
+ }
+ else
+ {
+ const eT a = eT(1);
+ const eT b = eT(0);
+
+ return a / b;
+ }
+ }
+
+
+ template<typename eT>
+ static
+ typename arma_cx_only<eT>::result
+ inf(typename arma_cx_only<eT>::result* junk = 0)
+ {
+ arma_ignore(junk);
+
+ typedef typename get_pod_type<eT>::result T;
+
+ return eT( Math_helper::inf<T>(), Math_helper::inf<T>() );
+ }
+
+ template<typename eT>
+ static
+ typename arma_integral_only<eT>::result
+ inf(typename arma_integral_only<eT>::result* junk = 0)
+ {
+ arma_ignore(junk);
+
+ return std::numeric_limits<eT>::max();
+ }
+
+ };
+ }
+
+
+
template<typename eT>
class Math
{
public:
+ // the long lengths of the constants are for future support of "long double"
+ // and any smart compiler that does high-precision computation at compile-time
+
//! ratio of any circle's circumference to its diameter
- static const eT pi() { return eT(3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679); }
+ static eT pi() { return eT(3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679); }
//! base of the natural logarithm
- static const eT e() { return eT(2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274); }
+ static eT e() { return eT(2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274); }
//! Euler's constant, aka Euler-Mascheroni constant
- static const eT euler() { return eT(0.5772156649015328606065120900824024310421593359399235988057672348848677267776646709369470632917467495); }
+ static eT euler() { return eT(0.5772156649015328606065120900824024310421593359399235988057672348848677267776646709369470632917467495); }
//! golden ratio
- static const eT gratio() { return eT(1.6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374); }
+ static eT gratio() { return eT(1.6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374); }
//! square root of 2
- static const eT sqrt2() { return eT(1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727); }
+ static eT sqrt2() { return eT(1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727); }
//! the difference between 1 and the least value greater than 1 that is representable
- static const eT eps() { return std::numeric_limits<eT>::epsilon(); }
+ static eT eps() { return std::numeric_limits<eT>::epsilon(); }
//! log of the minimum representable value
- static const eT log_min() { static const eT out = std::log(std::numeric_limits<eT>::min()); return out; }
+ static eT log_min() { static const eT out = std::log(std::numeric_limits<eT>::min()); return out; }
//! log of the maximum representable value
- static const eT log_max() { static const eT out = std::log(std::numeric_limits<eT>::max()); return out; }
+ static eT log_max() { static const eT out = std::log(std::numeric_limits<eT>::max()); return out; }
+
+ //! "not a number"
+ static eT nan() { return priv::Math_helper::nan<eT>(); }
+
+ //! infinity
+ static eT inf() { return priv::Math_helper::inf<eT>(); }
};
@@ -58,93 +164,93 @@
class Phy
{
public:
-
+
//! atomic mass constant (in kg)
- static const eT m_u() { return eT(1.660538782e-27); }
-
+ static eT m_u() { return eT(1.660538782e-27); }
+
//! Avogadro constant
- static const eT N_A() { return eT(6.02214179e23); }
-
+ static eT N_A() { return eT(6.02214179e23); }
+
//! Boltzmann constant (in joules per kelvin)
- static const eT k() { return eT(1.3806504e-23); }
-
+ static eT k() { return eT(1.3806504e-23); }
+
//! Boltzmann constant (in eV/K)
- static const eT k_evk() { return eT(8.617343e-5); }
-
+ static eT k_evk() { return eT(8.617343e-5); }
+
//! Bohr radius (in meters)
- static const eT a_0() { return eT(0.52917720859e-10); }
-
+ static eT a_0() { return eT(0.52917720859e-10); }
+
//! Bohr magneton
- static const eT mu_B() { return(927.400915e-26); }
-
+ static eT mu_B() { return(927.400915e-26); }
+
//! characteristic impedance of vacuum (in ohms)
- static const eT Z_0() { return eT(3.76730313461771e-2); }
-
+ static eT Z_0() { return eT(3.76730313461771e-2); }
+
//! conductance quantum (in siemens)
- static const eT G_0() { return eT(7.7480917004e-5); }
-
+ static eT G_0() { return eT(7.7480917004e-5); }
+
//! Coulomb's constant (in meters per farad)
- static const eT k_e() { return eT(8.9875517873681764e9); }
-
+ static eT k_e() { return eT(8.9875517873681764e9); }
+
//! electric constant (in farads per meter)
- static const eT eps_0() { return eT(8.85418781762039e-12); }
-
+ static eT eps_0() { return eT(8.85418781762039e-12); }
+
//! electron mass (in kg)
- static const eT m_e() { return eT(9.10938215e-31); }
-
+ static eT m_e() { return eT(9.10938215e-31); }
+
//! electron volt (in joules)
- static const eT eV() { return eT(1.602176487e-19); }
-
+ static eT eV() { return eT(1.602176487e-19); }
+
//! elementary charge (in coulombs)
- static const eT e() { return eT(1.602176487e-19); }
+ static eT e() { return eT(1.602176487e-19); }
//! Faraday constant (in coulombs)
- static const eT F() { return eT(96485.3399); }
-
+ static eT F() { return eT(96485.3399); }
+
//! fine-structure constant
- static const eT alpha() { return eT(7.2973525376e-3); }
-
+ static eT alpha() { return eT(7.2973525376e-3); }
+
//! inverse fine-structure constant
- static const eT alpha_inv() { return eT(137.035999679); }
-
+ static eT alpha_inv() { return eT(137.035999679); }
+
//! Josephson constant
- static const eT K_J() { return eT(483597.891e9); }
-
+ static eT K_J() { return eT(483597.891e9); }
+
//! magnetic constant (in henries per meter)
- static const eT mu_0() { return eT(1.25663706143592e-06); }
-
+ static eT mu_0() { return eT(1.25663706143592e-06); }
+
//! magnetic flux quantum (in webers)
- static const eT phi_0() { return eT(2.067833667e-15); }
-
+ static eT phi_0() { return eT(2.067833667e-15); }
+
//! molar gas constant (in joules per mole kelvin)
- static const eT R() { return eT(8.314472); }
-
+ static eT R() { return eT(8.314472); }
+
//! Newtonian constant of gravitation (in newton square meters per kilogram squared)
- static const eT G() { return eT(6.67428e-11); }
-
+ static eT G() { return eT(6.67428e-11); }
+
//! Planck constant (in joule seconds)
- static const eT h() { return eT(6.62606896e-34); }
-
+ static eT h() { return eT(6.62606896e-34); }
+
//! Planck constant over 2 pi, aka reduced Planck constant (in joule seconds)
- static const eT h_bar() { return eT(1.054571628e-34); }
-
+ static eT h_bar() { return eT(1.054571628e-34); }
+
//! proton mass (in kg)
- static const eT m_p() { return eT(1.672621637e-27); }
-
+ static eT m_p() { return eT(1.672621637e-27); }
+
//! Rydberg constant (in reciprocal meters)
- static const eT R_inf() { return eT(10973731.568527); }
-
+ static eT R_inf() { return eT(10973731.568527); }
+
//! speed of light in vacuum (in meters per second)
- static const eT c_0() { return eT(299792458.0); }
-
+ static eT c_0() { return eT(299792458.0); }
+
//! Stefan-Boltzmann constant
- static const eT sigma() { return eT(5.670400e-8); }
-
+ static eT sigma() { return eT(5.670400e-8); }
+
//! von Klitzing constant (in ohms)
- static const eT R_k() { return eT(25812.807557); }
-
+ static eT R_k() { return eT(25812.807557); }
+
//! Wien wavelength displacement law constant
- static const eT b() { return eT(2.8977685e-3); }
+ static eT b() { return eT(2.8977685e-3); }
};
@@ -157,4 +263,82 @@
+namespace priv
+ {
+
+ template<typename eT>
+ static
+ arma_inline
+ arma_hot
+ typename arma_float_only<eT>::result
+ most_neg(typename arma_float_only<eT>::result* junk = 0)
+ {
+ arma_ignore(junk);
+
+ if(std::numeric_limits<eT>::has_infinity == true)
+ {
+ return -(std::numeric_limits<eT>::infinity());
+ }
+ else
+ {
+ const eT a = eT(1);
+ const eT b = eT(0);
+
+ return -(a / b);
+ }
+ }
+
+
+ template<typename eT>
+ static
+ arma_inline
+ arma_hot
+ typename arma_integral_only<eT>::result
+ most_neg(typename arma_integral_only<eT>::result* junk = 0)
+ {
+ arma_ignore(junk);
+
+ return std::numeric_limits<eT>::min();
+ }
+
+
+ template<typename eT>
+ static
+ arma_inline
+ arma_hot
+ typename arma_float_only<eT>::result
+ most_pos(typename arma_float_only<eT>::result* junk = 0)
+ {
+ arma_ignore(junk);
+
+ if(std::numeric_limits<eT>::has_infinity == true)
+ {
+ return std::numeric_limits<eT>::infinity();
+ }
+ else
+ {
+ const eT a = eT(1);
+ const eT b = eT(0);
+
+ return a / b;
+ }
+ }
+
+
+ template<typename eT>
+ static
+ arma_inline
+ arma_hot
+ typename arma_integral_only<eT>::result
+ most_pos(typename arma_integral_only<eT>::result* junk = 0)
+ {
+ arma_ignore(junk);
+
+ return std::numeric_limits<eT>::max();
+ }
+
+ }
+
+
+
//! @}
Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp
===================================================================
--- pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp 2011-03-04 13:29:28 UTC (rev 2922)
+++ pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp 2011-03-10 18:54:12 UTC (rev 2923)
@@ -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
// Copyright (C) 2009-2010 Ian Cullinan
//
// This file is part of the Armadillo C++ library.
@@ -329,7 +329,7 @@
unsigned char* ptr = data.memptr();
f.clear();
- f.read(reinterpret_cast<char*>(ptr), N);
+ f.read( reinterpret_cast<char*>(ptr), std::streamsize(N) );
bool has_non_text_val = false;
@@ -610,7 +610,7 @@
{
arma_extra_debug_sigprint();
- f.write(reinterpret_cast<const char*>(x.mem), x.n_elem*sizeof(eT));
+ f.write( reinterpret_cast<const char*>(x.mem), std::streamsize(x.n_elem*sizeof(eT)) );
return f.good();
}
@@ -746,7 +746,7 @@
f << diskio::gen_bin_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << '\n';
- f.write(reinterpret_cast<const char*>(x.mem), x.n_elem*sizeof(eT));
+ f.write( reinterpret_cast<const char*>(x.mem), std::streamsize(x.n_elem*sizeof(eT)) );
return f.good();
}
@@ -816,7 +816,7 @@
}
}
- f.write(reinterpret_cast<const char*>(tmp.mem), n_elem);
+ f.write(reinterpret_cast<const char*>(tmp.mem), std::streamsize(n_elem) );
return f.good();
}
@@ -1017,7 +1017,7 @@
x.set_size(N / sizeof(eT), 1);
f.clear();
- f.read( reinterpret_cast<char *>(x.memptr()), N);
+ f.read( reinterpret_cast<char *>(x.memptr()), std::streamsize(N) );
return f.good();
}
@@ -1140,7 +1140,7 @@
f.get();
x.set_size(f_n_rows,f_n_cols);
- f.read( reinterpret_cast<char *>(x.memptr()), x.n_elem*sizeof(eT));
+ f.read( reinterpret_cast<char *>(x.memptr()), std::streamsize(x.n_elem*sizeof(eT)) );
load_okay = f.good();
}
@@ -1239,7 +1239,7 @@
const u32 n_elem = f_n_cols*f_n_rows;
podarray<u8> tmp(n_elem);
- f.read( reinterpret_cast<char*>(tmp.memptr()), n_elem);
+ f.read( reinterpret_cast<char*>(tmp.memptr()), std::streamsize(n_elem) );
u32 i = 0;
@@ -1262,7 +1262,7 @@
const u32 n_elem = f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem);
- f.read( reinterpret_cast<char *>(tmp.memptr()), n_elem*2);
+ f.read( reinterpret_cast<char *>(tmp.memptr()), std::streamsize(n_elem*2) );
u32 i = 0;
@@ -1376,7 +1376,7 @@
std::streampos pos = f.tellg();
- f.read(raw_header.memptr(), ARMA_MAT_TXT.length());
+ f.read( raw_header.memptr(), std::streamsize(ARMA_MAT_TXT.length()) );
raw_header[ARMA_MAT_TXT.length()] = '\0';
f.clear();
@@ -1532,7 +1532,7 @@
{
arma_extra_debug_sigprint();
- f.write(reinterpret_cast<const char*>(x.mem), x.n_elem*sizeof(eT));
+ f.write( reinterpret_cast<const char*>(x.mem), std::streamsize(x.n_elem*sizeof(eT)) );
return f.good();
}
@@ -1671,7 +1671,7 @@
f << diskio::gen_bin_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n';
- f.write(reinterpret_cast<const char*>(x.mem), x.n_elem*sizeof(eT));
+ f.write( reinterpret_cast<const char*>(x.mem), std::streamsize(x.n_elem*sizeof(eT)) );
return f.good();
}
@@ -1785,7 +1785,7 @@
x.set_size(N / sizeof(eT), 1, 1);
f.clear();
- f.read( reinterpret_cast<char *>(x.memptr()), N);
+ f.read( reinterpret_cast<char *>(x.memptr()), std::streamsize(N) );
return f.good();
}
@@ -1915,7 +1915,7 @@
f.get();
x.set_size(f_n_rows, f_n_cols, f_n_slices);
- f.read( reinterpret_cast<char *>(x.memptr()), x.n_elem*sizeof(eT));
+ f.read( reinterpret_cast<char *>(x.memptr()), std::streamsize(x.n_elem*sizeof(eT)) );
load_okay = f.good();
}
@@ -1970,7 +1970,7 @@
std::streampos pos = f.tellg();
- f.read(raw_header.memptr(), ARMA_CUB_TXT.length());
+ f.read( raw_header.memptr(), std::streamsize(ARMA_CUB_TXT.length()) );
raw_header[ARMA_CUB_TXT.length()] = '\0';
f.clear();
@@ -2336,7 +2336,7 @@
std::streampos pos = f.tellg();
- f.read(raw_header.memptr(), ARMA_FLD_BIN.length());
+ f.read( raw_header.memptr(), std::streamsize(ARMA_FLD_BIN.length()) );
f.clear();
f.seekg(pos);
@@ -2428,7 +2428,7 @@
const u32 n_elem = 3*f_n_cols*f_n_rows;
podarray<u8> tmp(n_elem);
- f.read( reinterpret_cast<char*>(tmp.memptr()), n_elem);
+ f.read( reinterpret_cast<char*>(tmp.memptr()), std::streamsize(n_elem) );
u32 i = 0;
@@ -2453,7 +2453,7 @@
const u32 n_elem = 3*f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem);
- f.read( reinterpret_cast<char *>(tmp.memptr()), 2*n_elem);
+ f.read( reinterpret_cast<char *>(tmp.memptr()), std::streamsize(2*n_elem) );
u32 i = 0;
@@ -2556,7 +2556,7 @@
f << x.n_rows << '\n';
f << 255 << '\n';
- f.write(reinterpret_cast<const char*>(tmp.mem), n_elem);
+ f.write( reinterpret_cast<const char*>(tmp.mem), std::streamsize(n_elem) );
return f.good();
}
@@ -2639,7 +2639,7 @@
const u32 n_elem = 3*f_n_cols*f_n_rows;
podarray<u8> tmp(n_elem);
- f.read( reinterpret_cast<char*>(tmp.memptr()), n_elem);
+ f.read( reinterpret_cast<char*>(tmp.memptr()), std::streamsize(n_elem) );
u32 i = 0;
@@ -2664,7 +2664,7 @@
const u32 n_elem = 3*f_n_cols*f_n_rows;
podarray<u16> tmp(n_elem);
- f.read( reinterpret_cast<char *>(tmp.memptr()), 2*n_elem);
+ f.read( reinterpret_cast<char *>(tmp.memptr()), std::streamsize(2*n_elem) );
u32 i = 0;
@@ -2786,7 +2786,7 @@
}
}
- f.write(reinterpret_cast<const char*>(tmp.mem), n_elem);
+ f.write( reinterpret_cast<const char*>(tmp.mem), std::streamsize(n_elem) );
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/rcpp -r 2923
More information about the Rcpp-commits
mailing list