arma_rng.hpp   arma_rng.hpp 
skipping to change at line 81 skipping to change at line 81
inline inline
void void
arma_rng::set_seed_random() arma_rng::set_seed_random()
{ {
seed_type seed1 = seed_type(0); seed_type seed1 = seed_type(0);
seed_type seed2 = seed_type(0); seed_type seed2 = seed_type(0);
seed_type seed3 = seed_type(0); seed_type seed3 = seed_type(0);
seed_type seed4 = seed_type(0); seed_type seed4 = seed_type(0);
seed_type seed5 = seed_type(0); seed_type seed5 = seed_type(0);
bool rd_ok = false; bool have_seed = false;
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
{ {
try try
{ {
std::random_device rd; std::random_device rd;
seed1 = static_cast<seed_type>( rd() ); if(rd.entropy() > double(0)) { seed1 = static_cast<seed_type>( rd() ); }
rd_ok = true; if(seed1 != seed_type(0)) { have_seed = true; }
} }
catch(...) {} catch(...) {}
} }
#endif #endif
if(rd_ok == false) if(have_seed == false)
{ {
try try
{ {
unsigned char buffer = 0; union
{
seed_type a;
unsigned char b[sizeof(seed_type)];
} tmp;
tmp.a = seed_type(0);
std::ifstream f("/dev/urandom", std::ifstream::binary); std::ifstream f("/dev/urandom", std::ifstream::binary);
f.read((char*)(&buffer), 1); if(f.good()) { f.read((char*)(&(tmp.b[0])), sizeof(seed_type)); }
if(f.good())
{
seed2 = tmp.a;
seed2 = static_cast<seed_type>(buffer); if(seed2 != seed_type(0)) { have_seed = true; }
}
} }
catch(...) {} catch(...) {}
}
if(have_seed == false)
{
// get better-than-nothing seeds in case reading /dev/urandom failed // get better-than-nothing seeds in case reading /dev/urandom failed
#if defined(ARMA_HAVE_GETTIMEOFDAY) #if defined(ARMA_HAVE_GETTIMEOFDAY)
{ {
struct timeval posix_time; struct timeval posix_time;
gettimeofday(&posix_time, 0); gettimeofday(&posix_time, 0);
seed3 = static_cast<seed_type>(posix_time.tv_usec); seed3 = static_cast<seed_type>(posix_time.tv_usec);
} }
#endif #endif
seed4 = static_cast<seed_type>( std::time(NULL) & 0xFFFF ); seed4 = static_cast<seed_type>( std::time(NULL) & 0xFFFF );
union union
{ {
uword* a; uword* a;
unsigned char b[sizeof(uword*)]; unsigned char b[sizeof(uword*)];
} address; } tmp;
uword junk = 0; tmp.a = (uword*)malloc(sizeof(uword));
address.a = &junk; if(tmp.a != NULL)
{
for(size_t i=0; i<sizeof(uword*); ++i) { seed5 += seed_type(tmp.b[i]
); }
seed5 = seed_type(address.b[0]) + seed_type(address.b[sizeof(uword*)-1] free(tmp.a);
); }
} }
arma_rng::set_seed( seed1 + seed2 + seed3 + seed4 + seed5 ); arma_rng::set_seed( seed1 + seed2 + seed3 + seed4 + seed5 );
} }
template<typename eT> template<typename eT>
struct arma_rng::randi struct arma_rng::randi
{ {
arma_inline arma_inline
operator eT () operator eT ()
 End of changes. 13 change blocks. 
12 lines changed or deleted 29 lines changed or added


 arma_version.hpp   arma_version.hpp 
skipping to change at line 12 skipping to change at line 12
// Copyright (C) 2009-2015 NICTA (www.nicta.com.au) // Copyright (C) 2009-2015 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup arma_version //! \addtogroup arma_version
//! @{ //! @{
#define ARMA_VERSION_MAJOR 5 #define ARMA_VERSION_MAJOR 5
#define ARMA_VERSION_MINOR 100 #define ARMA_VERSION_MINOR 200
#define ARMA_VERSION_PATCH 2 #define ARMA_VERSION_PATCH 0
#define ARMA_VERSION_NAME "Ankle Biter Deluxe" #define ARMA_VERSION_NAME "unstable development version"
struct arma_version struct arma_version
{ {
static const unsigned int major = ARMA_VERSION_MAJOR; static const unsigned int major = ARMA_VERSION_MAJOR;
static const unsigned int minor = ARMA_VERSION_MINOR; static const unsigned int minor = ARMA_VERSION_MINOR;
static const unsigned int patch = ARMA_VERSION_PATCH; static const unsigned int patch = ARMA_VERSION_PATCH;
static static
inline inline
std::string std::string
 End of changes. 1 change blocks. 
3 lines changed or deleted 3 lines changed or added


 cond_rel_bones.hpp   cond_rel_bones.hpp 
skipping to change at line 24 skipping to change at line 24
template<const bool do_eval> template<const bool do_eval>
class cond_rel class cond_rel
{ {
public: public:
template<typename eT> arma_inline static bool lt(const eT A, const eT B); template<typename eT> arma_inline static bool lt(const eT A, const eT B);
template<typename eT> arma_inline static bool gt(const eT A, const eT B); template<typename eT> arma_inline static bool gt(const eT A, const eT B);
template<typename eT> arma_inline static bool leq(const eT A, const eT B) ; template<typename eT> arma_inline static bool leq(const eT A, const eT B) ;
template<typename eT> arma_inline static bool geq(const eT A, const eT B) ; template<typename eT> arma_inline static bool geq(const eT A, const eT B) ;
template<typename eT> arma_inline static eT make_neg(const eT val);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 2 lines changed or added


 cond_rel_meat.hpp   cond_rel_meat.hpp 
skipping to change at line 83 skipping to change at line 83
template<> template<>
template<typename eT> template<typename eT>
arma_inline arma_inline
bool bool
cond_rel<false>::geq(const eT, const eT) cond_rel<false>::geq(const eT, const eT)
{ {
return false; return false;
} }
template<>
template<typename eT>
arma_inline
eT
cond_rel<true>::make_neg(const eT val)
{
return -val;
}
template<>
template<typename eT>
arma_inline
eT
cond_rel<false>::make_neg(const eT)
{
return eT(0);
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 18 lines changed or added


 diskio_meat.hpp   diskio_meat.hpp 
skipping to change at line 764 skipping to change at line 764
{ {
const bool neg = (token[0] == '-'); const bool neg = (token[0] == '-');
const bool pos = (token[0] == '+'); const bool pos = (token[0] == '+');
const size_t offset = ( (neg || pos) && (token.length() == 4) ) ? 1 : 0 ; const size_t offset = ( (neg || pos) && (token.length() == 4) ) ? 1 : 0 ;
const std::string token2 = token.substr(offset, 3); const std::string token2 = token.substr(offset, 3);
if( (token2 == "inf") || (token2 == "Inf") || (token2 == "INF") ) if( (token2 == "inf") || (token2 == "Inf") || (token2 == "INF") )
{ {
val = neg ? -(Datum<eT>::inf) : Datum<eT>::inf; val = neg ? cond_rel< is_signed<eT>::value >::make_neg(Datum<eT>::inf ) : Datum<eT>::inf;
return true; return true;
} }
else else
if( (token2 == "nan") || (token2 == "Nan") || (token2 == "NaN") || (tok en2 == "NAN") ) if( (token2 == "nan") || (token2 == "Nan") || (token2 == "NaN") || (tok en2 == "NAN") )
{ {
val = neg ? -(Datum<eT>::nan) : Datum<eT>::nan; val = Datum<eT>::nan;
return true; return true;
} }
} }
return false; return false;
} }
template<typename T> template<typename T>
inline inline
skipping to change at line 1402 skipping to change at line 1402
x.set_size(f_n_rows, f_n_cols); x.set_size(f_n_rows, f_n_cols);
std::stringstream ss; std::stringstream ss;
for(uword row=0; (row < x.n_rows) && (load_okay == true); ++row) for(uword row=0; (row < x.n_rows) && (load_okay == true); ++row)
{ {
for(uword col=0; (col < x.n_cols) && (load_okay == true); ++col) for(uword col=0; (col < x.n_cols) && (load_okay == true); ++col)
{ {
f >> token; f >> token;
ss.clear(); if( (is_signed<eT>::value == false) && (token.length() > 0) && (tok
ss.str(token); en[0] == '-') )
eT val = eT(0);
ss >> val;
if(ss.fail() == false)
{ {
x.at(row,col) = val; x.at(row,col) = eT(0);
} }
else else
{ {
const bool success = diskio::convert_naninf( x.at(row,col), token ss.clear();
); ss.str(token);
eT val = eT(0);
ss >> val;
if(success == false) if(ss.fail() == false)
{ {
load_okay = false; x.at(row,col) = val;
err_msg = "couldn't interpret data in "; }
else
{
const bool success = diskio::convert_naninf( x.at(row,col), tok
en );
if(success == false)
{
load_okay = false;
err_msg = "couldn't interpret data in ";
}
} }
} }
} }
} }
} }
// an empty file indicates an empty matrix // an empty file indicates an empty matrix
if( (f_n_cols_found == false) && (load_okay == true) ) if( (f_n_cols_found == false) && (load_okay == true) )
{ {
x.reset(); x.reset();
skipping to change at line 1705 skipping to change at line 1712
line_stream.clear(); line_stream.clear();
line_stream.str(line_string); line_stream.str(line_string);
uword col = 0; uword col = 0;
while(line_stream.good() == true) while(line_stream.good() == true)
{ {
std::getline(line_stream, token, ','); std::getline(line_stream, token, ',');
ss.clear(); if( (is_signed<eT>::value == false) && (token.length() > 0) && (token
ss.str(token); [0] == '-') )
eT val = eT(0);
ss >> val;
if(ss.fail() == false)
{ {
x.at(row,col) = val; x.at(row,col) = eT(0);
} }
else else
{ {
diskio::convert_naninf( x.at(row,col), token ); ss.clear();
ss.str(token);
eT val = eT(0);
ss >> val;
if(ss.fail() == false)
{
x.at(row,col) = val;
}
else
{
diskio::convert_naninf( x.at(row,col), token );
}
} }
++col; ++col;
} }
++row; ++row;
} }
return load_okay; return load_okay;
} }
 End of changes. 10 change blocks. 
24 lines changed or deleted 40 lines changed or added


