Compare commits

...
46 Commits
Author SHA1 Message Date
conrad d5e0669bde disable detection of HDF5 2023-03-09 12:24:35 +10:00
conrad ed97f0c946 backport changes 2023-03-09 12:20:28 +10:00
conrad e16a3a20c5 patch bump 2023-02-09 14:57:43 +10:00
conrad 6b5fcd0a1c add warning message 2023-02-07 14:42:12 +10:00
conrad 8c6ffe3a07 add note 2023-02-06 12:00:06 +10:00
conrad 8fa5e24d08 cleanup 2023-02-04 01:40:51 +10:00
conrad a6dacf3560 update spec 2023-02-03 15:27:26 +10:00
conrad b894ad1ea0 remove prototypes for unimplemented functions 2023-02-03 15:05:25 +10:00
conrad 42f38ce3ca mark quiet_load() and quiet_save() as deprecated 2023-02-03 15:04:30 +10:00
conrad 2ba8d27d1c mark quiet_load() and quiet_save() as deprecated 2023-02-03 00:26:31 +10:00
conrad 73413038af add note 2023-01-24 12:57:17 +10:00
conrad 15a8339ab4 rename 2023-01-20 13:21:11 +10:00
conrad b1ac5935bf simplification 2023-01-18 12:31:08 +10:00
conrad df1aa31d59 reduce delta 2023-01-18 12:06:29 +10:00
conrad 280b6c29c6 detect NaN in XI 2023-01-18 12:04:45 +10:00
conrad dbc44eb318 add warning note 2023-01-17 18:37:16 +10:00
conrad 43695b7809 explictly mark internal functionality 2023-01-17 12:00:43 +10:00
conrad a841ced91c add option for forward compat 2023-01-05 14:01:24 +10:00
conrad c066c0eca2 rearrange 2023-01-02 13:49:09 +10:00
conrad e37512d884 better layout 2023-01-02 13:40:51 +10:00
conrad 25e4ae7a83 simplify warning 2023-01-01 15:48:26 +10:00
conrad 6c46335c83 undefine yet another conflicting macro 2023-01-01 15:47:34 +10:00
conrad 88ab7d02a5 patch bump 2022-12-23 15:17:05 +10:00
conrad eccbb21574 remove no longer used code 2022-12-23 14:38:17 +10:00
conrad a6da58cdd4 make intent clear 2022-12-23 14:34:25 +10:00
conrad 72df37c321 rearrange 2022-12-20 16:24:33 +10:00
conrad 801843f724 simplifications 2022-12-20 12:10:36 +10:00
conrad 9599020e99 better wording 2022-12-20 12:03:31 +10:00
conrad 87e3298939 mark detection of HDF5 as deprecated 2022-12-20 11:54:11 +10:00
conrad 0f3c217f59 layout improvements 2022-12-20 11:42:39 +10:00
conrad 5e02112701 layout fix 2022-12-20 11:38:52 +10:00
conrad 1c84135e80 simplifications 2022-12-20 11:37:46 +10:00
conrad 779c12b84e swap 2022-12-16 12:06:34 +10:00
conrad b865430006 recommend using inv() and inv_sympd() with inv_opts::allow_approx 2022-12-16 12:05:20 +10:00
conrad 2bfb287cd0 simplification 2022-12-16 11:51:58 +10:00
conrad 2af1cc4d7f prevent warnings 2022-12-16 01:04:40 +10:00
conrad 3f56840f86 add deprecation note 2022-12-15 18:55:35 +10:00
conrad 05d3a38aa6 comment out sympd optimisation 2022-12-15 17:20:51 +10:00
conrad 5164042b2c simplification 2022-12-12 12:48:23 +10:00
conrad 65147441cb better wording 2022-12-10 19:24:24 +10:00
conrad 0de4fd33c4 remove docs for deprecated functionality 2022-12-08 16:18:19 +10:00
conrad 6c07fc5875 normalise order of declarations 2022-12-08 13:45:07 +10:00
conrad 06ba8d84cb mark set_cout_stream() and set_cerr_stream() as deprecated 2022-12-08 11:56:28 +10:00
conrad 47743b1ed4 add bool indicator for c++20 2022-12-07 11:07:49 +10:00
conrad 852a2cca85 remove broken functionality 2022-12-06 17:12:42 +10:00
conrad af1bc287bb simplifications 2022-12-06 17:08:30 +10:00
28 changed files with 278 additions and 626 deletions
+5 -2
View File
@@ -192,9 +192,9 @@ else()
option(BUILD_SHARED_LIBS "build shared library" ON)
endif()
option(DETECT_HDF5 "Detect HDF5 and include HDF5 support, if found" ON)
option(DETECT_HDF5 "Detect HDF5 (deprecated)" OFF)
# set(DETECT_HDF5 false)
## uncomment the above line to disable the detection of the HDF5 library;
## uncomment the above line to forcefully disable the detection of the HDF5 library;
## you can also disable HDF5 detection directly on the command line:
## cmake -D DETECT_HDF5=false .
@@ -458,6 +458,9 @@ find_package(PkgConfig)
if(DETECT_HDF5)
message(STATUS "")
message(STATUS "*** NOTE: detection of HDF5 is deprecated")
find_package(HDF5 QUIET COMPONENTS C)
if(NOT HDF5_FOUND)
+52 -93
View File
@@ -2039,9 +2039,9 @@ examples of omitted functions: <a href="#fill">.fill()</a>, <a href="#ones_membe
<a name="batch_constructors_sp_mat"></a>
Batch insertion constructors:
<ul>
<li>form&nbsp;1: <code>sp_mat(<i>locations</i>, <i>values</i>, <i>sort_locations = true</i>)</code></li>
<li>form&nbsp;2: <code>sp_mat(<i>locations</i>, <i>values</i>, <i>n_rows</i>, <i>n_cols</i>, <i>sort_locations&nbsp;=&nbsp;true</i>, <i>check_for_zeros&nbsp;=&nbsp;true</i>)</code></li>
<li>form&nbsp;3: <code>sp_mat(<i>add_values</i>, <i>locations</i>, <i>values</i>, <i>n_rows</i>, <i>n_cols</i>, <i>sort_locations&nbsp;=&nbsp;true</i>, <i>check_for_zeros&nbsp;=&nbsp;true</i>)</code></li>
<li>form&nbsp;1: <code>sp_mat(<i>locations</i>, <i>values</i>, <i>sort_locations&thinsp;=&thinsp;true</i>)</code></li>
<li>form&nbsp;2: <code>sp_mat(<i>locations</i>, <i>values</i>, <i>n_rows</i>, <i>n_cols</i>, <i>sort_locations&thinsp;=&thinsp;true</i>, <i>check_for_zeros&thinsp;=&thinsp;true</i>)</code></li>
<li>form&nbsp;3: <code>sp_mat(<i>add_values</i>, <i>locations</i>, <i>values</i>, <i>n_rows</i>, <i>n_cols</i>, <i>sort_locations&thinsp;=&thinsp;true</i>, <i>check_for_zeros&thinsp;=&thinsp;true</i>)</code></li>
<li>form&nbsp;4: <code>sp_mat(<i>rowind</i>, <i>colptr</i>, <i>values</i>, <i>n_rows</i>, <i>n_cols</i>)</code></li>
<br>
<ul>
@@ -9011,7 +9011,7 @@ Given matrix <i>X</i>, generate a matrix with the <i>k</i>-th diagonal containin
</li>
<br>
<li>
If <i>X</i> is an expression, the evaluation of the expression aims to only calculate the diagonal elements
If <i>X</i> is an expression, the evaluation of the expression aims to calculate only the diagonal elements
</li>
<br>
<li>
@@ -9068,7 +9068,7 @@ Extract the <i>k</i>-th diagonal from matrix <i>X</i>
</li>
<br>
<li>
If <i>X</i> is an expression, the evaluation of the expression aims to only calculate the diagonal elements
If <i>X</i> is an expression, the evaluation of the expression aims to calculate only the diagonal elements
</li>
<br>
<li>
@@ -9249,9 +9249,13 @@ See also:
</ul>
</li>
<br>
<li><b>Caveat:</b> if matrix <i>A</i> is symmetric, using <a href="#expmat_sym">expmat_sym()</a> is faster</li>
<br>
<li><b>Caveat:</b> the matrix exponential operation is generally <b>not</b> the same as applying the <a href="#misc_fns">exp()</a> function to each element</li>
<li>
<b>Caveats:</b>
<ul>
<li>the matrix exponential operation is generally <b>not</b> the same as applying the <a href="#misc_fns">exp()</a> function to each element</li>
<li>if matrix <i>A</i> is symmetric, using <a href="#expmat_sym">expmat_sym()</a> is faster</li>
</ul>
</li>
<br>
<li>
Examples:
@@ -10256,9 +10260,12 @@ See also:
</ul>
</li>
<br>
<li><b>Caveat:</b> if matrix <i>A</i> is symmetric positive definite, using <a href="#logmat_sympd">logmat_sympd()</a> is faster</li>
<br>
<li><b>Caveat:</b> the matrix logarithm operation is generally <b>not</b> the same as applying the <a href="#misc_fns">log()</a> function to each element</li>
<li><b>Caveats:</b>
<ul>
<li>the matrix logarithm operation is generally <b>not</b> the same as applying the <a href="#misc_fns">log()</a> function to each element</li>
<li>if matrix <i>A</i> is symmetric positive definite, using <a href="#logmat_sympd">logmat_sympd()</a> is faster</li>
</ul>
</li>
<br>
<li>
Examples:
@@ -11429,9 +11436,12 @@ See also:
If matrix <i>A</i> appears to be singular, an approximate square root is attempted; additionally, <i>sqrtmat(B,A)</i> returns a bool set to false
</li>
<br>
<li><b>Caveat:</b> if matrix <i>A</i> is symmetric positive definite, using <a href="#sqrtmat_sympd">sqrtmat_sympd()</a> is faster</li>
<br>
<li><b>Caveat:</b> the square root of a matrix is generally <b>not</b> the same as applying the <a href="#misc_fns">sqrt()</a> function to each element</li>
<li><b>Caveats:</b>
<ul>
<li>the square root of a matrix is generally <b>not</b> the same as applying the <a href="#misc_fns">sqrt()</a> function to each element</li>
<li>if matrix <i>A</i> is symmetric positive definite, using <a href="#sqrtmat_sympd">sqrtmat_sympd()</a> is faster</li>
</ul>
</li>
<br>
<li>
Examples:
@@ -11683,7 +11693,7 @@ Sum of the elements on the main diagonal of matrix <i>X</i>
</li>
<br>
<li>
If <i>X</i> is an expression, the evaluation of the expression aims to only calculate the diagonal elements
If <i>X</i> is an expression, the evaluation of the expression aims to calculate only the diagonal elements
</li>
<br>
<li>
@@ -12811,7 +12821,7 @@ Inverse of general square matrix <i>A</i>
<table>
<tbody>
<tr><td><code>inv_opts::no_ugly</code></td><td>&nbsp;&nbsp;&nbsp;</td><td>do not provide inverses for poorly conditioned matrices (where <i>rcond</i> &lt; <a href="#constants">datum::eps</a>)</td></tr>
<tr><td><code>inv_opts::allow_approx</code></td><td>&nbsp;&nbsp;&nbsp;</td><td>provide approximate inverses for rank deficient or poorly conditioned matrices; similar to pseudo-inverse</td></tr>
<tr><td><code>inv_opts::allow_approx</code></td><td>&nbsp;&nbsp;&nbsp;</td><td>allow approximate inverses for rank deficient or poorly conditioned matrices</td></tr>
<tr><td><code>inv_opts::tiny</code></td><td>&nbsp;&nbsp;&nbsp;</td><td>use fast inverse algorithm for tiny matrices (with size &leq; 4x4); may produce lower quality inverses</td></tr>
</tbody>
</table>
@@ -12908,7 +12918,7 @@ Inverse of symmetric/hermitian positive definite matrix <i>A</i>
<table>
<tbody>
<tr><td><code>inv_opts::no_ugly</code></td><td>&nbsp;&nbsp;&nbsp;</td><td>do not provide inverses for poorly conditioned matrices (where <i>rcond</i> &lt; <a href="#constants">datum::eps</a>)</td></tr>
<tr><td><code>inv_opts::allow_approx</code></td><td>&nbsp;&nbsp;&nbsp;</td><td>provide approximate inverses for rank deficient or poorly conditioned symmetric matrices; similar to pseudo-inverse</td></tr>
<tr><td><code>inv_opts::allow_approx</code></td><td>&nbsp;&nbsp;&nbsp;</td><td>allow approximate inverses for rank deficient or poorly conditioned symmetric matrices</td></tr>
<tr><td><code>inv_opts::tiny</code></td><td>&nbsp;&nbsp;&nbsp;</td><td>use fast inverse algorithm for tiny matrices (with size &leq; 4x4); may produce lower quality inverses</td></tr>
</tbody>
</table>
@@ -13213,9 +13223,18 @@ the divide-and-conquer method provides slightly different results than the stand
</li>
<br>
<li>
<b>Caveat:</b> to find approximate solutions (eg. minimum norm, least squares) to underdetermined, overdetermined, or rank deficient systems of linear equations,
<b>Caveats:</b>
<ul>
<li>
to find approximate solutions to under-/over-determined or rank deficient systems of linear equations,
using <a href="#solve">solve()</a> can be considerably faster and/or more accurate
</li>
<li>
if the given matrix <i>A</i> is square-sized and only occasionally rank deficient,
using <a href="#inv">inv()</a> or <a href="#inv_sympd">inv_sympd()</a> with the <code>inv_opts::allow_approx</code> option is faster
</li>
</ul>
</li>
<br>
<li>
Examples:
@@ -17613,95 +17632,35 @@ See also:
<div class="pagebreak"></div><div class="noprint"><hr class="greyline"><br></div>
<a name="output_streams"></a>
<a name="logging"></a>
<b>std::ostream&amp; x = get_cout_stream()</b>
<br><b>std::ostream&amp; x = get_cerr_stream()</b>
<br>
<br><b>set_cout_stream( user_stream )</b>
<br><b>set_cerr_stream( user_stream )</b>
<br>
<ul>
<li><b>get_cout_stream()</b>:
<ul>
<li>get a reference to the stream used for printing matrices and cubes with <a href="#print">.print()</a> and <a href="#raw_print">.raw_print()</a></li>
<li>by default this is <i>std::cout</i></li>
</ul>
<br>
<li><b>get_cerr_stream()</b>:
<ul>
<li>get a reference to the stream used for printing warnings and errors involving out of bounds accesses, failed decompositions, failed loading/saving, out of memory conditions, etc</li>
<li>by default this is <i>std::cerr</i></li>
</ul>
<br>
<li><b>set_cout_stream( custom_stream )</b>:
<ul>
<li>set the stream used for printing matrices and cubes</li>
<li>the stream can also be changed via the ARMA_COUT_STREAM define; see <a href="#config_hpp">config.hpp</a></li>
</ul>
</li>
<br>
<li><b>set_cerr_stream( custom_stream )</b>:
<ul>
<li>change the stream for printing warnings and errors
<li>the stream can also be changed via the ARMA_CERR_STREAM define; see <a href="#config_hpp">config.hpp</a></li>
</ul>
</li>
<br>
<!--
<li>
<b>Caveats:</b>
<b>output streams</b>
<ul>
<li>
in Armadillo 10.4 and later versions:
<ul>
<li>the default degree of emitted warnings about failed decompositions has been considerably reduced compared to earlier versions</li>
<li>the <i><a href="#config_hpp">ARMA_WARN_LEVEL</a></i> option allows fine-grained control over the degree of emitted warnings</li>
</ul>
</li>
<li>
in Armadillo 10.3 and earlier versions:
<ul>
<li>all failed decompositions print warnings</li>
<li>a blunt method to disable printing of all warnings and errors is via placing <i>#define <a href="#config_hpp">ARMA_DONT_PRINT_ERRORS</a></i> before <i>#include&nbsp;&lt;armadillo&gt;</i>
</ul>
</li>
<li>
detailed information about errors is always reported via the base <i>std::exception</i> class
</li>
</ul>
The default stream for printing matrices and cubes is <code>std::cout</code>
<br>the stream can be changed via the <code>ARMA_COUT_STREAM</code> define; see <a href="#config_hpp">config.hpp</a>
</li>
<br>
-->
<!--
<li>
Examples:
<ul>
The default stream for printing warnings and errors is <code>std::cerr</code>
<br>the stream can be changed via the <code>ARMA_CERR_STREAM</code> define; see <a href="#config_hpp">config.hpp</a>
</li>
<br>
<li>
The degree of printed warnings is controlled by the <code>ARMA_WARN_LEVEL</code> define; see <a href="#config_hpp">config.hpp</a>
</li>
<br>
<li>Example of changing the warning level:
<pre>
// print error messages to a log file
ofstream f("my_log.txt");
set_cerr_stream(f);
// trying to invert a singular matrix
// will print an error message and throw an exception
mat X(5, 5, fill::zeros);
mat Y = inv(X);
// disable printing of error messages
std::ostream nullstream(0);
set_cerr_stream(nullstream);
#define ARMA_WARN_LEVEL 1
#include &lt;armadillo&gt;
</pre>
</ul>
</li>
<br>
-->
<li>
See also:
<ul>
<li><a href="#config_hpp">config.hpp</a></li>
<li><a href="#print">.print()</a></li>
<li><a href="https://cplusplus.com/reference/iostream/cout/">std::cout</a></li>
<li><a href="https://cplusplus.com/reference/iostream/cerr/">std::cerr</a></li>
<li><a href="https://cplusplus.com/reference/ostream/ostream/">std::ostream</a></li>
<li><a href="https://cplusplus.com/reference/exception/exception/">std::exception</a></li>
<li><a href="https://cplusplus.com/doc/tutorial/exceptions/">tutorial on exceptions</a></li>
</ul>
</li>
<br>
+4
View File
@@ -19,6 +19,10 @@
#ifndef ARMA_INCLUDES
#define ARMA_INCLUDES
// NOTE: functions that are designed to be user accessible are described in the documentation (docs.html).
// NOTE: all other functions and classes (ie. not explicitly described in the documentation)
// NOTE: are considered as internal implementation details, and may be changed or removed without notice.
#include "armadillo_bits/config.hpp"
#include "armadillo_bits/compiler_check.hpp"
+6 -6
View File
@@ -402,13 +402,13 @@ class Cube : public BaseCube< eT, Cube<eT> >
inline arma_cold bool load(const hdf5_name& spec, const file_type type = hdf5_binary);
inline arma_cold bool load( std::istream& is, const file_type type = auto_detect);
inline arma_cold bool quiet_save(const std::string name, const file_type type = arma_binary) const;
inline arma_cold bool quiet_save(const hdf5_name& spec, const file_type type = hdf5_binary) const;
inline arma_cold bool quiet_save( std::ostream& os, const file_type type = arma_binary) const;
arma_deprecated inline bool quiet_save(const std::string name, const file_type type = arma_binary) const;
arma_deprecated inline bool quiet_save(const hdf5_name& spec, const file_type type = hdf5_binary) const;
arma_deprecated inline bool quiet_save( std::ostream& os, const file_type type = arma_binary) const;
inline arma_cold bool quiet_load(const std::string name, const file_type type = auto_detect);
inline arma_cold bool quiet_load(const hdf5_name& spec, const file_type type = hdf5_binary);
inline arma_cold bool quiet_load( std::istream& is, const file_type type = auto_detect);
arma_deprecated inline bool quiet_load(const std::string name, const file_type type = auto_detect);
arma_deprecated inline bool quiet_load(const hdf5_name& spec, const file_type type = hdf5_binary);
arma_deprecated inline bool quiet_load( std::istream& is, const file_type type = auto_detect);
// iterators
+6 -6
View File
@@ -4882,8 +4882,8 @@ Cube<eT>::load(std::istream& is, const file_type type)
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Cube<eT>::quiet_save(const std::string name, const file_type type) const
{
@@ -4895,8 +4895,8 @@ Cube<eT>::quiet_save(const std::string name, const file_type type) const
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Cube<eT>::quiet_save(const hdf5_name& spec, const file_type type) const
{
@@ -4908,8 +4908,8 @@ Cube<eT>::quiet_save(const hdf5_name& spec, const file_type type) const
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Cube<eT>::quiet_save(std::ostream& os, const file_type type) const
{
@@ -4921,8 +4921,8 @@ Cube<eT>::quiet_save(std::ostream& os, const file_type type) const
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Cube<eT>::quiet_load(const std::string name, const file_type type)
{
@@ -4934,8 +4934,8 @@ Cube<eT>::quiet_load(const std::string name, const file_type type)
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Cube<eT>::quiet_load(const hdf5_name& spec, const file_type type)
{
@@ -4947,8 +4947,8 @@ Cube<eT>::quiet_load(const hdf5_name& spec, const file_type type)
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Cube<eT>::quiet_load(std::istream& is, const file_type type)
{
+8 -8
View File
@@ -540,15 +540,15 @@ class Mat : public Base< eT, Mat<eT> >
inline arma_cold bool load(const csv_name& spec, const file_type type = csv_ascii);
inline arma_cold bool load( std::istream& is, const file_type type = auto_detect);
inline arma_cold bool quiet_save(const std::string name, const file_type type = arma_binary) const;
inline arma_cold bool quiet_save(const hdf5_name& spec, const file_type type = hdf5_binary) const;
inline arma_cold bool quiet_save(const csv_name& spec, const file_type type = csv_ascii) const;
inline arma_cold bool quiet_save( std::ostream& os, const file_type type = arma_binary) const;
arma_deprecated inline bool quiet_save(const std::string name, const file_type type = arma_binary) const;
arma_deprecated inline bool quiet_save(const hdf5_name& spec, const file_type type = hdf5_binary) const;
arma_deprecated inline bool quiet_save(const csv_name& spec, const file_type type = csv_ascii) const;
arma_deprecated inline bool quiet_save( std::ostream& os, const file_type type = arma_binary) const;
inline arma_cold bool quiet_load(const std::string name, const file_type type = auto_detect);
inline arma_cold bool quiet_load(const hdf5_name& spec, const file_type type = hdf5_binary);
inline arma_cold bool quiet_load(const csv_name& spec, const file_type type = csv_ascii);
inline arma_cold bool quiet_load( std::istream& is, const file_type type = auto_detect);
arma_deprecated inline bool quiet_load(const std::string name, const file_type type = auto_detect);
arma_deprecated inline bool quiet_load(const hdf5_name& spec, const file_type type = hdf5_binary);
arma_deprecated inline bool quiet_load(const csv_name& spec, const file_type type = csv_ascii);
arma_deprecated inline bool quiet_load( std::istream& is, const file_type type = auto_detect);
// for container-like functionality
+8 -12
View File
@@ -8068,10 +8068,9 @@ Mat<eT>::load(std::istream& is, const file_type type)
//! save the matrix to a file, without printing any error messages
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Mat<eT>::quiet_save(const std::string name, const file_type type) const
{
@@ -8083,8 +8082,8 @@ Mat<eT>::quiet_save(const std::string name, const file_type type) const
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Mat<eT>::quiet_save(const hdf5_name& spec, const file_type type) const
{
@@ -8096,8 +8095,8 @@ Mat<eT>::quiet_save(const hdf5_name& spec, const file_type type) const
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Mat<eT>::quiet_save(const csv_name& spec, const file_type type) const
{
@@ -8108,10 +8107,9 @@ Mat<eT>::quiet_save(const csv_name& spec, const file_type type) const
//! save the matrix to a stream, without printing any error messages
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Mat<eT>::quiet_save(std::ostream& os, const file_type type) const
{
@@ -8122,10 +8120,9 @@ Mat<eT>::quiet_save(std::ostream& os, const file_type type) const
//! load a matrix from a file, without printing any error messages
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Mat<eT>::quiet_load(const std::string name, const file_type type)
{
@@ -8137,8 +8134,8 @@ Mat<eT>::quiet_load(const std::string name, const file_type type)
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Mat<eT>::quiet_load(const hdf5_name& spec, const file_type type)
{
@@ -8150,8 +8147,8 @@ Mat<eT>::quiet_load(const hdf5_name& spec, const file_type type)
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Mat<eT>::quiet_load(const csv_name& spec, const file_type type)
{
@@ -8162,10 +8159,9 @@ Mat<eT>::quiet_load(const csv_name& spec, const file_type type)
//! load a matrix from a stream, without printing any error messages
template<typename eT>
arma_deprecated
inline
arma_cold
bool
Mat<eT>::quiet_load(std::istream& is, const file_type type)
{
+4 -6
View File
@@ -398,13 +398,11 @@ class SpMat : public SpBase< eT, SpMat<eT> >
inline arma_cold bool load(const csv_name& spec, const file_type type = csv_ascii);
inline arma_cold bool load( std::istream& is, const file_type type = arma_binary);
inline arma_cold bool quiet_save(const std::string name, const file_type type = arma_binary) const;
inline arma_cold bool quiet_save(const csv_name& spec, const file_type type = csv_ascii) const;
inline arma_cold bool quiet_save( std::ostream& os, const file_type type = arma_binary) const;
arma_deprecated inline bool quiet_save(const std::string name, const file_type type = arma_binary) const;
arma_deprecated inline bool quiet_save( std::ostream& os, const file_type type = arma_binary) const;
inline arma_cold bool quiet_load(const std::string name, const file_type type = arma_binary);
inline arma_cold bool quiet_load(const csv_name& spec, const file_type type = csv_ascii);
inline arma_cold bool quiet_load( std::istream& is, const file_type type = arma_binary);
arma_deprecated inline bool quiet_load(const std::string name, const file_type type = arma_binary);
arma_deprecated inline bool quiet_load( std::istream& is, const file_type type = arma_binary);
+4 -8
View File
@@ -4985,10 +4985,9 @@ SpMat<eT>::load(std::istream& is, const file_type type)
//! save the matrix to a file, without printing any error messages
template<typename eT>
arma_deprecated
inline
arma_cold
bool
SpMat<eT>::quiet_save(const std::string name, const file_type type) const
{
@@ -4999,10 +4998,9 @@ SpMat<eT>::quiet_save(const std::string name, const file_type type) const
//! save the matrix to a stream, without printing any error messages
template<typename eT>
arma_deprecated
inline
arma_cold
bool
SpMat<eT>::quiet_save(std::ostream& os, const file_type type) const
{
@@ -5013,10 +5011,9 @@ SpMat<eT>::quiet_save(std::ostream& os, const file_type type) const
//! load a matrix from a file, without printing any error messages
template<typename eT>
arma_deprecated
inline
arma_cold
bool
SpMat<eT>::quiet_load(const std::string name, const file_type type)
{
@@ -5027,10 +5024,9 @@ SpMat<eT>::quiet_load(const std::string name, const file_type type)
//! load a matrix from a stream, without printing any error messages
template<typename eT>
arma_deprecated
inline
arma_cold
bool
SpMat<eT>::quiet_load(std::istream& is, const file_type type)
{
+7
View File
@@ -174,6 +174,13 @@ struct arma_config
#endif
#if defined(ARMA_HAVE_CXX20)
static constexpr bool cxx20 = true;
#else
static constexpr bool cxx20 = false;
#endif
#if (!defined(ARMA_DONT_USE_STD_MUTEX))
static constexpr bool std_mutex = true;
#else
+1 -1
View File
@@ -23,7 +23,7 @@
#define ARMA_VERSION_MAJOR 11
#define ARMA_VERSION_MINOR 4
#define ARMA_VERSION_PATCH 2
#define ARMA_VERSION_PATCH 4
#define ARMA_VERSION_NAME "Ship of Theseus"
+5 -5
View File
@@ -42,11 +42,11 @@
#if defined(_MSVC_LANG)
#if (_MSVC_LANG >= 201402L)
#undef ARMA_HAVE_CXX11
#undef ARMA_HAVE_CXX14
#define ARMA_HAVE_CXX11
#define ARMA_HAVE_CXX14
#undef ARMA_HAVE_CXX11
#define ARMA_HAVE_CXX11
#undef ARMA_HAVE_CXX14
#define ARMA_HAVE_CXX14
#endif
#if (_MSVC_LANG >= 201703L)
+12 -13
View File
@@ -401,7 +401,7 @@
#pragma message ("WARNING: use of OpenMP disabled; compiler support for OpenMP 3.1+ not detected")
#if (defined(_OPENMP) && (_OPENMP < 201107))
#pragma message ("NOTE: your compiler appears to have an ancient version of OpenMP")
#pragma message ("NOTE: your compiler has an outdated version of OpenMP")
#pragma message ("NOTE: consider upgrading to a better compiler")
#endif
#endif
@@ -440,34 +440,33 @@
// undefine conflicting macros
#if defined(log2)
#undef log2
#pragma message ("WARNING: detected 'log2' macro and undefined it")
#pragma message ("WARNING: undefined conflicting 'log2' macro")
#endif
//
// whoever defined macros with the names "min" and "max" should be permanently removed from the gene pool
#if defined(check)
#undef check
#pragma message ("WARNING: undefined conflicting 'check' macro")
#endif
#if defined(min) || defined(max)
#undef min
#undef max
#pragma message ("WARNING: detected 'min' and/or 'max' macros and undefined them;")
#pragma message ("WARNING: you may wish to define NOMINMAX before including any windows header")
#pragma message ("WARNING: undefined conflicting 'min' and/or 'max' macros;")
#pragma message ("WARNING: suggest to define NOMINMAX before including any windows header")
#endif
//
// handle more stupid macros
// https://sourceware.org/bugzilla/show_bug.cgi?id=19239
#undef minor
#undef major
// optionally allow disabling of compile-time deprecation messages (not recommended)
// NOTE: option 'ARMA_IGNORE_DEPRECATED_MARKER' will be removed
// NOTE: disabling deprecation messages is counter-productive
#if defined(ARMA_IGNORE_DEPRECATED_MARKER) && (!defined(ARMA_DONT_IGNORE_DEPRECATED_MARKER)) && (!defined(ARMA_EXTRA_DEBUG))
#undef arma_deprecated
+5 -1
View File
@@ -135,6 +135,10 @@
//// and you will need to link with the hdf5 library (eg. -lhdf5)
#endif
#if defined(ARMA_USE_FFTW3)
#pragma message ("WARNING: use of FFTW3 is not supported in this version of Armadillo")
#endif
#if !defined(ARMA_OPTIMISE_BAND)
#define ARMA_OPTIMISE_BAND
//// Comment out the above line to disable optimised handling
@@ -322,7 +326,7 @@
#undef ARMA_OPTIMISE_BAND
#endif
#if defined(ARMA_DONT_OPTIMISE_SYMPD) || defined(ARMA_DONT_OPTIMISE_SOLVE_SYMPD)
#if defined(ARMA_DONT_OPTIMISE_SYM) || defined(ARMA_DONT_OPTIMISE_SYMPD) || defined(ARMA_DONT_OPTIMISE_SOLVE_SYMPD)
#undef ARMA_OPTIMISE_SYMPD
#endif
+5 -1
View File
@@ -135,6 +135,10 @@
//// and you will need to link with the hdf5 library (eg. -lhdf5)
#endif
#if defined(ARMA_USE_FFTW3)
#pragma message ("WARNING: use of FFTW3 is not supported in this version of Armadillo")
#endif
#if !defined(ARMA_OPTIMISE_BAND)
#define ARMA_OPTIMISE_BAND
//// Comment out the above line to disable optimised handling
@@ -322,7 +326,7 @@
#undef ARMA_OPTIMISE_BAND
#endif
#if defined(ARMA_DONT_OPTIMISE_SYMPD) || defined(ARMA_DONT_OPTIMISE_SOLVE_SYMPD)
#if defined(ARMA_DONT_OPTIMISE_SYM) || defined(ARMA_DONT_OPTIMISE_SYMPD) || defined(ARMA_DONT_OPTIMISE_SOLVE_SYMPD)
#undef ARMA_OPTIMISE_SYMPD
#endif
+38 -121
View File
@@ -30,137 +30,54 @@ 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
arma_deprecated static eT pi() { return eT(Datum<eT>::pi); } // use datum::pi instead
//! base of the natural logarithm
arma_deprecated static eT e() { return eT(Datum<eT>::e); } // use datum::e instead
//! Euler's constant, aka Euler-Mascheroni constant
arma_deprecated static eT euler() { return eT(Datum<eT>::euler); } // use datum::euler instead
//! golden ratio
arma_deprecated static eT gratio() { return eT(Datum<eT>::gratio); } // use datum::gratio instead
//! square root of 2
arma_deprecated static eT sqrt2() { return eT(Datum<eT>::sqrt2); } // use datum::sqrt2 instead
//! the difference between 1 and the least value greater than 1 that is representable
arma_deprecated static eT eps() { return eT(Datum<eT>::eps); } // use datum::eps instead
//! log of the minimum representable value
arma_deprecated static eT log_min() { return eT(Datum<eT>::log_min); } // use datum::log_min instead
//! log of the maximum representable value
arma_deprecated static eT log_max() { return eT(Datum<eT>::log_max); } // use datum::log_max instead
//! "not a number"
arma_deprecated static eT nan() { return eT(Datum<eT>::nan); } // use datum::nan instead
//! infinity
arma_deprecated static eT inf() { return eT(Datum<eT>::inf); } // use datum::inf instead
arma_deprecated static eT pi() { return eT(Datum<eT>::pi); }
arma_deprecated static eT e() { return eT(Datum<eT>::e); }
arma_deprecated static eT euler() { return eT(Datum<eT>::euler); }
arma_deprecated static eT gratio() { return eT(Datum<eT>::gratio); }
arma_deprecated static eT sqrt2() { return eT(Datum<eT>::sqrt2); }
arma_deprecated static eT eps() { return eT(Datum<eT>::eps); }
arma_deprecated static eT log_min() { return eT(Datum<eT>::log_min); }
arma_deprecated static eT log_max() { return eT(Datum<eT>::log_max); }
arma_deprecated static eT nan() { return eT(Datum<eT>::nan); }
arma_deprecated static eT inf() { return eT(Datum<eT>::inf); }
};
//! Physical constants taken from NIST 2010 CODATA values, and some from WolframAlpha (values provided as of 2009-06-23)
//! http://physics.nist.gov/cuu/Constants
//! http://www.wolframalpha.com
//! See also http://en.wikipedia.org/wiki/Physical_constant
template<typename eT>
class Phy
{
public:
//! atomic mass constant (in kg)
arma_deprecated static eT m_u() { return eT(Datum<eT>::m_u); }
//! Avogadro constant
arma_deprecated static eT N_A() { return eT(Datum<eT>::N_A); }
//! Boltzmann constant (in joules per kelvin)
arma_deprecated static eT k() { return eT(Datum<eT>::k); }
//! Boltzmann constant (in eV/K)
arma_deprecated static eT k_evk() { return eT(Datum<eT>::k_evk); }
//! Bohr radius (in meters)
arma_deprecated static eT a_0() { return eT(Datum<eT>::a_0); }
//! Bohr magneton
arma_deprecated static eT mu_B() { return eT(Datum<eT>::mu_B); }
//! characteristic impedance of vacuum (in ohms)
arma_deprecated static eT Z_0() { return eT(Datum<eT>::Z_0); }
//! conductance quantum (in siemens)
arma_deprecated static eT G_0() { return eT(Datum<eT>::G_0); }
//! Coulomb's constant (in meters per farad)
arma_deprecated static eT k_e() { return eT(Datum<eT>::k_e); }
//! electric constant (in farads per meter)
arma_deprecated static eT eps_0() { return eT(Datum<eT>::eps_0); }
//! electron mass (in kg)
arma_deprecated static eT m_e() { return eT(Datum<eT>::m_e); }
//! electron volt (in joules)
arma_deprecated static eT eV() { return eT(Datum<eT>::eV); }
//! elementary charge (in coulombs)
arma_deprecated static eT e() { return eT(Datum<eT>::ec); }
//! Faraday constant (in coulombs)
arma_deprecated static eT F() { return eT(Datum<eT>::F); }
//! fine-structure constant
arma_deprecated static eT alpha() { return eT(Datum<eT>::alpha); }
//! inverse fine-structure constant
arma_deprecated static eT m_u() { return eT(Datum<eT>::m_u); }
arma_deprecated static eT N_A() { return eT(Datum<eT>::N_A); }
arma_deprecated static eT k() { return eT(Datum<eT>::k); }
arma_deprecated static eT k_evk() { return eT(Datum<eT>::k_evk); }
arma_deprecated static eT a_0() { return eT(Datum<eT>::a_0); }
arma_deprecated static eT mu_B() { return eT(Datum<eT>::mu_B); }
arma_deprecated static eT Z_0() { return eT(Datum<eT>::Z_0); }
arma_deprecated static eT G_0() { return eT(Datum<eT>::G_0); }
arma_deprecated static eT k_e() { return eT(Datum<eT>::k_e); }
arma_deprecated static eT eps_0() { return eT(Datum<eT>::eps_0); }
arma_deprecated static eT m_e() { return eT(Datum<eT>::m_e); }
arma_deprecated static eT eV() { return eT(Datum<eT>::eV); }
arma_deprecated static eT e() { return eT(Datum<eT>::ec); }
arma_deprecated static eT F() { return eT(Datum<eT>::F); }
arma_deprecated static eT alpha() { return eT(Datum<eT>::alpha); }
arma_deprecated static eT alpha_inv() { return eT(Datum<eT>::alpha_inv); }
//! Josephson constant
arma_deprecated static eT K_J() { return eT(Datum<eT>::K_J); }
//! magnetic constant (in henries per meter)
arma_deprecated static eT mu_0() { return eT(Datum<eT>::mu_0); }
//! magnetic flux quantum (in webers)
arma_deprecated static eT phi_0() { return eT(Datum<eT>::phi_0); }
//! molar gas constant (in joules per mole kelvin)
arma_deprecated static eT R() { return eT(Datum<eT>::R); }
//! Newtonian constant of gravitation (in newton square meters per kilogram squared)
arma_deprecated static eT G() { return eT(Datum<eT>::G); }
//! Planck constant (in joule seconds)
arma_deprecated static eT h() { return eT(Datum<eT>::h); }
//! Planck constant over 2 pi, aka reduced Planck constant (in joule seconds)
arma_deprecated static eT h_bar() { return eT(Datum<eT>::h_bar); }
//! proton mass (in kg)
arma_deprecated static eT m_p() { return eT(Datum<eT>::m_p); }
//! Rydberg constant (in reciprocal meters)
arma_deprecated static eT R_inf() { return eT(Datum<eT>::R_inf); }
//! speed of light in vacuum (in meters per second)
arma_deprecated static eT c_0() { return eT(Datum<eT>::c_0); }
//! Stefan-Boltzmann constant
arma_deprecated static eT sigma() { return eT(Datum<eT>::sigma); }
//! von Klitzing constant (in ohms)
arma_deprecated static eT R_k() { return eT(Datum<eT>::R_k); }
//! Wien wavelength displacement law constant
arma_deprecated static eT b() { return eT(Datum<eT>::b); }
arma_deprecated static eT K_J() { return eT(Datum<eT>::K_J); }
arma_deprecated static eT mu_0() { return eT(Datum<eT>::mu_0); }
arma_deprecated static eT phi_0() { return eT(Datum<eT>::phi_0); }
arma_deprecated static eT R() { return eT(Datum<eT>::R); }
arma_deprecated static eT G() { return eT(Datum<eT>::G); }
arma_deprecated static eT h() { return eT(Datum<eT>::h); }
arma_deprecated static eT h_bar() { return eT(Datum<eT>::h_bar); }
arma_deprecated static eT m_p() { return eT(Datum<eT>::m_p); }
arma_deprecated static eT R_inf() { return eT(Datum<eT>::R_inf); }
arma_deprecated static eT c_0() { return eT(Datum<eT>::c_0); }
arma_deprecated static eT sigma() { return eT(Datum<eT>::sigma); }
arma_deprecated static eT R_k() { return eT(Datum<eT>::R_k); }
arma_deprecated static eT b() { return eT(Datum<eT>::b); }
};
+41 -14
View File
@@ -21,10 +21,11 @@
//! internal use only; subject to removal
template<typename T>
inline
std::ostream&
arma_cout_stream(std::ostream* user_stream)
internal_cout_stream(std::ostream* user_stream)
{
static std::ostream* cout_stream = &(ARMA_COUT_STREAM);
@@ -35,10 +36,11 @@ arma_cout_stream(std::ostream* user_stream)
//! internal use only; subject to removal
template<typename T>
inline
std::ostream&
arma_cerr_stream(std::ostream* user_stream)
internal_cerr_stream(std::ostream* user_stream)
{
static std::ostream* cerr_stream = &(ARMA_CERR_STREAM);
@@ -49,20 +51,44 @@ arma_cerr_stream(std::ostream* user_stream)
template<typename T>
arma_deprecated
inline
void
set_cout_stream(std::ostream& user_stream)
std::ostream&
arma_cout_stream(std::ostream* user_stream)
{
arma_cout_stream<char>(&user_stream);
return internal_cout_stream<T>(user_stream);
}
template<typename T>
arma_deprecated
inline
std::ostream&
arma_cerr_stream(std::ostream* user_stream)
{
return internal_cerr_stream<T>(user_stream);
}
arma_deprecated
inline
void
set_cout_stream(std::ostream& user_stream)
{
internal_cout_stream<char>(&user_stream);
}
arma_deprecated
inline
void
set_cerr_stream(std::ostream& user_stream)
{
arma_cerr_stream<char>(&user_stream);
internal_cerr_stream<char>(&user_stream);
}
@@ -71,7 +97,7 @@ inline
std::ostream&
get_cout_stream()
{
return arma_cout_stream<char>(nullptr);
return internal_cout_stream<char>(nullptr);
}
@@ -80,36 +106,36 @@ inline
std::ostream&
get_cerr_stream()
{
return arma_cerr_stream<char>(nullptr);
return internal_cerr_stream<char>(nullptr);
}
//! do not use this function - it's deprecated and will be removed
inline
arma_deprecated
inline
void
set_stream_err1(std::ostream& user_stream)
{
set_cerr_stream(user_stream);
internal_cerr_stream<char>(&user_stream);
}
//! do not use this function - it's deprecated and will be removed
inline
arma_deprecated
inline
void
set_stream_err2(std::ostream& user_stream)
{
set_cerr_stream(user_stream);
internal_cerr_stream<char>(&user_stream);
}
//! do not use this function - it's deprecated and will be removed
inline
arma_deprecated
inline
std::ostream&
get_stream_err1()
{
@@ -119,8 +145,8 @@ get_stream_err1()
//! do not use this function - it's deprecated and will be removed
inline
arma_deprecated
inline
std::ostream&
get_stream_err2()
{
@@ -1435,6 +1461,7 @@ arma_assert_atlas_size(const T1& A, const T2& B)
out << "@ arma_config::wrapper = " << arma_config::wrapper << '\n';
out << "@ arma_config::cxx14 = " << arma_config::cxx14 << '\n';
out << "@ arma_config::cxx17 = " << arma_config::cxx17 << '\n';
out << "@ arma_config::cxx20 = " << arma_config::cxx20 << '\n';
out << "@ arma_config::std_mutex = " << arma_config::std_mutex << '\n';
out << "@ arma_config::posix = " << arma_config::posix << '\n';
out << "@ arma_config::openmp = " << arma_config::openmp << '\n';
+4 -4
View File
@@ -217,11 +217,11 @@ class field
inline arma_cold bool load( std::istream& is, const file_type type = auto_detect);
inline arma_cold bool quiet_save(const std::string name, const file_type type = arma_binary) const;
inline arma_cold bool quiet_save( std::ostream& os, const file_type type = arma_binary) const;
arma_deprecated inline bool quiet_save(const std::string name, const file_type type = arma_binary) const;
arma_deprecated inline bool quiet_save( std::ostream& os, const file_type type = arma_binary) const;
inline arma_cold bool quiet_load(const std::string name, const file_type type = auto_detect);
inline arma_cold bool quiet_load( std::istream& is, const file_type type = auto_detect);
arma_deprecated inline bool quiet_load(const std::string name, const file_type type = auto_detect);
arma_deprecated inline bool quiet_load( std::istream& is, const file_type type = auto_detect);
// for container-like functionality
+4 -4
View File
@@ -1936,8 +1936,8 @@ field<oT>::load(std::istream& is, const file_type type)
template<typename oT>
arma_deprecated
inline
arma_cold
bool
field<oT>::quiet_save(const std::string name, const file_type type) const
{
@@ -1949,8 +1949,8 @@ field<oT>::quiet_save(const std::string name, const file_type type) const
template<typename oT>
arma_deprecated
inline
arma_cold
bool
field<oT>::quiet_save(std::ostream& os, const file_type type) const
{
@@ -1962,8 +1962,8 @@ field<oT>::quiet_save(std::ostream& os, const file_type type) const
template<typename oT>
arma_deprecated
inline
arma_cold
bool
field<oT>::quiet_load(const std::string name, const file_type type)
{
@@ -1975,8 +1975,8 @@ field<oT>::quiet_load(const std::string name, const file_type type)
template<typename oT>
arma_deprecated
inline
arma_cold
bool
field<oT>::quiet_load(std::istream& is, const file_type type)
{
+14 -2
View File
@@ -53,6 +53,11 @@ interp1_helper_nearest(const Mat<eT>& XG, const Mat<eT>& YG, const Mat<eT>& XI,
{
YI_mem[i] = extrap_val;
}
else
if(arma_isnan(XI_val))
{
YI_mem[i] = Datum<eT>::nan;
}
else
{
// XG and XI are guaranteed to be sorted in ascending manner,
@@ -113,6 +118,11 @@ interp1_helper_linear(const Mat<eT>& XG, const Mat<eT>& YG, const Mat<eT>& XI, M
{
YI_mem[i] = extrap_val;
}
else
if(arma_isnan(XI_val))
{
YI_mem[i] = Datum<eT>::nan;
}
else
{
// XG and XI are guaranteed to be sorted in ascending manner,
@@ -223,11 +233,11 @@ interp1_helper(const Mat<eT>& X, const Mat<eT>& Y, const Mat<eT>& XI, Mat<eT>& Y
Mat<eT> XI_tmp;
uvec XI_indices;
const bool XI_is_sorted = XI.is_sorted();
const bool XI_is_sorted = XI.is_sorted(); // NOTE: .is_sorted() currently doesn't detect NaN
if(XI_is_sorted == false)
{
XI_indices = sort_index(XI);
XI_indices = sort_index(XI); // NOTE: sort_index() will throw if XI has NaN
const uword N = XI.n_elem;
@@ -246,6 +256,8 @@ interp1_helper(const Mat<eT>& X, const Mat<eT>& Y, const Mat<eT>& XI, Mat<eT>& Y
const Mat<eT>& XI_sorted = (XI_is_sorted) ? XI : XI_tmp;
// NOTE: XI_sorted may have NaN
if(sig == 10) { interp1_helper_nearest(X_sanitised, Y_sanitised, XI_sorted, YI, extrap_val); }
else if(sig == 20) { interp1_helper_linear (X_sanitised, Y_sanitised, XI_sorted, YI, extrap_val); }
+4 -25
View File
@@ -111,39 +111,18 @@ op_pinv::apply_direct(Mat<typename T1::elem_type>& out, const Base<typename T1::
return op_pinv::apply_diag(out, A, tol);
}
bool do_sym = false;
bool do_sympd = false;
bool do_sym = false;
const bool is_sym_size_ok = (A.n_rows > (is_cx<eT>::yes ? uword(20) : uword(40)));
const bool is_arg_default = ((tol == T(0)) && (method_id == uword(0)));
const bool is_sym_size_ok = (A.n_rows == A.n_cols) && (A.n_rows > (is_cx<eT>::yes ? uword(20) : uword(40)));
if( (arma_config::optimise_sympd) && (auxlib::crippled_lapack(A) == false) && (is_arg_default || is_sym_size_ok) )
if( (is_sym_size_ok) && (arma_config::optimise_sympd) && (auxlib::crippled_lapack(A) == false) )
{
bool is_approx_sym = false;
bool is_approx_sympd = false;
sympd_helper::analyse_matrix(is_approx_sym, is_approx_sympd, A);
do_sym = is_sym_size_ok && ((is_cx<eT>::no) ? (is_approx_sym) : (is_approx_sym && is_approx_sympd));
do_sympd = is_arg_default && is_approx_sympd;
}
if(do_sympd)
{
arma_extra_debug_print("op_pinv: attempting sympd optimisation");
out = A;
bool is_sympd_junk = false;
T rcond_calc = T(0);
const T rcond_threshold = T((std::max)(uword(100), uword(A.n_rows))) * std::numeric_limits<T>::epsilon();
const bool status = auxlib::inv_sympd_rcond(out, is_sympd_junk, rcond_calc, rcond_threshold);
if(status && arma_isfinite(rcond_calc)) { return true; }
arma_extra_debug_print("op_pinv: sympd optimisation failed");
// auxlib::inv_sympd_rcond() will fail if A isn't really positive definite or its rcond is below rcond_threshold
do_sym = ((is_cx<eT>::no) ? (is_approx_sym) : (is_approx_sym && is_approx_sympd));
}
if(do_sym)
+2 -2
View File
@@ -57,8 +57,8 @@
<ul>
<li>Article on integration of Armadillo with R:
<ul>
<li><a href="http://arma.sourceforge.net/rcpp_armadillo_csda_2014.pdf">rcpp_armadillo_csda_2014.pdf</a> (online copy)</li>
<li><a href="rcpp_armadillo_csda_2014.pdf">rcpp_armadillo_csda_2014.pdf</a> (local copy)</li>
<li><a href="http://arma.sourceforge.net/armadillo_rcpp_2014.pdf">armadillo_rcpp_2014.pdf</a> (online copy)</li>
<li><a href="armadillo_rcpp_2014.pdf">armadillo_rcpp_2014.pdf</a> (local copy)</li>
</ul>
</li>
</ul>
+33 -249
View File
@@ -15,12 +15,12 @@
// Connector for Mex files to use Armadillo for calculation
// Version 0.5
// Version 0.6
#include <armadillo>
#include <mex.h>
#include <mat.h>
#include <mxarray.h>
#include <cstring>
using namespace std;
@@ -31,7 +31,7 @@ using namespace arma;
template<class Type>
inline
Type
armaGetScalar(const mxArray *matlabScalar)
armaGetScalar(const mxArray* matlabScalar)
{
if(mxGetData(matlabScalar) != NULL)
{
@@ -48,7 +48,7 @@ armaGetScalar(const mxArray *matlabScalar)
// To keep with Matlab/Octave mex functions since functions for double are usually defined in conjunction with the general functions.
inline
double
armaGetDouble(const mxArray *matlabScalar)
armaGetDouble(const mxArray* matlabScalar)
{
return armaGetScalar<double>(matlabScalar);
}
@@ -59,7 +59,7 @@ armaGetDouble(const mxArray *matlabScalar)
template<class Type>
inline
Mat<Type>
armaGetData(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict = true)
armaGetData(const mxArray* matlabMatrix, bool copy_aux_mem = false, bool strict = true)
{
if(mxGetData(matlabMatrix) != NULL)
{
@@ -86,7 +86,7 @@ armaGetData(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict
// Get double real matrix from Matlab/Octave.
inline
Mat<double>
armaGetPr(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict = true)
armaGetPr(const mxArray* matlabMatrix, bool copy_aux_mem = false, bool strict = true)
{
if(mxGetData(matlabMatrix) != NULL)
{
@@ -115,7 +115,7 @@ armaGetPr(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict =
template<class Type>
inline
Mat<Type>
armaGetImagData(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict = true)
armaGetImagData(const mxArray* matlabMatrix, bool copy_aux_mem = false, bool strict = true)
{
if(mxGetImagData(matlabMatrix) != NULL)
{
@@ -142,7 +142,7 @@ armaGetImagData(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool str
// Get double imaginary matrix from Matlab/Octave.
inline
Mat<double>
armaGetPi(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict = true)
armaGetPi(const mxArray* matlabMatrix, bool copy_aux_mem = false, bool strict = true)
{
if(mxGetImagData(matlabMatrix) != NULL)
{
@@ -169,7 +169,7 @@ armaGetPi(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict =
// Get complex matrix from Matlab/Octave
inline
cx_mat
armaGetCx(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict = true)
armaGetCx(const mxArray* matlabMatrix, bool copy_aux_mem = false, bool strict = true)
{
if( (mxGetPr(matlabMatrix) != NULL) && (mxGetPi(matlabMatrix) != NULL) )
{
@@ -195,7 +195,7 @@ armaGetCx(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict =
template<class Type>
inline
void
armaSetData(mxArray *matlabMatrix, const Mat<Type>& armaMatrix)
armaSetData(mxArray* matlabMatrix, const Mat<Type>& armaMatrix)
{
Type *dst_pointer = (Type*)mxGetData(matlabMatrix);
const Type *src_pointer = (Type*)armaMatrix.memptr();
@@ -207,7 +207,7 @@ armaSetData(mxArray *matlabMatrix, const Mat<Type>& armaMatrix)
// Return double real valued matrix to Matlab/Octave
inline
void
armaSetPr(mxArray *matlabMatrix, const Mat<double>& armaMatrix)
armaSetPr(mxArray* matlabMatrix, const Mat<double>& armaMatrix)
{
double *dst_pointer = mxGetPr(matlabMatrix);
const double *src_pointer = armaMatrix.memptr();
@@ -220,7 +220,7 @@ armaSetPr(mxArray *matlabMatrix, const Mat<double>& armaMatrix)
template<class Type>
inline
void
armaSetImagData(mxArray *matlabMatrix, const Mat<Type>& armaMatrix)
armaSetImagData(mxArray* matlabMatrix, const Mat<Type>& armaMatrix)
{
Type *dst_pointer = (Type*)mxGetImagData(matlabMatrix);
const Type *src_pointer = (Type*)armaMatrix.memptr();
@@ -232,7 +232,7 @@ armaSetImagData(mxArray *matlabMatrix, const Mat<Type>& armaMatrix)
// Return double complex valued matrix to Matlab/Octave
inline
void
armaSetPi(mxArray *matlabMatrix, const Mat<double>& armaMatrix)
armaSetPi(mxArray* matlabMatrix, const Mat<double>& armaMatrix)
{
double *dst_pointer = mxGetPi(matlabMatrix);
const double *src_pointer = armaMatrix.memptr();
@@ -244,7 +244,7 @@ armaSetPi(mxArray *matlabMatrix, const Mat<double>& armaMatrix)
// Return complex matrix to Matlab/Octave. Requires Matlab/Octave matrix to be mxCOMPLEX
inline
void
armaSetCx(mxArray *matlabMatrix, const cx_mat& armaMatrix)
armaSetCx(mxArray* matlabMatrix, const cx_mat& armaMatrix)
{
armaSetPr(matlabMatrix, real(armaMatrix));
armaSetPi(matlabMatrix, imag(armaMatrix));
@@ -258,7 +258,7 @@ armaSetCx(mxArray *matlabMatrix, const cx_mat& armaMatrix)
template<class Type>
inline
Cube<Type>
armaGetCubeData(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict = true)
armaGetCubeData(const mxArray* matlabMatrix, bool copy_aux_mem = false, bool strict = true)
{
if(mxGetData(matlabMatrix) != NULL)
{
@@ -286,7 +286,7 @@ armaGetCubeData(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool str
// Get double cube from Matlab/Octave.
inline
Cube<double>
armaGetCubePr(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict = true)
armaGetCubePr(const mxArray* matlabMatrix, bool copy_aux_mem = false, bool strict = true)
{
if(mxGetData(matlabMatrix) != NULL)
{
@@ -316,7 +316,7 @@ armaGetCubePr(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool stric
template<class Type>
inline
Cube<Type>
armaGetCubeImagData(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict = true)
armaGetCubeImagData(const mxArray* matlabMatrix, bool copy_aux_mem = false, bool strict = true)
{
if(mxGetImagData(matlabMatrix) != NULL)
{
@@ -344,7 +344,7 @@ armaGetCubeImagData(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool
// Get double cube from Matlab/Octave.
inline
Cube<double>
armaGetCubePi(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict = true)
armaGetCubePi(const mxArray* matlabMatrix, bool copy_aux_mem = false, bool strict = true)
{
if(mxGetImagData(matlabMatrix) != NULL)
{
@@ -372,7 +372,7 @@ armaGetCubePi(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool stric
// Get complex cube from Matlab/Octave
inline
cx_cube
armaGetCubeCx(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool strict = true)
armaGetCubeCx(const mxArray* matlabMatrix, bool copy_aux_mem = false, bool strict = true)
{
if( (mxGetPr(matlabMatrix) != NULL) && (mxGetPi(matlabMatrix) != NULL) )
{
@@ -399,7 +399,7 @@ armaGetCubeCx(const mxArray *matlabMatrix, bool copy_aux_mem = false, bool stric
template<class Type>
inline
void
armaSetCubeData(mxArray *matlabMatrix, const Cube<Type>& armaCube)
armaSetCubeData(mxArray* matlabMatrix, const Cube<Type>& armaCube)
{
Type *dst_pointer = (Type*)mxGetData(matlabMatrix);
const Type *src_pointer = (Type*)armaCube.memptr();
@@ -411,7 +411,7 @@ armaSetCubeData(mxArray *matlabMatrix, const Cube<Type>& armaCube)
// Return double real valued cube to Matlab/Octave
inline
void
armaSetCubePr(mxArray *matlabMatrix, const Cube<double>& armaCube)
armaSetCubePr(mxArray* matlabMatrix, const Cube<double>& armaCube)
{
double *dst_pointer = mxGetPr(matlabMatrix);
const double *src_pointer = armaCube.memptr();
@@ -424,7 +424,7 @@ armaSetCubePr(mxArray *matlabMatrix, const Cube<double>& armaCube)
template<class Type>
inline
void
armaSetImagCubeData(mxArray *matlabMatrix, const Cube<Type>& armaCube)
armaSetImagCubeData(mxArray* matlabMatrix, const Cube<Type>& armaCube)
{
Type *dst_pointer = (Type*)mxGetImagData(matlabMatrix);
const Type *src_pointer = (Type*)armaCube.memptr();
@@ -436,7 +436,7 @@ armaSetImagCubeData(mxArray *matlabMatrix, const Cube<Type>& armaCube)
// Return double imaginary valued matrix to Matlab/Octave
inline
void
armaSetCubePi(mxArray *matlabMatrix, const Cube<double>& armaCube)
armaSetCubePi(mxArray* matlabMatrix, const Cube<double>& armaCube)
{
double *dst_pointer = mxGetPi(matlabMatrix);
const double *src_pointer = armaCube.memptr();
@@ -448,7 +448,7 @@ armaSetCubePi(mxArray *matlabMatrix, const Cube<double>& armaCube)
// Return double complex cube to Matlab/Octave.
inline
void
armaSetCubeCx(mxArray *matlabMatrix, const cx_cube& armaCube)
armaSetCubeCx(mxArray* matlabMatrix, const cx_cube& armaCube)
{
armaSetCubePr(matlabMatrix, real(armaCube));
armaSetCubePi(matlabMatrix, imag(armaCube));
@@ -462,7 +462,7 @@ armaSetCubeCx(mxArray *matlabMatrix, const cx_cube& armaCube)
template<class Type>
inline
SpMat<Type>
armaGetSparseData(const mxArray *matlabMatrix, bool sort_locations = false)
armaGetSparseData(const mxArray* matlabMatrix, bool sort_locations = false)
{
if(!mxIsSparse(matlabMatrix))
{
@@ -522,7 +522,7 @@ armaGetSparseData(const mxArray *matlabMatrix, bool sort_locations = false)
// Get double valued sparse matrix from Matlab/Octave.
inline
SpMat<double>
armaGetSparseMatrix(const mxArray *matlabMatrix, bool sort_locations = false)
armaGetSparseMatrix(const mxArray* matlabMatrix, bool sort_locations = false)
{
if(!mxIsSparse(matlabMatrix))
{
@@ -584,7 +584,7 @@ armaGetSparseMatrix(const mxArray *matlabMatrix, bool sort_locations = false)
template<class Type>
inline
SpMat<Type>
armaGetSparseImagData(const mxArray *matlabMatrix, bool sort_locations = false)
armaGetSparseImagData(const mxArray* matlabMatrix, bool sort_locations = false)
{
if(!mxIsSparse(matlabMatrix))
{
@@ -643,7 +643,7 @@ armaGetSparseImagData(const mxArray *matlabMatrix, bool sort_locations = false)
// Get imaginary double valued sparse matrix from Matlab/Octave.
inline
SpMat<double>
armaGetSparseImagMatrix(const mxArray *matlabMatrix, bool sort_locations = false)
armaGetSparseImagMatrix(const mxArray* matlabMatrix, bool sort_locations = false)
{
if(!mxIsSparse(matlabMatrix))
{
@@ -703,7 +703,7 @@ armaGetSparseImagMatrix(const mxArray *matlabMatrix, bool sort_locations = false
// Return sparse matrix to matlab
inline
void
armaSetSparsePr(mxArray *matlabMatrix, const SpMat<double>& armaMatrix)
armaSetSparsePr(mxArray* matlabMatrix, const SpMat<double>& armaMatrix)
{
double *sr = mxGetPr(matlabMatrix);
mwIndex *irs = mxGetIr(matlabMatrix);
@@ -729,7 +729,7 @@ armaSetSparsePr(mxArray *matlabMatrix, const SpMat<double>& armaMatrix)
// Return sparse matrix to matlab as imaginary part
inline
void
armaSetSparsePi(mxArray *matlabMatrix, const SpMat<double>& armaMatrix)
armaSetSparsePi(mxArray* matlabMatrix, const SpMat<double>& armaMatrix)
{
double *si = mxGetPi(matlabMatrix);
mwIndex *irs = mxGetIr(matlabMatrix);
@@ -760,7 +760,7 @@ inline
mxArray*
armaCreateMxMatrix(const mwSize n_rows, const mwSize n_cols, const mxClassID mx_type = mxDOUBLE_CLASS, const mxComplexity mx_complexity = mxREAL)
{
mxArray *temp = mxCreateNumericMatrix(n_rows, n_cols, mx_type, mx_complexity);
mxArray* temp = mxCreateNumericMatrix(n_rows, n_cols, mx_type, mx_complexity);
if(temp == NULL)
{
@@ -783,7 +783,7 @@ armaCreateMxMatrix(const mwSize n_rows, const mwSize n_cols, const mwSize n_slic
const mwSize n_dim = 3;
mxArray *temp = mxCreateNumericArray(n_dim, dims, mx_type, mx_complexity);
mxArray* temp = mxCreateNumericArray(n_dim, dims, mx_type, mx_complexity);
if(temp == NULL)
{
@@ -801,7 +801,7 @@ inline
mxArray*
armaCreateMxSparseMatrix(const mwSize n_rows,const mwSize n_cols,const mwSize n_nonzero,const mxComplexity mx_complexity = mxREAL)
{
mxArray *temp = mxCreateSparse(n_rows, n_cols, n_nonzero, mx_complexity);
mxArray* temp = mxCreateSparse(n_rows, n_cols, n_nonzero, mx_complexity);
if(temp == NULL)
{
@@ -815,219 +815,3 @@ armaCreateMxSparseMatrix(const mwSize n_rows,const mwSize n_cols,const mwSize n_
}
//Functions to write MAT files
inline
int
armaWriteMatToFile(const char *filename, mat &armaMatrix, const char *name)
{
MATFile *file;
file = matOpen(filename,"wz");
int result;
if(file == NULL)
{
mexErrMsgTxt("Could not create MAT file.");
return 0;
}
else
{
mxArray *temp = mxCreateDoubleMatrix(armaMatrix.n_rows, armaMatrix.n_cols, mxREAL);
armaSetPr(temp, armaMatrix);
result = matPutVariable(file, name, temp);
mxDestroyArray(temp); //Cleanup after writing MAT file
}
matClose(file);
return result;
}
inline
int
armaWriteCxMatToFile(const char *filename, cx_mat &armaMatrix, const char *name)
{
MATFile *file;
file = matOpen(filename,"wz");
int result;
if(file == NULL)
{
mexErrMsgTxt("Could not create MAT file.");
return 0;
}
else
{
mxArray *temp = mxCreateDoubleMatrix(armaMatrix.n_rows, armaMatrix.n_cols, mxCOMPLEX);
armaSetCx(temp, armaMatrix);
result = matPutVariable(file, name, temp);
mxDestroyArray(temp); //Cleanup after writing MAT file
}
matClose(file);
return result;
}
inline
int
armaWriteCubeToFile(const char *filename, cube &armaCube, const char *name)
{
MATFile *file;
file = matOpen(filename,"wz");
int result;
if(file == NULL)
{
mexErrMsgTxt("Could not create MAT file.");
return 0;
}
else
{
mxArray *temp = armaCreateMxMatrix(armaCube.n_rows, armaCube.n_cols, armaCube.n_slices, mxDOUBLE_CLASS, mxREAL);
armaSetCubePr(temp, armaCube);
result = matPutVariable(file, name, temp);
mxDestroyArray(temp); //Cleanup after writing MAT file
}
matClose(file);
return result;
}
inline
int
armaWriteCxCubeToFile(const char *filename, cx_cube &armaCube, const char *name)
{
MATFile *file;
file = matOpen(filename,"wz");
int result;
if(file == NULL)
{
mexErrMsgTxt("Could not create MAT file.");
return 0;
}
else
{
mxArray *temp = armaCreateMxMatrix(armaCube.n_rows, armaCube.n_cols, armaCube.n_slices, mxDOUBLE_CLASS, mxCOMPLEX);
armaSetCubeCx(temp, armaCube);
result = matPutVariable(file, name, temp);
mxDestroyArray(temp); //Cleanup after writing MAT file
}
matClose(file);
return result;
}
//Functions to read and write matrices and cubes in MAT file format
inline
mat
armaReadMatFromFile(const char *filename)
{
MATFile *file;
file = matOpen(filename,"r");
char buffer[1024];
const char *name;
name = buffer;
if(file == NULL)
{
mexErrMsgTxt("Could not open MAT file.");
return mat();
}
else
{
mat tmp = armaGetPr(matGetNextVariable(file,&name));
matClose(file);
return tmp;
}
}
inline
cx_mat
armaReadCxMatFromFile(const char *filename)
{
MATFile *file;
file = matOpen(filename,"r");
char buffer[1024];
const char *name;
name = buffer;
if(file == NULL)
{
mexErrMsgTxt("Could not open MAT file.");
return cx_mat();
}
else
{
cx_mat tmp = armaGetCx(matGetNextVariable(file, &name));
matClose(file);
return tmp;
}
}
inline
cube
armaReadCubeFromFile(const char *filename)
{
MATFile *file;
file = matOpen(filename,"r");
char buffer[1024];
const char *name;
name = buffer;
if(file == NULL)
{
mexErrMsgTxt("Could not open MAT file.");
return cube();
}
else
{
cube tmp = armaGetCubePr(matGetNextVariable(file,&name));
matClose(file);
return tmp;
}
}
inline
cx_cube
armaReadCxCubeFromFile(const char *filename)
{
MATFile *file;
file = matOpen(filename,"r");
char buffer[1024];
const char *name;
name = buffer;
if(file == NULL)
{
mexErrMsgTxt("Could not open MAT file.");
return cx_cube();
}
else
{
cx_cube tmp = armaGetCubeCx(matGetNextVariable(file,&name));
matClose(file);
return tmp;
}
}
Binary file not shown.
-37
View File
@@ -1,37 +0,0 @@
// Copyright 2014 Conrad Sanderson (http://conradsanderson.id.au)
// Copyright 2014 National ICT Australia (NICTA)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------
// Demonstration of how to connect Armadillo with Matlab mex functions.
// Version 0.5
#include "armaMex.hpp"
void
mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
// Read the matrix from the file inData.mat
mat fromFile = armaReadMatFromFile("inData.mat");
fromFile.print();
mat tmp(4,6);
tmp.randu();
// Write the matrix tmp as outData in the file outData.mat
armaWriteMatToFile("outData.mat", tmp, "outData");
}
+1 -1
View File
@@ -97,5 +97,5 @@ rm -rf examples/lib_win64
%doc armadillo_nicta_2010.pdf
%doc armadillo_solver_2020.pdf
%doc armadillo_spcs_2017.pdf
%doc rcpp_armadillo_csda_2014.pdf
%doc armadillo_rcpp_2014.pdf
%doc mex_interface
+5 -5
View File
@@ -3,11 +3,11 @@ LIB_FLAGS = -larmadillo
#LIB_FLAGS = -lblas -llapack
#LIB_FLAGS = -lopenblas -llapack
CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -O0
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -O0 -fopenmp
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -O0 -DARMA_DONT_USE_WRAPPER
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -O0 -fsanitize=address -fsanitize=leak -fsanitize=undefined -fsanitize=bounds -fsanitize=bounds-strict -g
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -O2
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -O0
CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -Og
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -Og -fopenmp
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -Og -DARMA_DONT_USE_WRAPPER
#CXX_FLAGS = -std=c++11 -Wshadow -Wall -pedantic -Og -fsanitize=address -fsanitize=leak -fsanitize=undefined -fsanitize=bounds -fsanitize=bounds-strict -g
OBJECTS = $(patsubst %.cpp,%.o,$(wildcard *.cpp))