diff --git a/CMake/ARMA_FindARPACK.cmake b/CMake/ARMA_FindARPACK.cmake index 35edae7ccd5..ff1ee227977 100644 --- a/CMake/ARMA_FindARPACK.cmake +++ b/CMake/ARMA_FindARPACK.cmake @@ -1,39 +1,39 @@ -# - Try to find ARPACK -# Once done this will define -# -# ARPACK_FOUND - system has ARPACK -# ARPACK_LIBRARY - Link this to use ARPACK - - -find_library(ARPACK_LIBRARY - NAMES arpack - PATHS /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib - ) - - -if (ARPACK_LIBRARY) - set(ARPACK_FOUND YES) -else () - # Search for PARPACK. - find_library(ARPACK_LIBRARY - NAMES parpack - PATHS /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib - ) - - if (ARPACK_LIBRARY) - set(ARPACK_FOUND YES) - else () - set(ARPACK_FOUND NO) - endif () -endif () - - -if (ARPACK_FOUND) - if (NOT ARPACK_FIND_QUIETLY) - message(STATUS "Found an ARPACK library: ${ARPACK_LIBRARY}") - endif () -else () - if (ARPACK_FIND_REQUIRED) - message(FATAL_ERROR "Could not find an ARPACK library") - endif () -endif () +# - Try to find ARPACK +# Once done this will define +# +# ARPACK_FOUND - system has ARPACK +# ARPACK_LIBRARY - Link this to use ARPACK + + +find_library(ARPACK_LIBRARY + NAMES arpack + PATHS /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib + ) + + +if (ARPACK_LIBRARY) + set(ARPACK_FOUND YES) +else () + # Search for PARPACK. + find_library(ARPACK_LIBRARY + NAMES parpack + PATHS /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib + ) + + if (ARPACK_LIBRARY) + set(ARPACK_FOUND YES) + else () + set(ARPACK_FOUND NO) + endif () +endif () + + +if (ARPACK_FOUND) + if (NOT ARPACK_FIND_QUIETLY) + message(STATUS "Found an ARPACK library: ${ARPACK_LIBRARY}") + endif () +else () + if (ARPACK_FIND_REQUIRED) + message(FATAL_ERROR "Could not find an ARPACK library") + endif () +endif () diff --git a/doc/tutorials/approx_kfn/approx_kfn.txt b/doc/tutorials/approx_kfn/approx_kfn.txt index aa477a0d097..247eb72ff98 100644 --- a/doc/tutorials/approx_kfn/approx_kfn.txt +++ b/doc/tutorials/approx_kfn/approx_kfn.txt @@ -144,7 +144,7 @@ neighbor search: - \c mlpack_kfn, for exact and approximate tree-based approaches These two programs allow a large number of algorithms to be used to find -approximate furthest neighbors. Note that the \c mlpack_kfn program is also +approximate furthest neighbors. Note that the \c mlpack_kfn program is also documented by the \ref cli_nstut section of the \ref nstutorial page, as it shares options with the \c mlpack_knn program. @@ -170,7 +170,7 @@ $ mlpack_approx_kfn -q queries.csv -r refs.csv -v -k 5 -n n.csv -d d.csv [INFO ] Search complete. [INFO ] Saving CSV data to 'n.csv'. [INFO ] Saving CSV data to 'd.csv'. -[INFO ] +[INFO ] [INFO ] Execution parameters: [INFO ] algorithm: ds [INFO ] calculate_error: false @@ -188,7 +188,7 @@ $ mlpack_approx_kfn -q queries.csv -r refs.csv -v -k 5 -n n.csv -d d.csv [INFO ] reference_file: refs.csv [INFO ] verbose: true [INFO ] version: false -[INFO ] +[INFO ] [INFO ] Program timers: [INFO ] drusilla_select_construct: 0.000342s [INFO ] drusilla_select_search: 0.000780s @@ -231,7 +231,7 @@ $ mlpack_approx_kfn -q queries.csv -r refs.csv -v -k 4 -n n.csv -d d.csv -t 10 - [INFO ] Search complete. [INFO ] Saving CSV data to 'n.csv'. [INFO ] Saving CSV data to 'd.csv'. -[INFO ] +[INFO ] [INFO ] Execution parameters: [INFO ] algorithm: ds [INFO ] calculate_error: false @@ -249,7 +249,7 @@ $ mlpack_approx_kfn -q queries.csv -r refs.csv -v -k 4 -n n.csv -d d.csv -t 10 - [INFO ] reference_file: refs.csv [INFO ] verbose: true [INFO ] version: false -[INFO ] +[INFO ] [INFO ] Program timers: [INFO ] drusilla_select_construct: 0.000645s [INFO ] drusilla_select_search: 0.000551s @@ -276,7 +276,7 @@ $ mlpack_approx_kfn -q queries.csv -r refs.csv -v -k 3 -n n.csv -d d.csv -a qdaf [INFO ] Search complete. [INFO ] Saving CSV data to 'n.csv'. [INFO ] Saving CSV data to 'd.csv'. -[INFO ] +[INFO ] [INFO ] Execution parameters: [INFO ] algorithm: qdafn [INFO ] calculate_error: false @@ -294,7 +294,7 @@ $ mlpack_approx_kfn -q queries.csv -r refs.csv -v -k 3 -n n.csv -d d.csv -a qdaf [INFO ] reference_file: refs.csv [INFO ] verbose: true [INFO ] version: false -[INFO ] +[INFO ] [INFO ] Program timers: [INFO ] loading_data: 0.008380s [INFO ] qdafn_construct: 0.003399s @@ -326,7 +326,7 @@ $ mlpack_approx_kfn -q queries.csv -r refs.csv -v -k 1 -e -q -n n.csv [INFO ] Average error: 1.08417. [INFO ] Maximum error: 1.28712. [INFO ] Minimum error: 1. -[INFO ] +[INFO ] [INFO ] Execution parameters: [INFO ] algorithm: ds [INFO ] calculate_error: true @@ -344,7 +344,7 @@ $ mlpack_approx_kfn -q queries.csv -r refs.csv -v -k 1 -e -q -n n.csv [INFO ] reference_file: refs.csv [INFO ] verbose: true [INFO ] version: false -[INFO ] +[INFO ] [INFO ] Program timers: [INFO ] computing_neighbors: 0.001476s [INFO ] drusilla_select_construct: 0.000309s @@ -391,7 +391,7 @@ $ mlpack_approx_kfn -q queries.csv -r refs.csv -k 1 -e -x exact.csv -n n.csv -v [INFO ] Maximum error: 1.67407. [INFO ] Minimum error: 1. [INFO ] Saving CSV data to 'n.csv'. -[INFO ] +[INFO ] [INFO ] Execution parameters: [INFO ] algorithm: qdafn [INFO ] calculate_error: true @@ -409,7 +409,7 @@ $ mlpack_approx_kfn -q queries.csv -r refs.csv -k 1 -e -x exact.csv -n n.csv -v [INFO ] reference_file: refs.csv [INFO ] verbose: true [INFO ] version: false -[INFO ] +[INFO ] [INFO ] Program timers: [INFO ] loading_data: 0.010348s [INFO ] qdafn_construct: 0.000318s @@ -443,7 +443,7 @@ $ mlpack_kfn -q queries.csv -r refs.csv -v -k 3 -e 0.5 -n n.csv -d d.csv [INFO ] Search complete. [INFO ] Saving CSV data to 'n.csv'. [INFO ] Saving CSV data to 'd.csv'. -[INFO ] +[INFO ] [INFO ] Execution parameters: [INFO ] algorithm: dual_tree [INFO ] distances_file: d.csv @@ -467,7 +467,7 @@ $ mlpack_kfn -q queries.csv -r refs.csv -v -k 3 -e 0.5 -n n.csv -d d.csv [INFO ] true_neighbors_file: "" [INFO ] verbose: true [INFO ] version: false -[INFO ] +[INFO ] [INFO ] Program timers: [INFO ] computing_neighbors: 0.000442s [INFO ] loading_data: 0.008060s @@ -503,7 +503,7 @@ mlpack_kfn -q queries.csv -r refs.csv -v -k 3 -e 0.1 -n n.csv -d d.csv -a single [INFO ] Search complete. [INFO ] Saving CSV data to 'n.csv'. [INFO ] Saving CSV data to 'd.csv'. -[INFO ] +[INFO ] [INFO ] Execution parameters: [INFO ] algorithm: single_tree [INFO ] distances_file: d.csv @@ -527,7 +527,7 @@ mlpack_kfn -q queries.csv -r refs.csv -v -k 3 -e 0.1 -n n.csv -d d.csv -a single [INFO ] true_neighbors_file: "" [INFO ] verbose: true [INFO ] version: false -[INFO ] +[INFO ] [INFO ] Program timers: [INFO ] computing_neighbors: 0.000850s [INFO ] loading_data: 0.007858s @@ -554,7 +554,7 @@ $ mlpack_approx_kfn -r refs.csv -t 5 -p 10 -v -M model.bin [INFO ] Loading 'refs.csv' as CSV data. Size is 3 x 1000. [INFO ] Building DrusillaSelect model... [INFO ] Model built. -[INFO ] +[INFO ] [INFO ] Execution parameters: [INFO ] algorithm: ds [INFO ] calculate_error: false @@ -572,7 +572,7 @@ $ mlpack_approx_kfn -r refs.csv -t 5 -p 10 -v -M model.bin [INFO ] reference_file: refs.csv [INFO ] verbose: true [INFO ] version: false -[INFO ] +[INFO ] [INFO ] Program timers: [INFO ] drusilla_select_construct: 0.000321s [INFO ] loading_data: 0.004700s @@ -589,7 +589,7 @@ $ mlpack_approx_kfn -m model.bin -q queries.csv -k 3 -d d.csv -n n.csv -v [INFO ] Search complete. [INFO ] Saving CSV data to 'n.csv'. [INFO ] Saving CSV data to 'd.csv'. -[INFO ] +[INFO ] [INFO ] Execution parameters: [INFO ] algorithm: ds [INFO ] calculate_error: false @@ -607,7 +607,7 @@ $ mlpack_approx_kfn -m model.bin -q queries.csv -k 3 -d d.csv -n n.csv -v [INFO ] reference_file: "" [INFO ] verbose: true [INFO ] version: false -[INFO ] +[INFO ] [INFO ] Program timers: [INFO ] drusilla_select_search: 0.000878s [INFO ] loading_data: 0.004599s diff --git a/src/mlpack/core/arma_extend/fn_ind2sub.hpp b/src/mlpack/core/arma_extend/fn_ind2sub.hpp index cfa6ab5b44d..a3bff68195e 100644 --- a/src/mlpack/core/arma_extend/fn_ind2sub.hpp +++ b/src/mlpack/core/arma_extend/fn_ind2sub.hpp @@ -6,7 +6,7 @@ // ------------------------------------------------------------------- // // Written by Conrad Sanderson - http://conradsanderson.id.au - + #if (ARMA_VERSION_MAJOR < 6 || \ (ARMA_VERSION_MAJOR == 6 && ARMA_VERSION_MINOR < 399)) inline @@ -14,14 +14,14 @@ ind2sub(const SizeMat& s, const uword i) { arma_extra_debug_sigprint(); - + arma_debug_check( (i >= (s.n_rows * s.n_cols) ), "ind2sub(): index out of range" ); - + uvec out(2); - + out[0] = i % s.n_rows; out[1] = i / s.n_rows; - + return out; } @@ -31,22 +31,22 @@ ind2sub(const SizeCube& s, const uword i) { arma_extra_debug_sigprint(); - + arma_debug_check( (i >= (s.n_rows * s.n_cols * s.n_slices) ), "ind2sub(): index out of range" ); - + const uword n_elem_slice = s.n_rows * s.n_cols; - + const uword slice = i / n_elem_slice; const uword j = i - (slice * n_elem_slice); const uword row = j % s.n_rows; const uword col = j / s.n_rows; - + uvec out(3); - + out[0] = row; out[1] = col; out[2] = slice; - + return out; } @@ -56,9 +56,9 @@ sub2ind(const SizeMat& s, const uword row, const uword col) { arma_extra_debug_sigprint(); - + arma_debug_check( ((row >= s.n_rows) || (col >= s.n_cols)), "sub2ind(): subscript out of range" ); - + return uword(row + col*s.n_rows); } @@ -68,11 +68,11 @@ sub2ind(const SizeCube& s, const uword row, const uword col, const uword slice) { arma_extra_debug_sigprint(); - + arma_debug_check( ((row >= s.n_rows) || (col >= s.n_cols) || (slice >= s.n_slices)), "sub2ind(): subscript out of range" ); - + return uword( (slice * s.n_rows * s.n_cols) + (col * s.n_rows) + row ); } #endif - + diff --git a/src/mlpack/core/boost_backport/bernoulli.hpp b/src/mlpack/core/boost_backport/bernoulli.hpp index 554297001e3..4e8ee6f9214 100644 --- a/src/mlpack/core/boost_backport/bernoulli.hpp +++ b/src/mlpack/core/boost_backport/bernoulli.hpp @@ -48,8 +48,8 @@ namespace boost { namespace math{ #include "detail/unchecked_bernoulli.hpp" #include "detail/bernoulli_details.hpp" -namespace boost { namespace math { - +namespace boost { namespace math { + namespace detail { template @@ -60,7 +60,7 @@ OutputIterator bernoulli_number_imp(OutputIterator out, std::size_t start, std:: *out = unchecked_bernoulli_imp(i, tag); ++out; } - + for(std::size_t i = (std::max)(static_cast(max_bernoulli_b2n::value + 1), start); i < start + n; ++i) { // We must overflow: diff --git a/src/mlpack/core/boost_backport/detail/bernoulli_details.hpp b/src/mlpack/core/boost_backport/detail/bernoulli_details.hpp index f26dfe7d166..d07d796b1f8 100644 --- a/src/mlpack/core/boost_backport/detail/bernoulli_details.hpp +++ b/src/mlpack/core/boost_backport/detail/bernoulli_details.hpp @@ -82,12 +82,12 @@ T b2n_asymptotic(int n) const T nx = static_cast(n); const T nx2(nx * nx); - const T approximate_log_of_bernoulli_bn = + const T approximate_log_of_bernoulli_bn = ((boost::math::constants::half() + nx) * log(nx)) + ((boost::math::constants::half() - nx) * log(boost::math::constants::pi())) + (((T(3) / 2) - nx) * boost::math::constants::ln_two()) + ((nx * (T(2) - (nx2 * 7) * (1 + ((nx2 * 30) * ((nx2 * 12) - 1))))) / (((nx2 * nx2) * nx2) * 2520)); - return ((n / 2) & 1 ? 1 : -1) * (approximate_log_of_bernoulli_bn > tools::log_max_value() + return ((n / 2) & 1 ? 1 : -1) * (approximate_log_of_bernoulli_bn > tools::log_max_value() ? policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, nx, Policy()) : static_cast(exp(approximate_log_of_bernoulli_bn))); } @@ -114,12 +114,12 @@ T t2n_asymptotic(int n) // us to elude a great deal of runtime checking for values below // n, and only perform the full overflow checks when we know that we're // getting close to the point where our calculations will overflow. -// We use Luschny's LogB3 formula (http://www.luschny.de/math/primes/bernincl.html) +// We use Luschny's LogB3 formula (http://www.luschny.de/math/primes/bernincl.html) // to find the limit, and since we're dealing with the log of the Bernoulli numbers // we need only perform the calculation at double precision and not with T // (which may be a multiprecision type). The limit returned is within 1 of the true // limit for all the types tested. Note that although the code below is basically -// the same as b2n_asymptotic above, it has been recast as a continuous real-valued +// the same as b2n_asymptotic above, it has been recast as a continuous real-valued // function as this makes the root finding go smoother/faster. It also omits the // sign of the Bernoulli number. // @@ -241,10 +241,10 @@ struct fixed_vector : private std::allocator typedef T* iterator; typedef const T* const_iterator; fixed_vector() : m_used(0) - { + { std::size_t overflow_limit = 5 + b2n_overflow_limit >(); m_capacity = static_cast((std::min)(overflow_limit, static_cast(100000u))); - m_data = this->allocate(m_capacity); + m_data = this->allocate(m_capacity); } ~fixed_vector() { @@ -402,7 +402,7 @@ class bernoulli_numbers_cache // There are basically 3 thread safety options: // // 1) There are no threads (BOOST_HAS_THREADS is not defined). - // 2) There are threads, but we do not have a true atomic integer type, + // 2) There are threads, but we do not have a true atomic integer type, // in this case we just use a mutex to guard against race conditions. // 3) There are threads, and we have an atomic integer: in this case we can // use the double-checked locking pattern to avoid thread synchronisation @@ -504,7 +504,7 @@ class bernoulli_numbers_cache // There are basically 3 thread safety options: // // 1) There are no threads (BOOST_HAS_THREADS is not defined). - // 2) There are threads, but we do not have a true atomic integer type, + // 2) There are threads, but we do not have a true atomic integer type, // in this case we just use a mutex to guard against race conditions. // 3) There are threads, and we have an atomic integer: in this case we can // use the double-checked locking pattern to avoid thread synchronisation diff --git a/src/mlpack/core/boost_backport/detail/polygamma.hpp b/src/mlpack/core/boost_backport/detail/polygamma.hpp index 35b45fff14e..201f81929da 100644 --- a/src/mlpack/core/boost_backport/detail/polygamma.hpp +++ b/src/mlpack/core/boost_backport/detail/polygamma.hpp @@ -26,10 +26,10 @@ #include #include #include - + // Forward declarations. namespace boost { namespace math { - + // Forward declaration of boost::math::polygamma. template inline typename tools::promote_args::type polygamma(const int n, T x, const Policy& pol); @@ -39,12 +39,12 @@ namespace policies { template - inline int digits_base10(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) + inline int digits_base10(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) { return boost::math::policies::digits() * 301 / 1000L; } } - + }} namespace boost { namespace math { namespace detail{ @@ -77,12 +77,12 @@ // (n-1)! / x^(n+1) // // which is common to both the first term of the series (with k = 1) - // and to the leading part. + // and to the leading part. // We can then get to the leading term by: // // part_term * (n + 2 * x) / 2 // - // and to the first term in the series + // and to the first term in the series // (excluding the Bernoulli number) by: // // part_term n * (n + 1) / (2x) @@ -91,7 +91,7 @@ // or the power term underflows, this just gets set to 0 and then we // know that we have to use logs for the initial terms: // - part_term = ((n > (int)boost::math::max_factorial::value) && (T(n) * n > tools::log_max_value())) + part_term = ((n > (int)boost::math::max_factorial::value) && (T(n) * n > tools::log_max_value())) ? T(0) : static_cast(boost::math::factorial(n - 1, pol) * pow(x, -n - 1)); if(part_term == 0) { @@ -138,7 +138,7 @@ return policies::raise_evaluation_error(function, "Series did not converge, closest value was %1%", sum, pol); } } - + if((n - 1) & 1) sum = -sum; @@ -212,7 +212,7 @@ T factorial_part = 1; // // "prefix" is what we'll be adding the accumulated sum to, it will - // be n! / z^(n+1), but since we're scaling by n! it's just + // be n! / z^(n+1), but since we're scaling by n! it's just // 1 / z^(n+1) for now: // T prefix = pow(x, n + 1); @@ -224,10 +224,10 @@ // ignore the sum if it will have no effect on the result anyway: // if(prefix > 2 / policies::get_epsilon()) - return ((n & 1) ? 1 : -1) * + return ((n & 1) ? 1 : -1) * (tools::max_value() / prefix < scale ? policies::raise_overflow_error(function, 0, pol) : prefix * scale); // - // As this is an alternating series we could accelerate it using + // As this is an alternating series we could accelerate it using // "Convergence Acceleration of Alternating Series", // Henri Cohen, Fernando Rodriguez Villegas, and Don Zagier, Experimental Mathematics, 1999. // In practice however, it appears not to make any difference to the number of terms @@ -410,7 +410,7 @@ } // - // We'll have to compute the coefficients up to n, + // We'll have to compute the coefficients up to n, // complexity is O(n^2) which we don't worry about for now // as the values are computed once and then cached. // However, if the final evaluation would have too many @@ -493,7 +493,7 @@ template const typename polygamma_initializer::init polygamma_initializer::initializer; - + template inline T polygamma_imp(const int n, T x, const Policy &pol) { diff --git a/src/mlpack/core/boost_backport/detail/unchecked_bernoulli.hpp b/src/mlpack/core/boost_backport/detail/unchecked_bernoulli.hpp index 80801bd6bb5..c61c08999b0 100644 --- a/src/mlpack/core/boost_backport/detail/unchecked_bernoulli.hpp +++ b/src/mlpack/core/boost_backport/detail/unchecked_bernoulli.hpp @@ -19,8 +19,8 @@ #include #include -namespace boost { namespace math { - +namespace boost { namespace math { + namespace detail { template @@ -56,7 +56,7 @@ struct max_bernoulli_index<4> template struct bernoulli_imp_variant { - static const unsigned value = + static const unsigned value = (std::numeric_limits::max_exponent == 128) && (std::numeric_limits::radix == 2) && (std::numeric_limits::digits <= std::numeric_limits::digits) @@ -452,176 +452,176 @@ inline T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<3>& ) +1.33527841873546338750122832017820518292039E306L, #if LDBL_MAX_EXP == 16384 // Entries 260 - 600 http://www.wolframalpha.com/input/?i=TABLE[N[Bernoulli[i]%2C40]%2C+{i%2C258%2C600%2C2}] - -2.277640649601959593875058983506938037019e309L, - 3.945184036046326234163525556422667595884e312L, - -6.938525772130602106071724989641405550473e315L, - 1.238896367577564823729057820219210929986e319L, - -2.245542599169309759499987966025604480745e322L, - 4.131213176073842359732511639489669404266e325L, - -7.713581346815269584960928069762882771369e328L, - 1.461536066837669600638613788471335541313e332L, - -2.809904606225532896862935642992712059631e335L, - 5.480957121318876639512096994413992284327e338L, - -1.084573284087686110518125291186079616320e342L, - 2.176980775647663539729165173863716459962e345L, - -4.431998786117553751947439433256752608068e348L, - 9.150625657715535047417756278073770096073e351L, - -1.915867353003157351316577579148683133613e355L, - 4.067256303542212258698836003682016040629e358L, - -8.754223791037736616228150209910348734629e361L, - 1.910173688735533667244373747124109379826e365L, - -4.225001320265091714631115064713174404607e368L, - 9.471959352547827678466770796787503034505e371L, - -2.152149973279986829719817376756088198573e375L, - 4.955485775334221051344839716507812871361e378L, - -1.156225941759134696630956889716381968142e382L, - 2.733406597646137698610991926705098514017e385L, - -6.546868135325176947099912523279938546333e388L, - 1.588524912441221472814692121069821695547e392L, - -3.904354800861715180218598151050191841308e395L, - 9.719938686092045781827273411668132975319e398L, - -2.450763621049522051234479737511375679283e402L, - 6.257892098396815305085674126334317095277e405L, - -1.618113552083806592527989531636955084420e409L, - 4.236528795217618357348618613216833722648e412L, - -1.123047068199051008086174989124136878992e416L, - 3.013971787525654770217283559392286666886e419L, - -8.188437573221553030375681429202969070420e422L, - 2.251910591336716809153958146725775718707e426L, - -6.268411292043789823075314151509139413399e429L, - 1.765990845202322642693572112511312471527e433L, - -5.035154436231331651259071296731160882240e436L, - 1.452779356460483245253765356664402207266e440L, - -4.241490890130137339052414960684151515166e443L, - 1.252966001692427774088293833338841893293e447L, - -3.744830047478272947978103227876747240343e450L, - 1.132315806695710930595876001089232216024e454L, - -3.463510845942701805991786197773934662578e457L, - 1.071643382649675572086865465873916611537e461L, - -3.353824475439933688957233489984711465335e464L, - 1.061594257145875875963152734129803268488e468L, - -3.398420969215528955528654193586189805265e471L, - 1.100192502000434096206138068020551065890e475L, - -3.601686379213993374332690210094863486472e478L, - 1.192235170430164900533187239994513019475e482L, - -3.990342751779668381699052942504119409180e485L, - 1.350281800938769780891258894167663309221e489L, - -4.619325443466054312873093650888507562249e492L, - 1.597522243968586548227514639959727696694e496L, - -5.584753729092155108530929002119620487652e499L, - 1.973443623104646193229794524759543752089e503L, - -7.048295441989615807045620880311201930244e506L, - 2.544236702499719094591873151590280263560e510L, - -9.281551595258615205927443367289948150345e513L, - 3.421757163154453657766296828520235351572e517L, - -1.274733639384538364282697627345068947433e521L, - 4.798524805311016034711205886780460173566e524L, - -1.825116948422858388787806917284878870034e528L, - 7.013667442807288452441777981425055613982e531L, - -2.723003862685989740898815670978399383114e535L, - 1.068014853917260290630122222858884658850e539L, - -4.231650952273697842269381683768681118533e542L, - 1.693650052202594386658903598564772900388e546L, - -6.846944855806453360616258582310883597678e549L, - 2.795809132238082267120232174243715559601e553L, - -1.153012972808983269106716828311318981951e557L, - 4.802368854268746357511997492039592697149e560L, - -2.019995255271910836389761734035403905781e564L, - 8.580207235032617856059250643095019760968e567L, - -3.680247942263468164408192134916355198549e571L, - 1.593924457586765331397457407661306895942e575L, - -6.970267175232643679233530367569943057501e578L, - 3.077528087427698518703282907890556154309e582L, - -1.371846760052887888926055417297342106614e586L, - 6.173627360829553396851763207025505289166e589L, - -2.804703130495506384463249394043486916669e593L, - 1.286250900087150126167490951216207186092e597L, - -5.954394420063617872366818601092036543220e600L, - 2.782297785278756426177542270854984091406e604L, - -1.312214674935307746141207680066262384215e608L, - 6.246299145383554153167974732783934504370e611L, - -3.000812007679574430883792565577444226490e615L, - 1.454904877136007844493861746476079537075e619L, - -7.118558521873800304612781121044077357278e622L, - 3.514739820897817389472822276832677887997e626L, - -1.751137068816377401163011262831890828437e630L, - 8.803498091818800678575314081978951179602e633L, - -4.465612911700593572269200981612564161010e637L, - 2.285494565287530681465757798517033542888e641L, - -1.180145168917737098025683613598595411329e645L, - 6.147941849198393232663105284575149616925e648L, - -3.231069156963603593233679426198974663352e652L, - 1.713042725635435041806895849197608270935e656L, - -9.161761363270648920537613435771882898051e659L, - 4.942675965960539112005679080810117766825e663L, - -2.689684712697383518131267222872386600031e667L, - 1.476320014229917759615308193449511534656e671L, - -8.173037740864781506597184122049453514594e674L, - 4.563462313190521363235182420178784459580e678L, - -2.569790015236158475703055501886439298708e682L, - 1.459410219452119981958355737832022375085e686L, - -8.358304882556983795372406183642486436653e689L, - 4.827305091483557818593092377664570208355e693L, - -2.811394311081493166793414157061950132403e697L, - 1.651026863340675349245561261339568827739e701L, - -9.776578579336866764167878646459810047899e704L, - 5.837207965197521880181236529616560780535e708L, - -3.513938957938032127105389702846371181520e712L, - 2.132747371360190507595748444536911078788e716L, - -1.305047363239192640729466563372665311602e720L, - 8.050825342678337497636292798039996484780e723L, - -5.006884161223862543665524155681082112689e727L, - 3.139016066011452177570812014513491361235e731L, - -1.983829535212711378291469356666001365873e735L, - 1.263822427649676371257598052486237628698e739L, - -8.115678659900522918802121684491754629503e742L, - 5.252995164972075271667364371449050412435e746L, - -3.427038125662404660056511738625477058135e750L, - 2.253446011834352733279946306835940729858e754L, - -1.493407341897034717876962786798831719683e758L, - 9.974681322653365118752729509398728354442e761L, - -6.714230142773850863927710112350816379426e765L, - 4.554668668931723346600337564274944733530e769L, - -3.113635386023220127834102980385275379533e773L, - 2.144945411287666204679363498162954050208e777L, - -1.488982121181387164932397544378555256016e781L, - 1.041537218854627455352298173588983048748e785L, - -7.341073881786613676177562822942175683993e788L, - 5.213524272587199574980117351016322518428e792L, - -3.730592531776514409283897139216167197989e796L, - 2.689592876341877079083449497724049500175e800L, - -1.953643788231947582529884602972233135002e804L, - 1.429691073080500563348668321308878246277e808L, - -1.054059177095488639836063073070536825675e812L, - 7.828919160938693948399336431565350676613e815L, - -5.857884457184396382550955498026762014753e819L, - 4.415401588264172474136969345712659422380e823L, - -3.352573884181287635796498822858109969161e827L, - 2.564210385719224000156548240934108974447e831L, - -1.975534392116037602837941409848663077528e835L, - 1.533062123975940045180943006948008486466e839L, - -1.198306160488763291730059994812781226903e843L, - 9.434034267770711698676321369174735725321e846L, - -7.480619200038505368468483892246806488879e850L, - 5.974161898439971564124576801455052907638e854L, - -4.805125663714699771668630995361572639386e858L, - 3.892332138028039952403812726744593073776e862L, - -3.175276505779699340738548328810180869575e866L, - 2.608608681939322393581069188271626122519e870L, - -2.158148554392732439392868052394994052628e874L, - 1.797993483301448477700600221980862686033e878L, - -1.508407575089108597171576068862286462909e882L, - 1.274273406242459482708930389008701147244e886L, - -1.083950475353171986748233157909397370193e890L, - 9.284292630726328432038470356821265395331e893L, - -8.007012115449516364480417355063446317414e897L, - 6.952871948429568933888979915833266241471e901L, - -6.078828929473797621198666799700739891205e905L, - 5.350908089710964244671334224708057812633e909L, - -4.742168072503284973969982758434401589090e913L, - 4.231149239401967697257534662010605751136e917L, - -3.800684612827828851942743291026898158947e921L, - 3.436984796314246158361599955909956583986e925L, + -2.277640649601959593875058983506938037019e309L, + 3.945184036046326234163525556422667595884e312L, + -6.938525772130602106071724989641405550473e315L, + 1.238896367577564823729057820219210929986e319L, + -2.245542599169309759499987966025604480745e322L, + 4.131213176073842359732511639489669404266e325L, + -7.713581346815269584960928069762882771369e328L, + 1.461536066837669600638613788471335541313e332L, + -2.809904606225532896862935642992712059631e335L, + 5.480957121318876639512096994413992284327e338L, + -1.084573284087686110518125291186079616320e342L, + 2.176980775647663539729165173863716459962e345L, + -4.431998786117553751947439433256752608068e348L, + 9.150625657715535047417756278073770096073e351L, + -1.915867353003157351316577579148683133613e355L, + 4.067256303542212258698836003682016040629e358L, + -8.754223791037736616228150209910348734629e361L, + 1.910173688735533667244373747124109379826e365L, + -4.225001320265091714631115064713174404607e368L, + 9.471959352547827678466770796787503034505e371L, + -2.152149973279986829719817376756088198573e375L, + 4.955485775334221051344839716507812871361e378L, + -1.156225941759134696630956889716381968142e382L, + 2.733406597646137698610991926705098514017e385L, + -6.546868135325176947099912523279938546333e388L, + 1.588524912441221472814692121069821695547e392L, + -3.904354800861715180218598151050191841308e395L, + 9.719938686092045781827273411668132975319e398L, + -2.450763621049522051234479737511375679283e402L, + 6.257892098396815305085674126334317095277e405L, + -1.618113552083806592527989531636955084420e409L, + 4.236528795217618357348618613216833722648e412L, + -1.123047068199051008086174989124136878992e416L, + 3.013971787525654770217283559392286666886e419L, + -8.188437573221553030375681429202969070420e422L, + 2.251910591336716809153958146725775718707e426L, + -6.268411292043789823075314151509139413399e429L, + 1.765990845202322642693572112511312471527e433L, + -5.035154436231331651259071296731160882240e436L, + 1.452779356460483245253765356664402207266e440L, + -4.241490890130137339052414960684151515166e443L, + 1.252966001692427774088293833338841893293e447L, + -3.744830047478272947978103227876747240343e450L, + 1.132315806695710930595876001089232216024e454L, + -3.463510845942701805991786197773934662578e457L, + 1.071643382649675572086865465873916611537e461L, + -3.353824475439933688957233489984711465335e464L, + 1.061594257145875875963152734129803268488e468L, + -3.398420969215528955528654193586189805265e471L, + 1.100192502000434096206138068020551065890e475L, + -3.601686379213993374332690210094863486472e478L, + 1.192235170430164900533187239994513019475e482L, + -3.990342751779668381699052942504119409180e485L, + 1.350281800938769780891258894167663309221e489L, + -4.619325443466054312873093650888507562249e492L, + 1.597522243968586548227514639959727696694e496L, + -5.584753729092155108530929002119620487652e499L, + 1.973443623104646193229794524759543752089e503L, + -7.048295441989615807045620880311201930244e506L, + 2.544236702499719094591873151590280263560e510L, + -9.281551595258615205927443367289948150345e513L, + 3.421757163154453657766296828520235351572e517L, + -1.274733639384538364282697627345068947433e521L, + 4.798524805311016034711205886780460173566e524L, + -1.825116948422858388787806917284878870034e528L, + 7.013667442807288452441777981425055613982e531L, + -2.723003862685989740898815670978399383114e535L, + 1.068014853917260290630122222858884658850e539L, + -4.231650952273697842269381683768681118533e542L, + 1.693650052202594386658903598564772900388e546L, + -6.846944855806453360616258582310883597678e549L, + 2.795809132238082267120232174243715559601e553L, + -1.153012972808983269106716828311318981951e557L, + 4.802368854268746357511997492039592697149e560L, + -2.019995255271910836389761734035403905781e564L, + 8.580207235032617856059250643095019760968e567L, + -3.680247942263468164408192134916355198549e571L, + 1.593924457586765331397457407661306895942e575L, + -6.970267175232643679233530367569943057501e578L, + 3.077528087427698518703282907890556154309e582L, + -1.371846760052887888926055417297342106614e586L, + 6.173627360829553396851763207025505289166e589L, + -2.804703130495506384463249394043486916669e593L, + 1.286250900087150126167490951216207186092e597L, + -5.954394420063617872366818601092036543220e600L, + 2.782297785278756426177542270854984091406e604L, + -1.312214674935307746141207680066262384215e608L, + 6.246299145383554153167974732783934504370e611L, + -3.000812007679574430883792565577444226490e615L, + 1.454904877136007844493861746476079537075e619L, + -7.118558521873800304612781121044077357278e622L, + 3.514739820897817389472822276832677887997e626L, + -1.751137068816377401163011262831890828437e630L, + 8.803498091818800678575314081978951179602e633L, + -4.465612911700593572269200981612564161010e637L, + 2.285494565287530681465757798517033542888e641L, + -1.180145168917737098025683613598595411329e645L, + 6.147941849198393232663105284575149616925e648L, + -3.231069156963603593233679426198974663352e652L, + 1.713042725635435041806895849197608270935e656L, + -9.161761363270648920537613435771882898051e659L, + 4.942675965960539112005679080810117766825e663L, + -2.689684712697383518131267222872386600031e667L, + 1.476320014229917759615308193449511534656e671L, + -8.173037740864781506597184122049453514594e674L, + 4.563462313190521363235182420178784459580e678L, + -2.569790015236158475703055501886439298708e682L, + 1.459410219452119981958355737832022375085e686L, + -8.358304882556983795372406183642486436653e689L, + 4.827305091483557818593092377664570208355e693L, + -2.811394311081493166793414157061950132403e697L, + 1.651026863340675349245561261339568827739e701L, + -9.776578579336866764167878646459810047899e704L, + 5.837207965197521880181236529616560780535e708L, + -3.513938957938032127105389702846371181520e712L, + 2.132747371360190507595748444536911078788e716L, + -1.305047363239192640729466563372665311602e720L, + 8.050825342678337497636292798039996484780e723L, + -5.006884161223862543665524155681082112689e727L, + 3.139016066011452177570812014513491361235e731L, + -1.983829535212711378291469356666001365873e735L, + 1.263822427649676371257598052486237628698e739L, + -8.115678659900522918802121684491754629503e742L, + 5.252995164972075271667364371449050412435e746L, + -3.427038125662404660056511738625477058135e750L, + 2.253446011834352733279946306835940729858e754L, + -1.493407341897034717876962786798831719683e758L, + 9.974681322653365118752729509398728354442e761L, + -6.714230142773850863927710112350816379426e765L, + 4.554668668931723346600337564274944733530e769L, + -3.113635386023220127834102980385275379533e773L, + 2.144945411287666204679363498162954050208e777L, + -1.488982121181387164932397544378555256016e781L, + 1.041537218854627455352298173588983048748e785L, + -7.341073881786613676177562822942175683993e788L, + 5.213524272587199574980117351016322518428e792L, + -3.730592531776514409283897139216167197989e796L, + 2.689592876341877079083449497724049500175e800L, + -1.953643788231947582529884602972233135002e804L, + 1.429691073080500563348668321308878246277e808L, + -1.054059177095488639836063073070536825675e812L, + 7.828919160938693948399336431565350676613e815L, + -5.857884457184396382550955498026762014753e819L, + 4.415401588264172474136969345712659422380e823L, + -3.352573884181287635796498822858109969161e827L, + 2.564210385719224000156548240934108974447e831L, + -1.975534392116037602837941409848663077528e835L, + 1.533062123975940045180943006948008486466e839L, + -1.198306160488763291730059994812781226903e843L, + 9.434034267770711698676321369174735725321e846L, + -7.480619200038505368468483892246806488879e850L, + 5.974161898439971564124576801455052907638e854L, + -4.805125663714699771668630995361572639386e858L, + 3.892332138028039952403812726744593073776e862L, + -3.175276505779699340738548328810180869575e866L, + 2.608608681939322393581069188271626122519e870L, + -2.158148554392732439392868052394994052628e874L, + 1.797993483301448477700600221980862686033e878L, + -1.508407575089108597171576068862286462909e882L, + 1.274273406242459482708930389008701147244e886L, + -1.083950475353171986748233157909397370193e890L, + 9.284292630726328432038470356821265395331e893L, + -8.007012115449516364480417355063446317414e897L, + 6.952871948429568933888979915833266241471e901L, + -6.078828929473797621198666799700739891205e905L, + 5.350908089710964244671334224708057812633e909L, + -4.742168072503284973969982758434401589090e913L, + 4.231149239401967697257534662010605751136e917L, + -3.800684612827828851942743291026898158947e921L, + 3.436984796314246158361599955909956583986e925L, -3.128930718993658356398482705317381808301e929L, // // 602-1300: http://www.wolframalpha.com/input/?i=TABLE[N[Bernoulli[i]%2C40]%2C+{i%2C602%2C1300%2C2}] diff --git a/src/mlpack/core/boost_backport/policy.hpp b/src/mlpack/core/boost_backport/policy.hpp index 391c9d19641..bef8aaf1f95 100644 --- a/src/mlpack/core/boost_backport/policy.hpp +++ b/src/mlpack/core/boost_backport/policy.hpp @@ -31,7 +31,7 @@ #include #include -namespace boost{ namespace math{ +namespace boost{ namespace math{ namespace tools{ @@ -309,7 +309,7 @@ char test_is_valid_arg(const default_policy*); char test_is_default_arg(const default_policy*); template -struct is_valid_policy_imp +struct is_valid_policy_imp { BOOST_STATIC_CONSTANT(bool, value = sizeof(::boost::math::policies::detail::test_is_valid_arg(static_cast(0))) == 1); }; @@ -320,13 +320,13 @@ struct is_default_policy_imp BOOST_STATIC_CONSTANT(bool, value = sizeof(::boost::math::policies::detail::test_is_default_arg(static_cast(0))) == 1); }; -template struct is_valid_policy -: public mpl::bool_< +template struct is_valid_policy +: public mpl::bool_< ::boost::math::policies::detail::is_valid_policy_imp::value> {}; -template struct is_default_policy -: public mpl::bool_< +template struct is_default_policy +: public mpl::bool_< ::boost::math::policies::detail::is_default_policy_imp::value> { template @@ -389,8 +389,8 @@ typedef default_args max_root_iterations_type; }; -template -struct normalise, - promote_float, - promote_double, +struct normalise, + promote_float, + promote_double, discrete_quantile<>, assert_undefined<>, default_policy, @@ -652,72 +652,72 @@ inline BOOST_MATH_CONSTEXPR policy<> make_policy() BOOST_NOEXCEPT template inline BOOST_MATH_CONSTEXPR typename normalise, A1>::type make_policy(const A1&) BOOST_NOEXCEPT -{ +{ typedef typename normalise, A1>::type result_type; - return result_type(); + return result_type(); } template inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2>::type make_policy(const A1&, const A2&) BOOST_NOEXCEPT -{ +{ typedef typename normalise, A1, A2>::type result_type; - return result_type(); + return result_type(); } template inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3>::type make_policy(const A1&, const A2&, const A3&) BOOST_NOEXCEPT -{ +{ typedef typename normalise, A1, A2, A3>::type result_type; - return result_type(); + return result_type(); } template inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4>::type make_policy(const A1&, const A2&, const A3&, const A4&) BOOST_NOEXCEPT -{ +{ typedef typename normalise, A1, A2, A3, A4>::type result_type; - return result_type(); + return result_type(); } template inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&) BOOST_NOEXCEPT -{ +{ typedef typename normalise, A1, A2, A3, A4, A5>::type result_type; - return result_type(); + return result_type(); } template inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&) BOOST_NOEXCEPT -{ +{ typedef typename normalise, A1, A2, A3, A4, A5, A6>::type result_type; - return result_type(); + return result_type(); } template inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6, A7>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&) BOOST_NOEXCEPT -{ +{ typedef typename normalise, A1, A2, A3, A4, A5, A6, A7>::type result_type; - return result_type(); + return result_type(); } template inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6, A7, A8>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&) BOOST_NOEXCEPT -{ +{ typedef typename normalise, A1, A2, A3, A4, A5, A6, A7, A8>::type result_type; - return result_type(); + return result_type(); } template inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&) BOOST_NOEXCEPT -{ +{ typedef typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9>::type result_type; - return result_type(); + return result_type(); } template inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&, const A10&) BOOST_NOEXCEPT -{ +{ typedef typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::type result_type; - return result_type(); + return result_type(); } template @@ -808,7 +808,7 @@ struct precision // Possibly unknown precision: precision_type, typename mpl::if_c< - ((::std::numeric_limits::digits <= precision_type::value) + ((::std::numeric_limits::digits <= precision_type::value) || (Policy::precision_type::value <= 0)), // Default case, full precision for RealType: digits2< ::std::numeric_limits::digits>, @@ -966,8 +966,8 @@ inline BOOST_MATH_CONSTEXPR T get_epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) namespace detail{ -template - inline typename tools::promote_args::type + inline typename tools::promote_args::type trigamma(T x, const Policy&); template - inline typename tools::promote_args::type + inline typename tools::promote_args::type trigamma(T x); }} namespace boost { namespace math { - + template inline typename tools::promote_args::type polygamma(const int n, T x, const Policy& pol) { diff --git a/src/mlpack/core/boost_backport/trigamma.hpp b/src/mlpack/core/boost_backport/trigamma.hpp index c526f1a0af5..ebf435289e4 100644 --- a/src/mlpack/core/boost_backport/trigamma.hpp +++ b/src/mlpack/core/boost_backport/trigamma.hpp @@ -99,7 +99,7 @@ T trigamma_prec(T x, const mpl::int_<53>*, const Policy&) T y = 1 / x; return (1 + tools::evaluate_polynomial(P_4_inf, y) / tools::evaluate_polynomial(Q_4_inf, y)) / x; } - + template T trigamma_prec(T x, const mpl::int_<64>*, const Policy&) { @@ -418,7 +418,7 @@ const typename trigamma_initializer::init trigamma_initializer -inline typename tools::promote_args::type +inline typename tools::promote_args::type trigamma(T x, const Policy&) { typedef typename tools::promote_args::type result_type; @@ -457,7 +457,7 @@ inline typename tools::promote_args::type } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type trigamma(T x) { return trigamma(x, policies::policy<>()); diff --git a/src/mlpack/core/dists/gamma_distribution.cpp b/src/mlpack/core/dists/gamma_distribution.cpp index d2e424390dc..a8da1a28c6d 100644 --- a/src/mlpack/core/dists/gamma_distribution.cpp +++ b/src/mlpack/core/dists/gamma_distribution.cpp @@ -29,7 +29,7 @@ GammaDistribution::GammaDistribution(const arma::mat& data, Train(data, tol); } -GammaDistribution::GammaDistribution(const arma::vec& alpha, +GammaDistribution::GammaDistribution(const arma::vec& alpha, const arma::vec& beta) { if (beta.n_elem != alpha.n_elem) @@ -142,7 +142,7 @@ void GammaDistribution::Train(const arma::vec& logMeanxVec, // Protect against division by 0. if (denominator == 0) - throw std::logic_error("GammaDistribution::Train() attempted division" + throw std::logic_error("GammaDistribution::Train() attempted division" " by 0."); aEst = 1.0 / ((1.0 / aEst) + nominator / denominator); @@ -160,7 +160,7 @@ void GammaDistribution::Train(const arma::vec& logMeanxVec, } // Returns the probability of the provided observations. -void GammaDistribution::Probability(const arma::mat& observations, +void GammaDistribution::Probability(const arma::mat& observations, arma::vec& probabilities) const { size_t numObs = observations.n_cols; @@ -191,12 +191,12 @@ void GammaDistribution::Probability(const arma::mat& observations, // dimensions. double GammaDistribution::Probability(double x, size_t dim) const { - return std::pow(x, alpha(dim) - 1) * std::exp(-x / beta(dim)) / + return std::pow(x, alpha(dim) - 1) * std::exp(-x / beta(dim)) / (std::tgamma(alpha(dim)) * std::pow(beta(dim), alpha(dim))); } // Returns the log probability of the provided observations. -void GammaDistribution::LogProbability(const arma::mat& observations, +void GammaDistribution::LogProbability(const arma::mat& observations, arma::vec& LogProbabilities) const { size_t numObs = observations.n_cols; diff --git a/src/mlpack/core/dists/gamma_distribution.hpp b/src/mlpack/core/dists/gamma_distribution.hpp index 95b2de8991c..eadf78a55ac 100644 --- a/src/mlpack/core/dists/gamma_distribution.hpp +++ b/src/mlpack/core/dists/gamma_distribution.hpp @@ -88,7 +88,7 @@ class GammaDistribution * * @param rdata Reference data to fit parameters to. * @param tol Convergence tolerance. This is *not* an absolute measure: - * It will stop the approximation once the *change* in the value is + * It will stop the approximation once the *change* in the value is * smaller than tol. */ void Train(const arma::mat& rdata, const double tol = 1e-8); @@ -101,7 +101,7 @@ class GammaDistribution * @param probabilities The probability of each observation. One value per * column of the observations matrix. * @param tol Convergence tolerance. This is *not* an absolute measure: - * It will stop the approximation once the *change* in the value is + * It will stop the approximation once the *change* in the value is * smaller than tol. */ void Train(const arma::mat& observations, diff --git a/src/mlpack/core/tree/binary_space_tree/ub_tree_split_impl.hpp b/src/mlpack/core/tree/binary_space_tree/ub_tree_split_impl.hpp index 0841c15c508..46f784b60c2 100644 --- a/src/mlpack/core/tree/binary_space_tree/ub_tree_split_impl.hpp +++ b/src/mlpack/core/tree/binary_space_tree/ub_tree_split_impl.hpp @@ -85,7 +85,7 @@ bool UBTreeSplit::SplitNode(BoundType& bound, for (; row < data.n_rows; row++) for (; bit < order; bit++) - lo[row] |= ((AddressElemType) 1 << (order - 1 - bit)); + lo[row] |= ((AddressElemType) 1 << (order - 1 - bit)); } // The bound shouldn't contain too many subrectangles. @@ -128,7 +128,7 @@ bool UBTreeSplit::SplitNode(BoundType& bound, for (; row < data.n_rows; row++) for (; bit < order; bit++) - hi[row] &= ~((AddressElemType) 1 << (order - 1 - bit)); + hi[row] &= ~((AddressElemType) 1 << (order - 1 - bit)); } // Set the minimum and the maximum addresses. diff --git a/src/mlpack/core/tree/cellbound.hpp b/src/mlpack/core/tree/cellbound.hpp index 7b45cc523f4..5805f99b7a5 100644 --- a/src/mlpack/core/tree/cellbound.hpp +++ b/src/mlpack/core/tree/cellbound.hpp @@ -123,7 +123,7 @@ class CellBound arma::Col& LoAddress() { return loAddress; } //! Modify lower address. const arma::Col& LoAddress() const {return loAddress; } - + //! Get high address. arma::Col& HiAddress() { return hiAddress; } //! Modify high address. diff --git a/src/mlpack/core/tree/rectangle_tree/r_plus_tree_split_policy.hpp b/src/mlpack/core/tree/rectangle_tree/r_plus_tree_split_policy.hpp index 0a6047343e2..3b22375b3e7 100644 --- a/src/mlpack/core/tree/rectangle_tree/r_plus_tree_split_policy.hpp +++ b/src/mlpack/core/tree/rectangle_tree/r_plus_tree_split_policy.hpp @@ -61,7 +61,7 @@ class RPlusTreeSplitPolicy * Return the minimum bounding rectangle of the node. * This method should always return the bound that is used for the * decision-making in GetSplitPolicy(). - * + * * @param node The node whose bound is requested. */ template diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp index 42746e84b80..d88452499ad 100644 --- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp @@ -113,7 +113,7 @@ RectangleTree( RectangleTree* parentNode,const size_t numMaxChildren) : - maxNumChildren(numMaxChildren > 0 ? numMaxChildren : + maxNumChildren(numMaxChildren > 0 ? numMaxChildren : parentNode->MaxNumChildren()), minNumChildren(parentNode->MinNumChildren()), numChildren(0), diff --git a/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp index a8f6dc89634..b8482c41f78 100644 --- a/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp @@ -316,7 +316,7 @@ bool XTreeSplit::SplitNonLeafNode(TreeType *tree,std::vector& relevels) std::vector axes(tree->Bound().Dim()); std::vector dimensionsLastUsed(tree->NumChildren()); for (size_t i = 0; i < tree->NumChildren(); i++) - dimensionsLastUsed[i] = + dimensionsLastUsed[i] = tree->Child(i).AuxiliaryInfo().SplitHistory().lastDimension; std::sort(dimensionsLastUsed.begin(), dimensionsLastUsed.end()); @@ -328,7 +328,7 @@ bool XTreeSplit::SplitNonLeafNode(TreeType *tree,std::vector& relevels) { axes[i] = true; for (size_t j = 0; j < tree->NumChildren(); j++) - axes[i] = axes[i] & + axes[i] = axes[i] & tree->Child(j).AuxiliaryInfo().SplitHistory().history[i]; if (axes[i] == true) { @@ -342,7 +342,7 @@ bool XTreeSplit::SplitNonLeafNode(TreeType *tree,std::vector& relevels) { axes[i] = true; for (size_t j = 0; j < tree->NumChildren(); j++) - axes[i] = axes[i] & + axes[i] = axes[i] & tree->Child(j).AuxiliaryInfo().SplitHistory().history[i]; if (axes[i] == true) { @@ -688,7 +688,7 @@ bool XTreeSplit::SplitNonLeafNode(TreeType *tree,std::vector& relevels) (tree->Parent()->NumChildren() == 1)) { // We make the root a supernode instead. - tree->Parent()->MaxNumChildren() = tree->MaxNumChildren() + + tree->Parent()->MaxNumChildren() = tree->MaxNumChildren() + tree->AuxiliaryInfo().NormalNodeMaxNumChildren(); tree->Parent()->children.resize(tree->Parent()->MaxNumChildren() + 1); tree->Parent()->NumChildren() = tree->NumChildren(); @@ -706,7 +706,7 @@ bool XTreeSplit::SplitNonLeafNode(TreeType *tree,std::vector& relevels) } // If we don't have to worry about the root, we just enlarge this node. - tree->MaxNumChildren() += + tree->MaxNumChildren() += tree->AuxiliaryInfo().NormalNodeMaxNumChildren(); tree->children.resize(tree->MaxNumChildren() + 1); for (size_t i = 0; i < tree->NumChildren(); i++) diff --git a/src/mlpack/methods/adaboost/adaboost_main.cpp b/src/mlpack/methods/adaboost/adaboost_main.cpp index c05f083ecb5..4310e2048fd 100644 --- a/src/mlpack/methods/adaboost/adaboost_main.cpp +++ b/src/mlpack/methods/adaboost/adaboost_main.cpp @@ -229,7 +229,7 @@ int main(int argc, char *argv[]) Row results; data::RevertLabels(predictedLabels, m.Mappings(), results); - + if (CLI::HasParam("output")) CLI::GetParam>("output") = std::move(results); } diff --git a/src/mlpack/methods/ann/activation_functions/softplus_function.hpp b/src/mlpack/methods/ann/activation_functions/softplus_function.hpp index ab306496c79..4adc5d746c1 100644 --- a/src/mlpack/methods/ann/activation_functions/softplus_function.hpp +++ b/src/mlpack/methods/ann/activation_functions/softplus_function.hpp @@ -43,7 +43,7 @@ namespace ann /** Artificial Neural Network. */ { class SoftplusFunction { public: - + /** * Computes the softplus function. * diff --git a/src/mlpack/methods/dbscan/dbscan.hpp b/src/mlpack/methods/dbscan/dbscan.hpp index e35d7f9bfb1..58ce304171c 100644 --- a/src/mlpack/methods/dbscan/dbscan.hpp +++ b/src/mlpack/methods/dbscan/dbscan.hpp @@ -65,7 +65,7 @@ class DBSCAN PointSelectionPolicy pointSelector = PointSelectionPolicy()); /** - * Performs DBSCAN clustering on the data, returning number of clusters + * Performs DBSCAN clustering on the data, returning number of clusters * and also the centroid of each cluster. * * @tparam MatType Type of matrix (arma::mat or arma::sp_mat). @@ -77,7 +77,7 @@ class DBSCAN arma::mat& centroids); /** - * Performs DBSCAN clustering on the data, returning number of clusters + * Performs DBSCAN clustering on the data, returning number of clusters * and also the list of cluster assignments. * * @tparam MatType Type of matrix (arma::mat or arma::sp_mat). @@ -89,7 +89,7 @@ class DBSCAN arma::Row& assignments); /** - * Performs DBSCAN clustering on the data, returning number of clusters, + * Performs DBSCAN clustering on the data, returning number of clusters, * the centroid of each cluster and also the list of cluster assignments. * If assignments[i] == assignments.n_elem - 1, then the point is considered * "noise". diff --git a/src/mlpack/methods/dbscan/dbscan_impl.hpp b/src/mlpack/methods/dbscan/dbscan_impl.hpp index 91e0b829f10..1c6d5e76675 100644 --- a/src/mlpack/methods/dbscan/dbscan_impl.hpp +++ b/src/mlpack/methods/dbscan/dbscan_impl.hpp @@ -35,7 +35,7 @@ DBSCAN::DBSCAN( } /** - * Performs DBSCAN clustering on the data, returning number of clusters + * Performs DBSCAN clustering on the data, returning number of clusters * and also the centroid of each cluster. */ template @@ -53,7 +53,7 @@ size_t DBSCAN::Cluster( } /** - * Performs DBSCAN clustering on the data, returning number of clusters, + * Performs DBSCAN clustering on the data, returning number of clusters, * the centroid of each cluster and also the list of cluster assignments. */ template @@ -89,7 +89,7 @@ size_t DBSCAN::Cluster( } /** - * Performs DBSCAN clustering on the data, returning number of clusters + * Performs DBSCAN clustering on the data, returning number of clusters * and also the list of cluster assignments. */ template diff --git a/src/mlpack/methods/naive_bayes/naive_bayes_classifier.hpp b/src/mlpack/methods/naive_bayes/naive_bayes_classifier.hpp index 71df747331f..b5b4e1fce4b 100644 --- a/src/mlpack/methods/naive_bayes/naive_bayes_classifier.hpp +++ b/src/mlpack/methods/naive_bayes/naive_bayes_classifier.hpp @@ -120,7 +120,7 @@ class NaiveBayesClassifier size_t Classify(const VecType& point) const; /** - * Classify the given point using the training GaussianNB model + * Classify the given point using the training GaussianNB model * and also return estimates of the probability for * each class in the given vector. * @@ -152,8 +152,8 @@ class NaiveBayesClassifier arma::Row& predictions) const; /** - * Classify the given points using the training GaussianNB model - * and also return estimates of the probabilities for each class in the given matrix. + * Classify the given points using the training GaussianNB model + * and also return estimates of the probabilities for each class in the given matrix. * The predicted labels for each point are stored in the given vector. * * @code diff --git a/src/mlpack/methods/range_search/rs_model.cpp b/src/mlpack/methods/range_search/rs_model.cpp index 401372b16b8..747c3f600e8 100644 --- a/src/mlpack/methods/range_search/rs_model.cpp +++ b/src/mlpack/methods/range_search/rs_model.cpp @@ -136,7 +136,7 @@ void RSModel::BuildModel(arma::mat&& referenceSet, break; case BALL_TREE: - rSearch = new RSType(naive, singleMode); + rSearch = new RSType(naive, singleMode); break; case X_TREE: diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp b/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp index f17e11d0562..f262fb4082c 100644 --- a/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp +++ b/src/mlpack/methods/softmax_regression/softmax_regression_main.cpp @@ -179,7 +179,7 @@ void TestClassifyAcc(size_t numClasses, const Model& model) // Calculate accuracy, if desired. if (CLI::HasParam("test_labels")) { - arma::Row testLabels = + arma::Row testLabels = std::move(CLI::GetParam>("test_labels")); if (testData.n_cols != testLabels.n_elem) @@ -231,7 +231,7 @@ unique_ptr TrainSoftmax(const size_t maxIterations) else { arma::mat trainData = std::move(CLI::GetParam("training")); - arma::Row trainLabels = + arma::Row trainLabels = std::move(CLI::GetParam>("labels")); if (trainData.n_cols != trainLabels.n_elem) diff --git a/src/mlpack/tests/det_test.cpp b/src/mlpack/tests/det_test.cpp index b09781bef1d..bff2baf583c 100644 --- a/src/mlpack/tests/det_test.cpp +++ b/src/mlpack/tests/det_test.cpp @@ -150,30 +150,30 @@ BOOST_AUTO_TEST_CASE(TestSplitData) BOOST_AUTO_TEST_CASE(TestSparseFindSplit) { arma::mat realData(4,7); - + realData << .0 << 4 << 5 << 7 << 0 << 5 << 0 << arma::endr << .0 << 5 << 0 << 0 << 1 << 7 << 1 << arma::endr << .0 << 5 << 6 << 7 << 1 << 0 << 8 << arma::endr << -1 << 2 << 5 << 0 << 0 << 0 << 0 << arma::endr; - + arma::sp_mat testData(realData); - + DTree testDTree(testData); - + size_t obDim, trueDim; double trueLeftError, obLeftError, trueRightError, obRightError, obSplit, trueSplit; - + trueDim = 1; trueSplit = .5; trueLeftError = 2 * log(3.0 / 7.0) - (log(7.0) + log(0.5) + log(8.0) + log(6.0)); trueRightError = 2 * log(4.0 / 7.0) - (log(7.0) + log(6.5) + log(8.0) + log(6.0)); - + testDTree.logVolume = log(7.0) + log(7.0) + log(8.0) + log(6.0); BOOST_REQUIRE(testDTree.FindSplit(testData, obDim, obSplit, obLeftError, obRightError, 1)); - + BOOST_REQUIRE(trueDim == obDim); BOOST_REQUIRE_CLOSE(trueSplit, obSplit, 1e-10); - + BOOST_REQUIRE_CLOSE(trueLeftError, obLeftError, 1e-10); BOOST_REQUIRE_CLOSE(trueRightError, obRightError, 1e-10); } @@ -181,26 +181,26 @@ BOOST_AUTO_TEST_CASE(TestSparseFindSplit) BOOST_AUTO_TEST_CASE(TestSparseSplitData) { arma::mat realData(4,7); - + realData << .0 << 4 << 5 << 7 << 0 << 5 << 0 << arma::endr << .0 << 5 << 0 << 0 << 1 << 7 << 1 << arma::endr << .0 << 5 << 6 << 7 << 1 << 0 << 8 << arma::endr << -1 << 2 << 5 << 0 << 0 << 0 << 0 << arma::endr; - + arma::sp_mat testData(realData); - + DTree testDTree(testData); - + arma::Col oTest(7); oTest << 1 << 2 << 3 << 4 << 5 << 6 << 7; - + size_t splitDim = 1; double trueSplitVal = .5; - + size_t splitInd = testDTree.SplitData(testData, splitDim, trueSplitVal, oTest); - + BOOST_REQUIRE_EQUAL(splitInd, 3); // 2 points on left side. - + BOOST_REQUIRE_EQUAL(oTest[0], 1); BOOST_REQUIRE_EQUAL(oTest[1], 4); BOOST_REQUIRE_EQUAL(oTest[2], 3); diff --git a/src/mlpack/tests/distribution_test.cpp b/src/mlpack/tests/distribution_test.cpp index 242927225ac..bbf22a6c400 100644 --- a/src/mlpack/tests/distribution_test.cpp +++ b/src/mlpack/tests/distribution_test.cpp @@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE(MultiDiscreteDistributionTrainProbTest) arma::mat obs("0 1 1 1 2 2 2 2 2 2;" "0 0 0 1 1 1 2 2 2 2;" "0 0 0 1 1 2 2 2 2 2;"); - + d.Train(obs); BOOST_REQUIRE_CLOSE(d.Probability("0 0 0"), 0.009, 1e-5); BOOST_REQUIRE_CLOSE(d.Probability("0 1 2"), 0.015, 1e-5); @@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE(MultiDiscreteDistributionTrainProbTest) } /** - * Make sure we initialize multidimensional probability distribution + * Make sure we initialize multidimensional probability distribution * correctly. */ BOOST_AUTO_TEST_CASE(MultiDiscreteDistributionConstructorTest) diff --git a/src/mlpack/tests/ind2sub_test.cpp b/src/mlpack/tests/ind2sub_test.cpp index c43cb00a76e..98e425c01dc 100644 --- a/src/mlpack/tests/ind2sub_test.cpp +++ b/src/mlpack/tests/ind2sub_test.cpp @@ -16,7 +16,7 @@ BOOST_AUTO_TEST_SUITE(ind2subTest); /** - * This test checks whether ind2sub and sub2ind are + * This test checks whether ind2sub and sub2ind are * compiled successfully and that they function properly. */ BOOST_AUTO_TEST_CASE(ind2sub_test) diff --git a/src/mlpack/tests/prefixedoutstream_test.cpp b/src/mlpack/tests/prefixedoutstream_test.cpp index 5eabc6a31ce..eb4a93cae43 100644 --- a/src/mlpack/tests/prefixedoutstream_test.cpp +++ b/src/mlpack/tests/prefixedoutstream_test.cpp @@ -29,7 +29,7 @@ using namespace mlpack::util; BOOST_AUTO_TEST_SUITE(PrefixedOutStreamTest); /** - * Test the output of CLI using PrefixedOutStream. We will pass bogus + * Test the output of CLI using PrefixedOutStream. We will pass bogus * input to a stringstream so that none of it gets to the screen. */ BOOST_AUTO_TEST_CASE(TestPrefixedOutStreamBasic) @@ -220,11 +220,11 @@ BOOST_AUTO_TEST_CASE(TestArmaCustomPrecision) pss << trans(test2); BOOST_REQUIRE_EQUAL(ss.str(), - BASH_GREEN "[INFO ] " BASH_CLEAR + BASH_GREEN "[INFO ] " BASH_CLEAR " 1.00000000 2.50000000 40.00000000\n" - BASH_GREEN "[INFO ] " BASH_CLEAR + BASH_GREEN "[INFO ] " BASH_CLEAR " 1.50000000 3.00000000 4.50000000\n" - BASH_GREEN "[INFO ] " BASH_CLEAR + BASH_GREEN "[INFO ] " BASH_CLEAR " 2.00000000 3.50000000 4.99999000\n"); // Test stream after reset. diff --git a/src/mlpack/tests/tree_test.cpp b/src/mlpack/tests/tree_test.cpp index f0463c784ed..449ebebc05f 100644 --- a/src/mlpack/tests/tree_test.cpp +++ b/src/mlpack/tests/tree_test.cpp @@ -1573,7 +1573,7 @@ void CheckRPTreeSplit(const TreeType& tree) BOOST_REQUIRE_LE(maxDist, dist * (1.0 + 10.0 * std::numeric_limits::epsilon())); } - + } CheckRPTreeSplit(*tree.Left()); diff --git a/src/mlpack/tests/ub_tree_test.cpp b/src/mlpack/tests/ub_tree_test.cpp index 7e9f0fd66e1..8b75e2d7e31 100644 --- a/src/mlpack/tests/ub_tree_test.cpp +++ b/src/mlpack/tests/ub_tree_test.cpp @@ -203,7 +203,7 @@ void CheckDistance(TreeType& tree, TreeType* node = NULL) BOOST_REQUIRE_LE(maxDist, r.Hi() * (1.0 + 10 * std::numeric_limits::epsilon())); } - + if (!tree.IsLeaf()) { CheckDistance(*tree.Left()); diff --git a/src/mlpack/tests/vantage_point_tree_test.cpp b/src/mlpack/tests/vantage_point_tree_test.cpp index ba60f2d126e..2223341f21c 100644 --- a/src/mlpack/tests/vantage_point_tree_test.cpp +++ b/src/mlpack/tests/vantage_point_tree_test.cpp @@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE(HollowBallBoundTest) b2 = HollowBallBound(0.5, 2.0, arma::vec("1.0 8.0 3.0 4.0 5.0")); BOOST_REQUIRE_CLOSE(b.MaxDistance(b2), 12.0, 1e-5); - + b2 = HollowBallBound(0.5, 2.0, arma::vec("1.0 3.0 3.0 4.0 5.0")); BOOST_REQUIRE_CLOSE(b.MaxDistance(b2), 7.0, 1e-5); @@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(HollowBallBoundTest) b1 |= b2; BOOST_REQUIRE_CLOSE(b1.InnerRadius(), 0.5, 1e-5); - + b1 = b; b2 = HollowBallBound(0.5, 2.0, arma::vec("1.0 3.0 3.0 4.0 5.0"));