 fn_misc.hpp   fn_misc.hpp 
skipping to change at line 274 skipping to change at line 274
template<typename eT> template<typename eT>
inline inline
void void
swap(Cube<eT>& A, Cube<eT>& B) swap(Cube<eT>& A, Cube<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
A.swap(B); A.swap(B);
} }
template<typename T1>
arma_inline
const Op<T1, op_orth>
orth(const Base<typename T1::elem_type, T1>& X, const typename T1::pod_type
tol = 0.0, const typename arma_blas_type_only<typename T1::elem_type>::res
ult* junk = 0)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::elem_type eT;
return Op<T1, op_orth>(X.get_ref(), eT(tol));
}
template<typename T1>
inline
bool
orth(Mat<typename T1::elem_type>& out, const Base<typename T1::elem_type, T
1>& X, const typename T1::pod_type tol = 0.0, const typename arma_blas_type
_only<typename T1::elem_type>::result* junk = 0)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
try { out = orth(X,tol); } catch (std::runtime_error&) { return false; }
return true;
}
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 30 lines changed or added


 fn_rank.hpp   fn_rank.hpp 
// Copyright (C) 2009-2013 Conrad Sanderson // Copyright (C) 2009-2015 Conrad Sanderson
// Copyright (C) 2009-2013 NICTA (www.nicta.com.au) // Copyright (C) 2009-2015 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Dimitrios Bouzas // Copyright (C) 2009-2010 Dimitrios Bouzas
// Copyright (C) 2011 Stanislav Funiak // Copyright (C) 2011 Stanislav Funiak
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_rank //! \addtogroup fn_rank
//! @{ //! @{
skipping to change at line 33 skipping to change at line 33
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
uword X_n_rows; uword X_n_rows;
uword X_n_cols; uword X_n_cols;
Col<T> s; Col<T> s;
const bool status = auxlib::svd_dc(s, X, X_n_rows, X_n_cols); const bool status = auxlib::svd_dc(s, X, X_n_rows, X_n_cols);
const uword n_elem = s.n_elem;
if(status == true) if(status == false)
{ {
if( (tol == T(0)) && (n_elem > 0) ) arma_bad("rank(): failed to converge");
{
tol = (std::max)(X_n_rows, X_n_cols) * eop_aux::direct_eps(max(s));
}
// count non zero valued elements in s return uword(0);
}
const T* s_mem = s.memptr(); const uword s_n_elem = s.n_elem;
const T* s_mem = s.memptr();
uword count = 0; // set tolerance to default if it hasn't been specified
if( (tol == T(0)) && (s_n_elem > 0) )
{
tol = (std::max)(X_n_rows, X_n_cols) * s_mem[0] * std::numeric_limits<T
>::epsilon();
}
for(uword i=0; i<n_elem; ++i) uword count = 0;
{
if(s_mem[i] > tol) { ++count; }
}
return count; for(uword i=0; i < s_n_elem; ++i) { count += (s_mem[i] > tol) ? uword(1)
} : uword(0); }
else
{
arma_bad("rank(): failed to converge");
return uword(0); return count;
}
} }
//! @} //! @}
 End of changes. 10 change blocks. 
23 lines changed or deleted 19 lines changed or added


 op_misc_bones.hpp   op_misc_bones.hpp 
// Copyright (C) 2008-2011 Conrad Sanderson // Copyright (C) 2008-2015 Conrad Sanderson
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) // Copyright (C) 2008-2015 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup op_misc //! \addtogroup op_misc
//! @{ //! @{
class op_real class op_real
{ {
skipping to change at line 44 skipping to change at line 44
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply( Mat<typename T1::pod_type>& out, const mtOp<typ ename T1::pod_type, T1, op_abs>& X); inline static void apply( Mat<typename T1::pod_type>& out, const mtOp<typ ename T1::pod_type, T1, op_abs>& X);
template<typename T1> template<typename T1>
inline static void apply( Cube<typename T1::pod_type>& out, const mtOpCub e<typename T1::pod_type, T1, op_abs>& X); inline static void apply( Cube<typename T1::pod_type>& out, const mtOpCub e<typename T1::pod_type, T1, op_abs>& X);
}; };
class op_orth
{
public:
template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1, o
p_orth>& expr);
};
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 11 lines changed or added


 op_misc_meat.hpp   op_misc_meat.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2015 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2015 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup op_misc //! \addtogroup op_misc
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
skipping to change at line 263 skipping to change at line 263
for(uword slice=0; slice < n_slices; ++slice) for(uword slice=0; slice < n_slices; ++slice)
for(uword col=0; col < n_cols; ++col ) for(uword col=0; col < n_cols; ++col )
for(uword row=0; row < n_rows; ++row ) for(uword row=0; row < n_rows; ++row )
{ {
*out_mem = std::abs( P.at(row,col,slice) ); *out_mem = std::abs( P.at(row,col,slice) );
out_mem++; out_mem++;
} }
} }
} }
template<typename T1>
inline
void
op_orth::apply( Mat<typename T1::elem_type>& out, const Op<T1, op_orth>& ex
pr )
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
typedef typename T1::pod_type T;
T tol = access::tmp_real(expr.aux);
arma_debug_check((tol < T(0)), "orth(): tolerance must be >= 0");
const unwrap<T1> tmp(expr.m);
const Mat<eT>& X = tmp.M;
Mat<eT> U;
Col< T> s;
Mat<eT> V;
//const bool status = auxlib::svd_econ(U, s, V, X, 'l');
//const bool status = auxlib::svd_dc(U, s, V, X);
const bool status = auxlib::svd_dc_econ(U, s, V, X);
V.reset();
if(status == false) { out.reset(); arma_bad("orth(): svd failed"); retur
n; }
if(s.is_empty()) { out.reset(); return; }
const uword s_n_elem = s.n_elem;
const T* s_mem = s.memptr();
// set tolerance to default if it hasn't been specified
if(tol == T(0)) { tol = (std::max)(X.n_rows, X.n_cols) * s_mem[0] * std:
:numeric_limits<T>::epsilon(); }
uword count = 0;
for(uword i=0; i < s_n_elem; ++i) { count += (s_mem[i] > tol) ? uword(1)
: uword(0); }
if(count > 0)
{
out = U.head_cols(count); // out *= eT(-1);
}
else
{
out.set_size(X.n_rows, 0);
}
}
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 57 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/