Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78717c2af5 | ||
|
|
32cdd2fd27 | ||
|
|
e3aebbe0f5 | ||
|
|
80087a3a55 | ||
|
|
d0b07c02a3 | ||
|
|
1716a6b531 | ||
|
|
a86cfc932b | ||
|
|
8ce3f3aa7d | ||
|
|
89158f7777 | ||
|
|
cedbd0eb89 | ||
|
|
fd38c47657 | ||
|
|
bb5c4469b3 | ||
|
|
36b0cd37ec | ||
|
|
59fbefc095 | ||
|
|
b1f3a185bf | ||
|
|
adcbf1380a | ||
|
|
733533f089 | ||
|
|
ae6f216a82 | ||
|
|
417bb37042 | ||
|
|
95cad27904 | ||
|
|
3e66e7b1f0 | ||
|
|
4a6cc3e9a8 | ||
|
|
0260b7f1dc | ||
|
|
6b180e1943 | ||
|
|
afec1a5f5a | ||
|
|
7ab5657470 | ||
|
|
fa63e6d717 | ||
|
|
bf69c85cb8 | ||
|
|
5e888a2fc7 | ||
|
|
f0db911a5c | ||
|
|
efff7a8f3f | ||
|
|
7f5569ffba | ||
|
|
7c9ef72802 | ||
|
|
c75af66d72 | ||
|
|
ce769c625f | ||
|
|
f1e65e55de | ||
|
|
7e4a956dbd | ||
|
|
43b071020a | ||
|
|
f548057ee7 | ||
|
|
e260407a3e | ||
|
|
f049b04688 | ||
|
|
8af4d74bd4 | ||
|
|
a039d60a47 | ||
|
|
a4634e8888 | ||
|
|
df1eec4fb9 | ||
|
|
4524c7580f | ||
|
|
536a642b64 | ||
|
|
80e1faa764 | ||
|
|
4e8e1564e0 | ||
|
|
cd0a21d242 | ||
|
|
e43f4f7ef9 | ||
|
|
f2691c6beb | ||
|
|
825dbf7e60 | ||
|
|
ed078509da | ||
|
|
759a36d0b3 | ||
|
|
e0d2196ae5 | ||
|
|
998c7814bc | ||
|
|
ebd9209b31 | ||
|
|
745b02d4d7 | ||
|
|
b28fd1456c | ||
|
|
44a7a9cfed | ||
|
|
ee9e26902f | ||
|
|
c14a60deec | ||
|
|
33e382b623 | ||
|
|
7334664999 | ||
|
|
f021766215 | ||
|
|
5491a20833 | ||
|
|
1cab3be4df | ||
|
|
08e1cb5211 | ||
|
|
70c45a2f17 | ||
|
|
2dfed59b94 | ||
|
|
8bf7834041 | ||
|
|
1461d33045 | ||
|
|
e05bc82e7b | ||
|
|
9201e8ddd0 | ||
|
|
30dd62780b | ||
|
|
5dd6c665a5 | ||
|
|
2e6b4ed0a3 | ||
|
|
08c0647e54 | ||
|
|
ff7f5d63e6 | ||
|
|
2288ec1497 | ||
|
|
1df5fc83b7 | ||
|
|
81df0a1f93 | ||
|
|
bceaf09865 | ||
|
|
3992546579 | ||
|
|
602f6217e0 | ||
|
|
449e6f682f | ||
|
|
03df540096 | ||
|
|
b21700fc85 | ||
|
|
02438fff53 | ||
|
|
451d5d2cec | ||
|
|
534f135ef5 | ||
|
|
8bd0d6692a | ||
|
|
ad1bed2686 | ||
|
|
36e3d67a28 | ||
|
|
e3db651df7 | ||
|
|
fa52e3f5ef | ||
|
|
e6b06b21da | ||
|
|
252708e389 | ||
|
|
4b468f5009 | ||
|
|
1244651dda | ||
|
|
e4b96542b3 | ||
|
|
5701dd07a8 | ||
|
|
bdc89797cd | ||
|
|
2110b7d82c | ||
|
|
3bcfde3238 | ||
|
|
3495f87581 | ||
|
|
8a24c0d724 | ||
|
|
ec75a6107c | ||
|
|
450e1ba8a5 | ||
|
|
a0dcf97054 | ||
|
|
cd96c0d9e2 | ||
|
|
5e4ce67bf4 | ||
|
|
7dbe9fa6c3 | ||
|
|
7da30298dd | ||
|
|
f347a5640e | ||
|
|
c7433b6e60 | ||
|
|
e712b832e8 | ||
|
|
8a736f85a3 | ||
|
|
9f8bf056c2 | ||
|
|
b79a7e005c | ||
|
|
cae3a6a4bf | ||
|
|
fb6278f692 | ||
|
|
8622e81b8a | ||
|
|
f788d4032f | ||
|
|
c2b1eea864 | ||
|
|
6eb9394e13 | ||
|
|
391a1df2e8 | ||
|
|
7b718b1ae9 | ||
|
|
bc18db7a51 | ||
|
|
505339b6e5 | ||
|
|
f015fac562 | ||
|
|
502cbca4ba | ||
|
|
5e5331acd4 | ||
|
|
2dddc1367e | ||
|
|
5ca720b31f | ||
|
|
f72922fa68 | ||
|
|
c18e7f0aff | ||
|
|
0c40604508 | ||
|
|
f16c95c5c5 | ||
|
|
65c42d01cd | ||
|
|
485b705757 | ||
|
|
0b77330a4d | ||
|
|
4b93b36b3b | ||
|
|
475b97464d | ||
|
|
09e213b8ee | ||
|
|
16d8d9184a | ||
|
|
db9a72e616 | ||
|
|
a091e28200 | ||
|
|
f0b85ca5f6 | ||
|
|
df0d597efe | ||
|
|
43175ea30a | ||
|
|
5c89440ae6 | ||
|
|
6c9939308c | ||
|
|
fd42b70761 | ||
|
|
edfa27d837 | ||
|
|
1549c14df7 | ||
|
|
5d312b07c1 | ||
|
|
91b672bd1a | ||
|
|
59707c1ae4 | ||
|
|
b2668ee071 | ||
|
|
f447f144fe | ||
|
|
ce914cdf47 | ||
|
|
dc613842b1 | ||
|
|
f290389fbe | ||
|
|
3a7185c261 | ||
|
|
c7861f1fd0 | ||
|
|
63763b6b63 | ||
|
|
8ebb6ac0a2 | ||
|
|
5245bfc6fe | ||
|
|
4f9486699c | ||
|
|
9a45f6cb87 | ||
|
|
f232dde0e4 | ||
|
|
db7395173f | ||
|
|
ba2af98edf | ||
|
|
0998f46768 | ||
|
|
1816783f33 | ||
|
|
c1a8093c81 | ||
|
|
a50f35ea01 | ||
|
|
3ac6dae148 | ||
|
|
289630982c | ||
|
|
d0c03a8854 | ||
|
|
a7d1061a91 | ||
|
|
51e05c104c | ||
|
|
6fea1054d4 | ||
|
|
1d5981c084 | ||
|
|
8d75ca051d | ||
|
|
3d30c3c98b | ||
|
|
6b9b3ee8ca | ||
|
|
0d53547bd7 | ||
|
|
4dbc73b36d | ||
|
|
2784d6c912 | ||
|
|
5ea56be3b7 | ||
|
|
c33258d10c | ||
|
|
db0f9bb7eb | ||
|
|
f44ddefe87 | ||
|
|
27f50ccc77 | ||
|
|
cf989effe6 | ||
|
|
b18e38ed2b | ||
|
|
5b8b5813dc | ||
|
|
5bafc30a2a | ||
|
|
7a63aad350 | ||
|
|
56b74f982e | ||
|
|
05740be686 | ||
|
|
7e67ab4d9a | ||
|
|
0ad1fa65f6 | ||
|
|
7fd68b3333 | ||
|
|
356be8fdf0 | ||
|
|
2f0b2aaf83 | ||
|
|
355cc6adad | ||
|
|
a189f683c4 | ||
|
|
5b64691308 | ||
|
|
f487d19327 | ||
|
|
544afa8b21 | ||
|
|
ab6d553c18 | ||
|
|
ec9abaf635 | ||
|
|
d896f56e06 | ||
|
|
bae404906c | ||
|
|
85b987e5c9 | ||
|
|
0c54c27517 | ||
|
|
e116139d6d | ||
|
|
f441ee87b7 | ||
|
|
787654c911 | ||
|
|
1bb4f5e350 | ||
|
|
24586267cf | ||
|
|
71142882e9 | ||
|
|
c9f960afa9 | ||
|
|
50ff9c704e | ||
|
|
86d6ae5b4c | ||
|
|
9ace567ad4 | ||
|
|
cdb7166177 | ||
|
|
7e560dadd0 | ||
|
|
6ba4f99302 | ||
|
|
712596cd5e | ||
|
|
7ee11c94ec | ||
|
|
8d68fefa48 | ||
|
|
cd1944d9ed | ||
|
|
877568668d | ||
|
|
108adbdf97 | ||
|
|
f76cf14794 | ||
|
|
c4033d8838 | ||
|
|
ced2325184 | ||
|
|
fe9a74bf75 |
+4
-2
@@ -381,10 +381,11 @@ else()
|
||||
set(ARMA_LIBS ${ARMA_LIBS} ${MKL_LIBRARIES})
|
||||
|
||||
message(STATUS "")
|
||||
message(STATUS "*** If the MKL libraries are installed in non-standard locations such as")
|
||||
message(STATUS "*** If the MKL libraries are installed in a non-standard location such as")
|
||||
message(STATUS "*** /opt/intel/mkl, /opt/intel/composerxe/, /usr/local/intel/mkl")
|
||||
message(STATUS "*** make sure the run-time linker can find them.")
|
||||
message(STATUS "*** On Linux systems this can be done by editing /etc/ld.so.conf")
|
||||
message(STATUS "*** or specifying the location through a file in /etc/ld.so.conf.d/")
|
||||
message(STATUS "*** or modifying the LD_LIBRARY_PATH environment variable.")
|
||||
message(STATUS "")
|
||||
message(STATUS "*** On systems with SELinux enabled (eg. Fedora, RHEL),")
|
||||
@@ -419,10 +420,11 @@ else()
|
||||
endif()
|
||||
|
||||
message(STATUS "")
|
||||
message(STATUS "*** If the OpenBLAS library is installed in")
|
||||
message(STATUS "*** If the OpenBLAS library is installed in a location such as")
|
||||
message(STATUS "*** /usr/local/lib or /usr/local/lib64")
|
||||
message(STATUS "*** make sure the run-time linker can find it.")
|
||||
message(STATUS "*** On Linux systems this can be done by editing /etc/ld.so.conf")
|
||||
message(STATUS "*** or specifying the location through a file in /etc/ld.so.conf.d/")
|
||||
message(STATUS "*** or modifying the LD_LIBRARY_PATH environment variable.")
|
||||
message(STATUS "")
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
Armadillo C++ Linear Algebra Library
|
||||
Copyright 2008-2025 Conrad Sanderson (https://conradsanderson.id.au)
|
||||
Copyright 2008-2026 Conrad Sanderson (https://conradsanderson.id.au)
|
||||
Copyright 2008-2016 National ICT Australia (NICTA)
|
||||
Copyright 2017-2025 Data61 / CSIRO
|
||||
Copyright 2017-2026 Data61 / CSIRO
|
||||
|
||||
This product includes software developed by Conrad Sanderson (https://conradsanderson.id.au)
|
||||
This product includes software developed at National ICT Australia (NICTA)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
### Armadillo: C++ Library for Linear Algebra & Scientific Computing
|
||||
https://arma.sourceforge.net
|
||||
|
||||
Copyright 2008-2025 Conrad Sanderson (https://conradsanderson.id.au)
|
||||
Copyright 2008-2026 Conrad Sanderson (https://conradsanderson.id.au)
|
||||
Copyright 2008-2016 National ICT Australia (NICTA)
|
||||
Copyright 2017-2025 Data61 / CSIRO
|
||||
Copyright 2017-2026 Data61 / CSIRO
|
||||
|
||||
---
|
||||
|
||||
@@ -38,7 +38,7 @@ Copyright 2017-2025 Data61 / CSIRO
|
||||
13. [API Stability and Version Policy](#13-api-stability-and-version-policy)
|
||||
14. [Bug Reports and Frequently Asked Questions](#14-bug-reports-and-frequently-asked-questions)
|
||||
|
||||
15. [MEX Interface to Octave/Matlab](#15-mex-interface-to-octavematlab)
|
||||
15. [Prohibition on Use of Large Language Models (LLMs)](#15-prohibition-on-use-of-large-language-models-llms)
|
||||
16. [Related Software Using Armadillo](#16-related-software-using-armadillo)
|
||||
|
||||
---
|
||||
@@ -391,8 +391,8 @@ Use a web browser to view it.
|
||||
|
||||
Use of the C++11 `auto` keyword is not recommended with Armadillo objects and expressions.
|
||||
|
||||
Armadillo has a template meta-programming framework which creates short-lived temporaries
|
||||
that are not properly handled by `auto`.
|
||||
Armadillo has a template meta-programming framework which creates short-lived
|
||||
temporary objects that are not properly handled by `auto`.
|
||||
|
||||
---
|
||||
|
||||
@@ -452,10 +452,12 @@ https://arma.sourceforge.net/faq.html
|
||||
|
||||
---
|
||||
|
||||
### 15: MEX Interface to Octave/Matlab
|
||||
### 15: Prohibition on Use of Large Language Models (LLMs)
|
||||
|
||||
The `mex_interface` folder contains examples of how to interface
|
||||
Octave/Matlab with C++ code that uses Armadillo matrices.
|
||||
The Armadillo codebase has been developed entirely without the use of LLMs.
|
||||
We do not accept any code which has been created (directly or indirectly)
|
||||
with the aid of LLMs. This is due to issues with code provenance and low quality
|
||||
of LLM generated code.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Binary file not shown.
@@ -581,6 +581,7 @@ namespace arma
|
||||
#include "armadillo_bits/fn_inplace_trans.hpp"
|
||||
#include "armadillo_bits/fn_randi.hpp"
|
||||
#include "armadillo_bits/fn_randg.hpp"
|
||||
#include "armadillo_bits/fn_rande.hpp"
|
||||
#include "armadillo_bits/fn_cond_rcond.hpp"
|
||||
#include "armadillo_bits/fn_normalise.hpp"
|
||||
#include "armadillo_bits/fn_clamp.hpp"
|
||||
|
||||
@@ -244,9 +244,9 @@ BaseCube<elem_type,derived>::is_zero(const typename get_pod_type<elem_type>::res
|
||||
|
||||
typedef typename get_pod_type<elem_type>::result T;
|
||||
|
||||
arma_conform_check( (tol < T(0)), "is_zero(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_zero(): parameter 'tol' must be >= 0" );
|
||||
|
||||
if(ProxyCube<derived>::use_at || is_Cube<typename ProxyCube<derived>::stored_type>::value)
|
||||
if(is_Cube<typename ProxyCube<derived>::stored_type>::value || ProxyCube<derived>::use_at)
|
||||
{
|
||||
const unwrap_cube<derived> U( (*this).get_ref() );
|
||||
|
||||
@@ -263,22 +263,52 @@ BaseCube<elem_type,derived>::is_zero(const typename get_pod_type<elem_type>::res
|
||||
|
||||
if(is_cx<elem_type>::yes)
|
||||
{
|
||||
for(uword i=0; i<n_elem; ++i)
|
||||
if(tol == T(0))
|
||||
{
|
||||
const elem_type val = Pea[i];
|
||||
|
||||
const T val_real = access::tmp_real(val);
|
||||
const T val_imag = access::tmp_imag(val);
|
||||
|
||||
if(eop_aux::arma_abs(val_real) > tol) { return false; }
|
||||
if(eop_aux::arma_abs(val_imag) > tol) { return false; }
|
||||
for(uword i=0; i < n_elem; ++i)
|
||||
{
|
||||
const elem_type val = Pea[i];
|
||||
|
||||
const T val_real = access::tmp_real(val);
|
||||
const T val_imag = access::tmp_imag(val);
|
||||
|
||||
if(eop_aux::arma_abs(val_real) != T(0)) { return false; }
|
||||
if(eop_aux::arma_abs(val_imag) != T(0)) { return false; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(uword i=0; i < n_elem; ++i)
|
||||
{
|
||||
const elem_type val = Pea[i];
|
||||
|
||||
const T val_real = access::tmp_real(val);
|
||||
const T val_imag = access::tmp_imag(val);
|
||||
|
||||
if( (eop_aux::arma_abs(val_real) <= tol) == false ) { return false; }
|
||||
if( (eop_aux::arma_abs(val_imag) <= tol) == false ) { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
else // not complex
|
||||
{
|
||||
for(uword i=0; i < n_elem; ++i)
|
||||
if(tol == T(0))
|
||||
{
|
||||
if(eop_aux::arma_abs(Pea[i]) > tol) { return false; }
|
||||
for(uword i=0; i < n_elem; ++i)
|
||||
{
|
||||
const elem_type val = Pea[i];
|
||||
|
||||
if(val != elem_type(0)) { return false; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(uword i=0; i < n_elem; ++i)
|
||||
{
|
||||
const elem_type val = Pea[i];
|
||||
|
||||
if( (eop_aux::arma_abs(val) <= tol) == false ) { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ Base<elem_type,derived>::is_symmetric(const typename get_pod_type<elem_type>::re
|
||||
|
||||
if(tol == T(0)) { return (*this).is_symmetric(); }
|
||||
|
||||
arma_conform_check( (tol < T(0)), "is_symmetric(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_symmetric(): parameter 'tol' must be > 0" );
|
||||
|
||||
const quasi_unwrap<derived> U( (*this).get_ref() );
|
||||
|
||||
@@ -365,8 +365,12 @@ Base<elem_type,derived>::is_symmetric(const typename get_pod_type<elem_type>::re
|
||||
|
||||
if(norm_A == T(0)) { return true; }
|
||||
|
||||
if(arma_isnan(norm_A)) { return false; }
|
||||
|
||||
const T norm_A_Ast = as_scalar( arma::max(sum(abs(A - A.st()), 1), 0) );
|
||||
|
||||
if(arma_isnan(norm_A_Ast)) { return false; }
|
||||
|
||||
return ( (norm_A_Ast / norm_A) <= tol );
|
||||
}
|
||||
|
||||
@@ -435,7 +439,7 @@ Base<elem_type,derived>::is_hermitian(const typename get_pod_type<elem_type>::re
|
||||
|
||||
if(tol == T(0)) { return (*this).is_hermitian(); }
|
||||
|
||||
arma_conform_check( (tol < T(0)), "is_hermitian(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_hermitian(): parameter 'tol' must be > 0" );
|
||||
|
||||
const quasi_unwrap<derived> U( (*this).get_ref() );
|
||||
|
||||
@@ -448,8 +452,12 @@ Base<elem_type,derived>::is_hermitian(const typename get_pod_type<elem_type>::re
|
||||
|
||||
if(norm_A == T(0)) { return true; }
|
||||
|
||||
if(arma_isnan(norm_A)) { return false; }
|
||||
|
||||
const T norm_A_At = as_scalar( arma::max(sum(abs(A - A.t()), 1), 0) );
|
||||
|
||||
if(arma_isnan(norm_A_At)) { return false; }
|
||||
|
||||
return ( (norm_A_At / norm_A) <= tol );
|
||||
}
|
||||
|
||||
@@ -464,9 +472,9 @@ Base<elem_type,derived>::is_zero(const typename get_pod_type<elem_type>::result
|
||||
|
||||
typedef typename get_pod_type<elem_type>::result T;
|
||||
|
||||
arma_conform_check( (tol < T(0)), "is_zero(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_zero(): parameter 'tol' must be >= 0" );
|
||||
|
||||
if(Proxy<derived>::use_at || is_Mat<typename Proxy<derived>::stored_type>::value)
|
||||
if( (quasi_unwrap<derived>::has_orig_mem) || (is_Mat<typename Proxy<derived>::stored_type>::value) || (Proxy<derived>::use_at) )
|
||||
{
|
||||
const quasi_unwrap<derived> U( (*this).get_ref() );
|
||||
|
||||
@@ -483,22 +491,52 @@ Base<elem_type,derived>::is_zero(const typename get_pod_type<elem_type>::result
|
||||
|
||||
if(is_cx<elem_type>::yes)
|
||||
{
|
||||
for(uword i=0; i<n_elem; ++i)
|
||||
if(tol == T(0))
|
||||
{
|
||||
const elem_type val = Pea[i];
|
||||
|
||||
const T val_real = access::tmp_real(val);
|
||||
const T val_imag = access::tmp_imag(val);
|
||||
|
||||
if(eop_aux::arma_abs(val_real) > tol) { return false; }
|
||||
if(eop_aux::arma_abs(val_imag) > tol) { return false; }
|
||||
for(uword i=0; i < n_elem; ++i)
|
||||
{
|
||||
const elem_type val = Pea[i];
|
||||
|
||||
const T val_real = access::tmp_real(val);
|
||||
const T val_imag = access::tmp_imag(val);
|
||||
|
||||
if(eop_aux::arma_abs(val_real) != T(0)) { return false; }
|
||||
if(eop_aux::arma_abs(val_imag) != T(0)) { return false; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(uword i=0; i < n_elem; ++i)
|
||||
{
|
||||
const elem_type val = Pea[i];
|
||||
|
||||
const T val_real = access::tmp_real(val);
|
||||
const T val_imag = access::tmp_imag(val);
|
||||
|
||||
if( (eop_aux::arma_abs(val_real) <= tol) == false ) { return false; }
|
||||
if( (eop_aux::arma_abs(val_imag) <= tol) == false ) { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
else // not complex
|
||||
{
|
||||
for(uword i=0; i<n_elem; ++i)
|
||||
if(tol == T(0))
|
||||
{
|
||||
if(eop_aux::arma_abs(Pea[i]) > tol) { return false; }
|
||||
for(uword i=0; i < n_elem; ++i)
|
||||
{
|
||||
const elem_type val = Pea[i];
|
||||
|
||||
if(val != elem_type(0)) { return false; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(uword i=0; i < n_elem; ++i)
|
||||
{
|
||||
const elem_type val = Pea[i];
|
||||
|
||||
if( (eop_aux::arma_abs(val) <= tol) == false ) { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,7 +705,7 @@ Base<elem_type,derived>::is_finite() const
|
||||
|
||||
if(arma_config::fast_math_warn) { arma_warn(1, "is_finite(): detection of non-finite values is not reliable in fast math mode"); }
|
||||
|
||||
if(is_Mat<typename Proxy<derived>::stored_type>::value)
|
||||
if( (quasi_unwrap<derived>::has_orig_mem) || (is_Mat<typename Proxy<derived>::stored_type>::value) )
|
||||
{
|
||||
const quasi_unwrap<derived> U( (*this).get_ref() );
|
||||
|
||||
@@ -715,7 +753,7 @@ Base<elem_type,derived>::has_inf() const
|
||||
|
||||
if(arma_config::fast_math_warn) { arma_warn(1, "has_inf(): detection of non-finite values is not reliable in fast math mode"); }
|
||||
|
||||
if(is_Mat<typename Proxy<derived>::stored_type>::value)
|
||||
if( (quasi_unwrap<derived>::has_orig_mem) || (is_Mat<typename Proxy<derived>::stored_type>::value) )
|
||||
{
|
||||
const quasi_unwrap<derived> U( (*this).get_ref() );
|
||||
|
||||
@@ -763,7 +801,7 @@ Base<elem_type,derived>::has_nan() const
|
||||
|
||||
if(arma_config::fast_math_warn) { arma_warn(1, "has_nan(): detection of non-finite values is not reliable in fast math mode"); }
|
||||
|
||||
if(is_Mat<typename Proxy<derived>::stored_type>::value)
|
||||
if( (quasi_unwrap<derived>::has_orig_mem) || (is_Mat<typename Proxy<derived>::stored_type>::value) )
|
||||
{
|
||||
const quasi_unwrap<derived> U( (*this).get_ref() );
|
||||
|
||||
@@ -811,7 +849,7 @@ Base<elem_type,derived>::has_nonfinite() const
|
||||
|
||||
if(arma_config::fast_math_warn) { arma_warn(1, "has_nonfinite(): detection of non-finite values is not reliable in fast math mode"); }
|
||||
|
||||
if(is_Mat<typename Proxy<derived>::stored_type>::value)
|
||||
if( (quasi_unwrap<derived>::has_orig_mem) || (is_Mat<typename Proxy<derived>::stored_type>::value) )
|
||||
{
|
||||
const quasi_unwrap<derived> U( (*this).get_ref() );
|
||||
|
||||
@@ -897,6 +935,8 @@ Base_extra_yes<elem_type,derived>::is_sympd() const
|
||||
// default value for tol
|
||||
const T tol = T(100) * std::numeric_limits<T>::epsilon() * norm(X, "fro");
|
||||
|
||||
if(arma_isnan(tol)) { return false; }
|
||||
|
||||
if(X.is_hermitian(tol) == false) { return false; }
|
||||
|
||||
if(X.is_empty()) { return false; }
|
||||
@@ -917,7 +957,7 @@ Base_extra_yes<elem_type,derived>::is_sympd(typename get_pod_type<elem_type>::re
|
||||
|
||||
typedef typename get_pod_type<elem_type>::result T;
|
||||
|
||||
arma_conform_check( (tol < T(0)), "is_sympd(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_sympd(): parameter 'tol' must be >= 0" );
|
||||
|
||||
Mat<elem_type> X = static_cast<const derived&>(*this);
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ class Col : public Mat<eT>
|
||||
template<typename T1> inline void shed_rows(const Base<uword, T1>& indices);
|
||||
|
||||
[[deprecated]] inline void insert_rows(const uword row_num, const uword N, const bool set_to_zero);
|
||||
inline void insert_rows(const uword row_num, const uword N);
|
||||
inline void insert_rows(const uword row_num, const uword N);
|
||||
|
||||
template<typename T1> inline void insert_rows(const uword row_num, const Base<eT,T1>& X);
|
||||
|
||||
@@ -154,6 +154,11 @@ class Col : public Mat<eT>
|
||||
arma_warn_unused arma_inline const eT& at(const uword in_row, const uword in_col) const;
|
||||
|
||||
|
||||
inline constexpr bool is_vec() const { return true; }
|
||||
inline constexpr bool is_rowvec() const { return false; }
|
||||
inline constexpr bool is_colvec() const { return true; }
|
||||
|
||||
|
||||
typedef eT* row_iterator;
|
||||
typedef const eT* const_row_iterator;
|
||||
|
||||
|
||||
@@ -483,7 +483,7 @@ Col<eT>::operator=(Col<eT>&& X)
|
||||
// if(X.n_cols != 1) { const Mat<eT>& XX = X; Mat<eT>::operator=(XX); return *this; }
|
||||
//
|
||||
// (*this).steal_mem(X, true);
|
||||
//
|
||||
//
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
@@ -521,11 +521,9 @@ template<typename eT>
|
||||
template<typename T1>
|
||||
inline
|
||||
Col<eT>::Col(const Base<eT,T1>& X)
|
||||
: Mat<eT>(arma_vec_indicator(), 1)
|
||||
: Mat<eT>(X.get_ref(), arma_vec_indicator(), 1)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<eT>::operator=(X.get_ref());
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -549,11 +547,9 @@ template<typename eT>
|
||||
template<typename T1>
|
||||
inline
|
||||
Col<eT>::Col(const SpBase<eT,T1>& X)
|
||||
: Mat<eT>(arma_vec_indicator(), 1)
|
||||
: Mat<eT>(X.get_ref(), arma_vec_indicator(), 1)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
Mat<eT>::operator=(X.get_ref());
|
||||
}
|
||||
|
||||
|
||||
@@ -607,12 +603,9 @@ Col<eT>::Col
|
||||
const Base<typename Col<eT>::pod_type, T1>& A,
|
||||
const Base<typename Col<eT>::pod_type, T2>& B
|
||||
)
|
||||
: Mat<eT>(A.get_ref(), B.get_ref(), arma_vec_indicator(), 1)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
access::rw(Mat<eT>::vec_state) = 1;
|
||||
|
||||
Mat<eT>::init(A,B);
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -621,12 +614,9 @@ template<typename eT>
|
||||
template<typename T1>
|
||||
inline
|
||||
Col<eT>::Col(const BaseCube<eT,T1>& X)
|
||||
: Mat<eT>(X.get_ref(), arma_vec_indicator(), 1)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
access::rw(Mat<eT>::vec_state) = 1;
|
||||
|
||||
Mat<eT>::operator=(X);
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -649,12 +639,9 @@ Col<eT>::operator=(const BaseCube<eT,T1>& X)
|
||||
template<typename eT>
|
||||
inline
|
||||
Col<eT>::Col(const subview_cube<eT>& X)
|
||||
: Mat<eT>(X, arma_vec_indicator(), 1)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
access::rw(Mat<eT>::vec_state) = 1;
|
||||
|
||||
Mat<eT>::operator=(X);
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1277,6 +1264,13 @@ Col<eT>::end_row(const uword row_num) const
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<uword fixed_n_elem>
|
||||
arma_inline
|
||||
@@ -1350,6 +1344,10 @@ Col<eT>::fixed<fixed_n_elem>::fixed(const fill::fill_class<fill_type>&)
|
||||
if(is_same_type<fill_type, fill::fill_eye >::yes) { Mat<eT>::eye(); }
|
||||
if(is_same_type<fill_type, fill::fill_randu>::yes) { Mat<eT>::randu(); }
|
||||
if(is_same_type<fill_type, fill::fill_randn>::yes) { Mat<eT>::randn(); }
|
||||
|
||||
if(is_same_type<fill_type, fill::fill_nan >::yes) { (*this).fill( priv::Datum_helper::nan <eT>() ); }
|
||||
if(is_same_type<fill_type, fill::fill_pos_inf>::yes) { (*this).fill( priv::Datum_helper::pos_inf<eT>() ); }
|
||||
if(is_same_type<fill_type, fill::fill_neg_inf>::yes) { (*this).fill( priv::Datum_helper::neg_inf<eT>() ); }
|
||||
}
|
||||
|
||||
|
||||
@@ -1872,6 +1870,10 @@ Col<eT>::fixed<fixed_n_elem>::ones()
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
Col<eT>::Col(const arma_fixed_indicator&, const uword in_n_elem, const eT* in_mem)
|
||||
|
||||
@@ -360,6 +360,9 @@ class Cube : public BaseCube< eT, Cube<eT> >
|
||||
|
||||
inline Cube& fill(const eT val);
|
||||
|
||||
template<typename fill_type>
|
||||
inline Cube& fill(const fill::fill_class<fill_type>& f);
|
||||
|
||||
inline Cube& zeros();
|
||||
inline Cube& zeros(const uword new_n_rows, const uword new_n_cols, const uword new_n_slices);
|
||||
inline Cube& zeros(const SizeCube& s);
|
||||
|
||||
@@ -52,7 +52,7 @@ Cube<eT>::Cube()
|
||||
, n_elem(0)
|
||||
, n_alloc(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ Cube<eT>::Cube(const SizeCube& s, const arma_initmode_indicator<do_zeros>&)
|
||||
template<typename eT>
|
||||
template<typename fill_type>
|
||||
inline
|
||||
Cube<eT>::Cube(const uword in_n_rows, const uword in_n_cols, const uword in_n_slices, const fill::fill_class<fill_type>&)
|
||||
Cube<eT>::Cube(const uword in_n_rows, const uword in_n_cols, const uword in_n_slices, const fill::fill_class<fill_type>& f)
|
||||
: n_rows(in_n_rows)
|
||||
, n_cols(in_n_cols)
|
||||
, n_elem_slice(in_n_rows*in_n_cols)
|
||||
@@ -186,12 +186,7 @@ Cube<eT>::Cube(const uword in_n_rows, const uword in_n_cols, const uword in_n_sl
|
||||
|
||||
init_cold();
|
||||
|
||||
if(is_same_type<fill_type, fill::fill_zeros>::yes) { (*this).zeros(); }
|
||||
if(is_same_type<fill_type, fill::fill_ones >::yes) { (*this).ones(); }
|
||||
if(is_same_type<fill_type, fill::fill_randu>::yes) { (*this).randu(); }
|
||||
if(is_same_type<fill_type, fill::fill_randn>::yes) { (*this).randn(); }
|
||||
|
||||
arma_static_check( (is_same_type<fill_type, fill::fill_eye>::yes), "Cube::Cube(): unsupported fill type" );
|
||||
(*this).fill(f);
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +194,7 @@ Cube<eT>::Cube(const uword in_n_rows, const uword in_n_cols, const uword in_n_sl
|
||||
template<typename eT>
|
||||
template<typename fill_type>
|
||||
inline
|
||||
Cube<eT>::Cube(const SizeCube& s, const fill::fill_class<fill_type>&)
|
||||
Cube<eT>::Cube(const SizeCube& s, const fill::fill_class<fill_type>& f)
|
||||
: n_rows(s.n_rows)
|
||||
, n_cols(s.n_cols)
|
||||
, n_elem_slice(s.n_rows*s.n_cols)
|
||||
@@ -213,12 +208,7 @@ Cube<eT>::Cube(const SizeCube& s, const fill::fill_class<fill_type>&)
|
||||
|
||||
init_cold();
|
||||
|
||||
if(is_same_type<fill_type, fill::fill_zeros>::yes) { (*this).zeros(); }
|
||||
if(is_same_type<fill_type, fill::fill_ones >::yes) { (*this).ones(); }
|
||||
if(is_same_type<fill_type, fill::fill_randu>::yes) { (*this).randu(); }
|
||||
if(is_same_type<fill_type, fill::fill_randn>::yes) { (*this).randn(); }
|
||||
|
||||
arma_static_check( (is_same_type<fill_type, fill::fill_eye>::yes), "Cube::Cube(): unsupported fill type" );
|
||||
(*this).fill(f);
|
||||
}
|
||||
|
||||
|
||||
@@ -934,7 +924,7 @@ Cube<eT>::Cube
|
||||
, n_elem(0)
|
||||
, n_alloc(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -1064,7 +1054,7 @@ Cube<eT>::Cube(const subview_cube_slices<eT,T1>& X)
|
||||
, n_elem(0)
|
||||
, n_alloc(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -2751,7 +2741,7 @@ Cube<eT>::Cube(const OpCube<T1, op_type>& X)
|
||||
, n_elem(0)
|
||||
, n_alloc(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -3048,7 +3038,7 @@ Cube<eT>::Cube(const mtOpCube<eT, T1, op_type>& X)
|
||||
, n_elem(0)
|
||||
, n_alloc(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -3144,11 +3134,11 @@ Cube<eT>::Cube(const GlueCube<T1, T2, glue_type>& X)
|
||||
, n_elem(0)
|
||||
, n_alloc(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
this->operator=(X);
|
||||
(*this).operator=(X);
|
||||
}
|
||||
|
||||
|
||||
@@ -3401,7 +3391,7 @@ Cube<eT>::Cube(const mtGlueCube<eT, T1, T2, glue_type>& X)
|
||||
, n_elem(0)
|
||||
, n_alloc(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -3887,7 +3877,7 @@ arma_inline
|
||||
eT*
|
||||
Cube<eT>::slice_memptr(const uword uslice)
|
||||
{
|
||||
return const_cast<eT*>( &mem[ uslice*n_elem_slice ] );
|
||||
return access::rwp( mem + (uslice*n_elem_slice) );
|
||||
}
|
||||
|
||||
|
||||
@@ -3898,7 +3888,7 @@ arma_inline
|
||||
const eT*
|
||||
Cube<eT>::slice_memptr(const uword uslice) const
|
||||
{
|
||||
return &mem[ uslice*n_elem_slice ];
|
||||
return mem + (uslice*n_elem_slice);
|
||||
}
|
||||
|
||||
|
||||
@@ -3909,7 +3899,7 @@ arma_inline
|
||||
eT*
|
||||
Cube<eT>::slice_colptr(const uword uslice, const uword col)
|
||||
{
|
||||
return const_cast<eT*>( &mem[ uslice*n_elem_slice + col*n_rows] );
|
||||
return access::rwp( mem + (uslice*n_elem_slice + col*n_rows) );
|
||||
}
|
||||
|
||||
|
||||
@@ -3920,7 +3910,7 @@ arma_inline
|
||||
const eT*
|
||||
Cube<eT>::slice_colptr(const uword uslice, const uword col) const
|
||||
{
|
||||
return &mem[ uslice*n_elem_slice + col*n_rows ];
|
||||
return mem + (uslice*n_elem_slice + col*n_rows);
|
||||
}
|
||||
|
||||
|
||||
@@ -4197,12 +4187,12 @@ Cube<eT>::clamp(const eT min_val, const eT max_val)
|
||||
|
||||
if(is_cx<eT>::no)
|
||||
{
|
||||
arma_conform_check( (access::tmp_real(min_val) > access::tmp_real(max_val)), "Cube::clamp(): min_val must be less than max_val" );
|
||||
arma_conform_check( ((access::tmp_real(min_val) <= access::tmp_real(max_val)) == false), "Cube::clamp(): min_val must be less than max_val" );
|
||||
}
|
||||
else
|
||||
{
|
||||
arma_conform_check( (access::tmp_real(min_val) > access::tmp_real(max_val)), "Cube::clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( (access::tmp_imag(min_val) > access::tmp_imag(max_val)), "Cube::clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
arma_conform_check( ((access::tmp_real(min_val) <= access::tmp_real(max_val)) == false), "Cube::clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( ((access::tmp_imag(min_val) <= access::tmp_imag(max_val)) == false), "Cube::clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
}
|
||||
|
||||
arrayops::clamp(memptr(), n_elem, min_val, max_val);
|
||||
@@ -4227,6 +4217,30 @@ Cube<eT>::fill(const eT val)
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<typename fill_type>
|
||||
inline
|
||||
Cube<eT>&
|
||||
Cube<eT>::fill(const fill::fill_class<fill_type>&)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
arma_static_check( (is_same_type<fill_type, fill::fill_eye>::yes), "Cube::fill(): unsupported fill type" );
|
||||
|
||||
if(is_same_type<fill_type, fill::fill_zeros>::yes) { (*this).zeros(); }
|
||||
if(is_same_type<fill_type, fill::fill_ones >::yes) { (*this).ones(); }
|
||||
if(is_same_type<fill_type, fill::fill_randu>::yes) { (*this).randu(); }
|
||||
if(is_same_type<fill_type, fill::fill_randn>::yes) { (*this).randn(); }
|
||||
|
||||
if(is_same_type<fill_type, fill::fill_nan >::yes) { (*this).fill( priv::Datum_helper::nan <eT>() ); }
|
||||
if(is_same_type<fill_type, fill::fill_pos_inf>::yes) { (*this).fill( priv::Datum_helper::pos_inf<eT>() ); }
|
||||
if(is_same_type<fill_type, fill::fill_neg_inf>::yes) { (*this).fill( priv::Datum_helper::neg_inf<eT>() ); }
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
Cube<eT>&
|
||||
@@ -5458,18 +5472,13 @@ template<typename eT>
|
||||
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices>
|
||||
template<typename fill_type>
|
||||
inline
|
||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::fixed(const fill::fill_class<fill_type>&)
|
||||
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::fixed(const fill::fill_class<fill_type>& f)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
mem_setup();
|
||||
|
||||
if(is_same_type<fill_type, fill::fill_zeros>::yes) { Cube<eT>::zeros(); }
|
||||
if(is_same_type<fill_type, fill::fill_ones >::yes) { Cube<eT>::ones(); }
|
||||
if(is_same_type<fill_type, fill::fill_randu>::yes) { Cube<eT>::randu(); }
|
||||
if(is_same_type<fill_type, fill::fill_randn>::yes) { Cube<eT>::randn(); }
|
||||
|
||||
arma_static_check( (is_same_type<fill_type, fill::fill_eye>::yes), "Cube::fixed::fixed(): unsupported fill type" );
|
||||
(*this).fill(f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
inline Mat& operator*=(const eT val);
|
||||
inline Mat& operator/=(const eT val);
|
||||
|
||||
inline Mat(const Mat& m, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
inline Mat(const Mat& m);
|
||||
inline Mat& operator= (const Mat& m);
|
||||
inline Mat& operator+=(const Mat& m);
|
||||
@@ -107,6 +108,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
inline Mat& operator%=(const Mat& m);
|
||||
inline Mat& operator/=(const Mat& m);
|
||||
|
||||
template<typename T1> inline Mat(const BaseCube<eT,T1>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1> inline Mat(const BaseCube<eT,T1>& X);
|
||||
template<typename T1> inline Mat& operator= (const BaseCube<eT,T1>& X);
|
||||
template<typename T1> inline Mat& operator+=(const BaseCube<eT,T1>& X);
|
||||
@@ -115,11 +117,12 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1> inline Mat& operator%=(const BaseCube<eT,T1>& X);
|
||||
template<typename T1> inline Mat& operator/=(const BaseCube<eT,T1>& X);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline explicit Mat(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
|
||||
template<typename T1, typename T2> inline explicit Mat(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename T2> inline explicit Mat(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B);
|
||||
|
||||
inline explicit Mat(const subview<eT>& X, const bool use_colmem); // only to be used by the quasi_unwrap class
|
||||
inline explicit Mat(const subview<eT>& X, const bool reuse_mem); // only to be used by quasi_unwrap and partial_unwrap
|
||||
|
||||
inline Mat(const subview<eT>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
inline Mat(const subview<eT>& X);
|
||||
inline Mat& operator= (const subview<eT>& X);
|
||||
inline Mat& operator+=(const subview<eT>& X);
|
||||
@@ -135,6 +138,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<bool do_conj>
|
||||
inline Mat(const xtrans_mat<eT,do_conj>& X); // xtrans_mat can only be generated by the Proxy class
|
||||
|
||||
inline Mat(const subview_cube<eT>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
inline Mat(const subview_cube<eT>& X);
|
||||
inline Mat& operator= (const subview_cube<eT>& X);
|
||||
inline Mat& operator+=(const subview_cube<eT>& X);
|
||||
@@ -143,6 +147,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
inline Mat& operator%=(const subview_cube<eT>& X);
|
||||
inline Mat& operator/=(const subview_cube<eT>& X);
|
||||
|
||||
inline Mat(const diagview<eT>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
inline Mat(const diagview<eT>& X);
|
||||
inline Mat& operator= (const diagview<eT>& X);
|
||||
inline Mat& operator+=(const diagview<eT>& X);
|
||||
@@ -151,6 +156,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
inline Mat& operator%=(const diagview<eT>& X);
|
||||
inline Mat& operator/=(const diagview<eT>& X);
|
||||
|
||||
template<typename T1> inline Mat(const subview_elem1<eT,T1>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1> inline Mat(const subview_elem1<eT,T1>& X);
|
||||
template<typename T1> inline Mat& operator= (const subview_elem1<eT,T1>& X);
|
||||
template<typename T1> inline Mat& operator+=(const subview_elem1<eT,T1>& X);
|
||||
@@ -159,6 +165,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1> inline Mat& operator%=(const subview_elem1<eT,T1>& X);
|
||||
template<typename T1> inline Mat& operator/=(const subview_elem1<eT,T1>& X);
|
||||
|
||||
template<typename T1, typename T2> inline Mat(const subview_elem2<eT,T1,T2>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename T2> inline Mat(const subview_elem2<eT,T1,T2>& X);
|
||||
template<typename T1, typename T2> inline Mat& operator= (const subview_elem2<eT,T1,T2>& X);
|
||||
template<typename T1, typename T2> inline Mat& operator+=(const subview_elem2<eT,T1,T2>& X);
|
||||
@@ -168,6 +175,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename T2> inline Mat& operator/=(const subview_elem2<eT,T1,T2>& X);
|
||||
|
||||
// Operators on sparse matrices (and subviews)
|
||||
template<typename T1> inline explicit Mat(const SpBase<eT, T1>& m, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1> inline explicit Mat(const SpBase<eT, T1>& m);
|
||||
template<typename T1> inline Mat& operator= (const SpBase<eT, T1>& m);
|
||||
template<typename T1> inline Mat& operator+=(const SpBase<eT, T1>& m);
|
||||
@@ -176,11 +184,13 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1> inline Mat& operator%=(const SpBase<eT, T1>& m);
|
||||
template<typename T1> inline Mat& operator/=(const SpBase<eT, T1>& m);
|
||||
|
||||
inline explicit Mat(const SpSubview<eT>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
inline explicit Mat(const SpSubview<eT>& X);
|
||||
inline Mat& operator= (const SpSubview<eT>& X);
|
||||
inline Mat& operator+=(const SpSubview<eT>& X);
|
||||
inline Mat& operator-=(const SpSubview<eT>& X);
|
||||
|
||||
inline explicit Mat(const spdiagview<eT>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
inline explicit Mat(const spdiagview<eT>& X);
|
||||
inline Mat& operator= (const spdiagview<eT>& X);
|
||||
inline Mat& operator+=(const spdiagview<eT>& X);
|
||||
@@ -320,6 +330,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1> inline void insert_cols(const uword col_num, const Base<eT,T1>& X);
|
||||
|
||||
|
||||
template<typename T1, typename gen_type> inline Mat(const Gen<T1, gen_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename gen_type> inline Mat(const Gen<T1, gen_type>& X);
|
||||
template<typename T1, typename gen_type> inline Mat& operator= (const Gen<T1, gen_type>& X);
|
||||
template<typename T1, typename gen_type> inline Mat& operator+=(const Gen<T1, gen_type>& X);
|
||||
@@ -328,6 +339,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename gen_type> inline Mat& operator%=(const Gen<T1, gen_type>& X);
|
||||
template<typename T1, typename gen_type> inline Mat& operator/=(const Gen<T1, gen_type>& X);
|
||||
|
||||
template<typename T1, typename op_type> inline Mat(const Op<T1, op_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename op_type> inline Mat(const Op<T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator= (const Op<T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator+=(const Op<T1, op_type>& X);
|
||||
@@ -336,6 +348,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename op_type> inline Mat& operator%=(const Op<T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator/=(const Op<T1, op_type>& X);
|
||||
|
||||
template<typename T1, typename eop_type> inline Mat(const eOp<T1, eop_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename eop_type> inline Mat(const eOp<T1, eop_type>& X);
|
||||
template<typename T1, typename eop_type> inline Mat& operator= (const eOp<T1, eop_type>& X);
|
||||
template<typename T1, typename eop_type> inline Mat& operator+=(const eOp<T1, eop_type>& X);
|
||||
@@ -344,6 +357,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename eop_type> inline Mat& operator%=(const eOp<T1, eop_type>& X);
|
||||
template<typename T1, typename eop_type> inline Mat& operator/=(const eOp<T1, eop_type>& X);
|
||||
|
||||
template<typename T1, typename op_type> inline Mat(const mtOp<eT, T1, op_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename op_type> inline Mat(const mtOp<eT, T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator= (const mtOp<eT, T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator+=(const mtOp<eT, T1, op_type>& X);
|
||||
@@ -352,6 +366,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename op_type> inline Mat& operator%=(const mtOp<eT, T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator/=(const mtOp<eT, T1, op_type>& X);
|
||||
|
||||
template<typename T1, typename op_type> inline Mat(const CubeToMatOp<T1, op_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename op_type> inline Mat(const CubeToMatOp<T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator= (const CubeToMatOp<T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator+=(const CubeToMatOp<T1, op_type>& X);
|
||||
@@ -360,6 +375,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename op_type> inline Mat& operator%=(const CubeToMatOp<T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator/=(const CubeToMatOp<T1, op_type>& X);
|
||||
|
||||
template<typename T1, typename op_type> inline Mat(const SpToDOp<T1, op_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename op_type> inline Mat(const SpToDOp<T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator= (const SpToDOp<T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator+=(const SpToDOp<T1, op_type>& X);
|
||||
@@ -368,6 +384,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename op_type> inline Mat& operator%=(const SpToDOp<T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator/=(const SpToDOp<T1, op_type>& X);
|
||||
|
||||
template<typename T1, typename op_type> inline explicit Mat(const mtSpReduceOp<eT, T1, op_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename op_type> inline explicit Mat(const mtSpReduceOp<eT, T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator= (const mtSpReduceOp<eT, T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator+=(const mtSpReduceOp<eT, T1, op_type>& X);
|
||||
@@ -376,6 +393,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename op_type> inline Mat& operator%=(const mtSpReduceOp<eT, T1, op_type>& X);
|
||||
template<typename T1, typename op_type> inline Mat& operator/=(const mtSpReduceOp<eT, T1, op_type>& X);
|
||||
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat(const Glue<T1, T2, glue_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat(const Glue<T1, T2, glue_type>& X);
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat& operator= (const Glue<T1, T2, glue_type>& X);
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat& operator+=(const Glue<T1, T2, glue_type>& X);
|
||||
@@ -387,6 +405,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename T2> inline Mat& operator+=(const Glue<T1, T2, glue_times>& X);
|
||||
template<typename T1, typename T2> inline Mat& operator-=(const Glue<T1, T2, glue_times>& X);
|
||||
|
||||
template<typename T1, typename T2, typename eglue_type> inline Mat(const eGlue<T1, T2, eglue_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename T2, typename eglue_type> inline Mat(const eGlue<T1, T2, eglue_type>& X);
|
||||
template<typename T1, typename T2, typename eglue_type> inline Mat& operator= (const eGlue<T1, T2, eglue_type>& X);
|
||||
template<typename T1, typename T2, typename eglue_type> inline Mat& operator+=(const eGlue<T1, T2, eglue_type>& X);
|
||||
@@ -395,6 +414,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename T2, typename eglue_type> inline Mat& operator%=(const eGlue<T1, T2, eglue_type>& X);
|
||||
template<typename T1, typename T2, typename eglue_type> inline Mat& operator/=(const eGlue<T1, T2, eglue_type>& X);
|
||||
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat(const mtGlue<eT, T1, T2, glue_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat(const mtGlue<eT, T1, T2, glue_type>& X);
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat& operator= (const mtGlue<eT, T1, T2, glue_type>& X);
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat& operator+=(const mtGlue<eT, T1, T2, glue_type>& X);
|
||||
@@ -403,6 +423,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat& operator%=(const mtGlue<eT, T1, T2, glue_type>& X);
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat& operator/=(const mtGlue<eT, T1, T2, glue_type>& X);
|
||||
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat(const SpToDGlue<T1, T2, glue_type>& X, const arma_vec_indicator&, const uhword in_vec_state);
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat(const SpToDGlue<T1, T2, glue_type>& X);
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat& operator= (const SpToDGlue<T1, T2, glue_type>& X);
|
||||
template<typename T1, typename T2, typename glue_type> inline Mat& operator+=(const SpToDGlue<T1, T2, glue_type>& X);
|
||||
@@ -958,4 +979,8 @@ class Mat_aux
|
||||
|
||||
|
||||
|
||||
template<typename eT> class Mat_noalias : public Mat<eT> {};
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1537,7 +1537,7 @@ struct Proxy_xtrans_default< Op<T1, op_htrans> >
|
||||
arma_inline aligned_ea_type get_aligned_ea() const { return Q; }
|
||||
|
||||
template<typename eT2>
|
||||
arma_inline bool is_alias(const Mat<eT2>& X) const { return void_ptr(&(U.M)) == void_ptr(&X); }
|
||||
arma_inline bool is_alias(const Mat<eT2>& X) const { return U.is_alias(X); }
|
||||
|
||||
template<typename eT2>
|
||||
arma_inline bool has_overlap(const subview<eT2>& X) const { return is_alias(X.m); }
|
||||
@@ -1578,7 +1578,7 @@ struct Proxy_xtrans_default< Op<T1, op_strans> >
|
||||
arma_inline aligned_ea_type get_aligned_ea() const { return Q; }
|
||||
|
||||
template<typename eT2>
|
||||
arma_inline bool is_alias(const Mat<eT2>& X) const { return void_ptr(&(U.M)) == void_ptr(&X); }
|
||||
arma_inline bool is_alias(const Mat<eT2>& X) const { return U.is_alias(X); }
|
||||
|
||||
template<typename eT2>
|
||||
arma_inline bool has_overlap(const subview<eT2>& X) const { return is_alias(X.m); }
|
||||
@@ -2441,7 +2441,7 @@ struct Proxy_vectorise_col_mat< Op<T1, op_vectorise_col> >
|
||||
arma_inline aligned_ea_type get_aligned_ea() const { return Q; }
|
||||
|
||||
template<typename eT2>
|
||||
arma_inline bool is_alias(const Mat<eT2>& X) const { return ( void_ptr(&X) == void_ptr(&(U.M)) ); }
|
||||
arma_inline bool is_alias(const Mat<eT2>& X) const { return U.is_alias(X); }
|
||||
|
||||
template<typename eT2>
|
||||
arma_inline bool has_overlap(const subview<eT2>& X) const { return is_alias(X.m); }
|
||||
|
||||
@@ -142,7 +142,7 @@ class Row : public Mat<eT>
|
||||
template<typename T1> inline void shed_cols(const Base<uword, T1>& indices);
|
||||
|
||||
[[deprecated]] inline void insert_cols(const uword col_num, const uword N, const bool set_to_zero);
|
||||
inline void insert_cols(const uword col_num, const uword N);
|
||||
inline void insert_cols(const uword col_num, const uword N);
|
||||
|
||||
template<typename T1> inline void insert_cols(const uword col_num, const Base<eT,T1>& X);
|
||||
|
||||
@@ -154,6 +154,11 @@ class Row : public Mat<eT>
|
||||
arma_warn_unused arma_inline const eT& at(const uword in_row, const uword in_col) const;
|
||||
|
||||
|
||||
inline constexpr bool is_vec() const { return true; }
|
||||
inline constexpr bool is_rowvec() const { return true; }
|
||||
inline constexpr bool is_colvec() const { return false; }
|
||||
|
||||
|
||||
typedef eT* row_iterator;
|
||||
typedef const eT* const_row_iterator;
|
||||
|
||||
@@ -164,6 +169,9 @@ class Row : public Mat<eT>
|
||||
inline const_row_iterator end_row (const uword row_num) const;
|
||||
|
||||
|
||||
inline explicit Row(const subview<eT>& X, const bool reuse_mem); // only to be used by the partial_unwrap class
|
||||
|
||||
|
||||
template<uword fixed_n_elem> class fixed;
|
||||
|
||||
|
||||
|
||||
@@ -521,11 +521,9 @@ template<typename eT>
|
||||
template<typename T1>
|
||||
inline
|
||||
Row<eT>::Row(const Base<eT,T1>& X)
|
||||
: Mat<eT>(arma_vec_indicator(), 2)
|
||||
: Mat<eT>(X.get_ref(), arma_vec_indicator(), 2)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<eT>::operator=(X.get_ref());
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -549,11 +547,9 @@ template<typename eT>
|
||||
template<typename T1>
|
||||
inline
|
||||
Row<eT>::Row(const SpBase<eT,T1>& X)
|
||||
: Mat<eT>(arma_vec_indicator(), 2)
|
||||
: Mat<eT>(X.get_ref(), arma_vec_indicator(), 2)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<eT>::operator=(X.get_ref());
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -607,12 +603,9 @@ Row<eT>::Row
|
||||
const Base<typename Row<eT>::pod_type, T1>& A,
|
||||
const Base<typename Row<eT>::pod_type, T2>& B
|
||||
)
|
||||
: Mat<eT>(A.get_ref(), B.get_ref(), arma_vec_indicator(), 2)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
access::rw(Mat<eT>::vec_state) = 2;
|
||||
|
||||
Mat<eT>::init(A,B);
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -621,12 +614,9 @@ template<typename eT>
|
||||
template<typename T1>
|
||||
inline
|
||||
Row<eT>::Row(const BaseCube<eT,T1>& X)
|
||||
: Mat<eT>(X.get_ref(), arma_vec_indicator(), 2)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
access::rw(Mat<eT>::vec_state) = 2;
|
||||
|
||||
Mat<eT>::operator=(X);
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -649,12 +639,9 @@ Row<eT>::operator=(const BaseCube<eT,T1>& X)
|
||||
template<typename eT>
|
||||
inline
|
||||
Row<eT>::Row(const subview_cube<eT>& X)
|
||||
: Mat<eT>(X, arma_vec_indicator(), 2)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
access::rw(Mat<eT>::vec_state) = 2;
|
||||
|
||||
Mat<eT>::operator=(X);
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1277,6 +1264,20 @@ Row<eT>::end_row(const uword row_num) const
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
Row<eT>::Row(const subview<eT>& X, const bool reuse_mem)
|
||||
: Mat<eT>(X, reuse_mem)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<uword fixed_n_elem>
|
||||
arma_inline
|
||||
@@ -1350,6 +1351,10 @@ Row<eT>::fixed<fixed_n_elem>::fixed(const fill::fill_class<fill_type>&)
|
||||
if(is_same_type<fill_type, fill::fill_eye >::yes) { Mat<eT>::eye(); }
|
||||
if(is_same_type<fill_type, fill::fill_randu>::yes) { Mat<eT>::randu(); }
|
||||
if(is_same_type<fill_type, fill::fill_randn>::yes) { Mat<eT>::randn(); }
|
||||
|
||||
if(is_same_type<fill_type, fill::fill_nan >::yes) { (*this).fill( priv::Datum_helper::nan <eT>() ); }
|
||||
if(is_same_type<fill_type, fill::fill_pos_inf>::yes) { (*this).fill( priv::Datum_helper::pos_inf<eT>() ); }
|
||||
if(is_same_type<fill_type, fill::fill_neg_inf>::yes) { (*this).fill( priv::Datum_helper::neg_inf<eT>() ); }
|
||||
}
|
||||
|
||||
|
||||
@@ -1872,6 +1877,10 @@ Row<eT>::fixed<fixed_n_elem>::ones()
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
Row<eT>::Row(const arma_fixed_indicator&, const uword in_n_elem, const eT* in_mem)
|
||||
|
||||
@@ -52,8 +52,6 @@ struct SpBase
|
||||
{
|
||||
arma_inline const derived& get_ref() const;
|
||||
|
||||
arma_inline bool is_alias(const SpMat<elem_type>& X) const;
|
||||
|
||||
arma_warn_unused inline const SpOp<derived,spop_htrans> t() const; //!< Hermitian transpose
|
||||
arma_warn_unused inline const SpOp<derived,spop_htrans> ht() const; //!< Hermitian transpose
|
||||
arma_warn_unused inline const SpOp<derived,spop_strans> st() const; //!< simple transpose
|
||||
|
||||
@@ -31,16 +31,6 @@ SpBase<elem_type,derived>::get_ref() const
|
||||
|
||||
|
||||
|
||||
template<typename elem_type, typename derived>
|
||||
arma_inline
|
||||
bool
|
||||
SpBase<elem_type,derived>::is_alias(const SpMat<elem_type>& X) const
|
||||
{
|
||||
return (*this).get_ref().is_alias(X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename elem_type, typename derived>
|
||||
inline
|
||||
const SpOp<derived, spop_htrans>
|
||||
@@ -527,7 +517,7 @@ SpBase<elem_type,derived>::is_zero(const typename get_pod_type<elem_type>::resul
|
||||
|
||||
typedef typename get_pod_type<elem_type>::result T;
|
||||
|
||||
arma_conform_check( (tol < T(0)), "is_zero(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_zero(): parameter 'tol' must be >= 0" );
|
||||
|
||||
const SpProxy<derived> P( (*this).get_ref() );
|
||||
|
||||
@@ -554,8 +544,8 @@ SpBase<elem_type,derived>::is_zero(const typename get_pod_type<elem_type>::resul
|
||||
const T val_real = access::tmp_real(val);
|
||||
const T val_imag = access::tmp_imag(val);
|
||||
|
||||
if(eop_aux::arma_abs(val_real) > tol) { return false; }
|
||||
if(eop_aux::arma_abs(val_imag) > tol) { return false; }
|
||||
if( (eop_aux::arma_abs(val_real) <= tol) == false ) { return false; }
|
||||
if( (eop_aux::arma_abs(val_imag) <= tol) == false ) { return false; }
|
||||
|
||||
++it;
|
||||
}
|
||||
@@ -564,7 +554,7 @@ SpBase<elem_type,derived>::is_zero(const typename get_pod_type<elem_type>::resul
|
||||
{
|
||||
while(it != it_end)
|
||||
{
|
||||
if(eop_aux::arma_abs(*it) > tol) { return false; }
|
||||
if( (eop_aux::arma_abs(*it) <= tol) == false ) { return false; }
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ struct SpGlue : public SpBase< typename T1::elem_type, SpGlue<T1, T2, spglue_typ
|
||||
inline SpGlue(const T1& in_A, const T2& in_B, const elem_type in_aux);
|
||||
inline ~SpGlue();
|
||||
|
||||
arma_inline bool is_alias(const SpMat<elem_type>& X) const;
|
||||
template<typename eT2>
|
||||
arma_inline bool is_alias(const SpMat<eT2>& X) const;
|
||||
|
||||
const T1& A; //!< first operand; must be derived from SpBase
|
||||
const T2& B; //!< second operand; must be derived from SpBase
|
||||
|
||||
@@ -54,9 +54,10 @@ SpGlue<T1,T2,spglue_type>::~SpGlue()
|
||||
|
||||
|
||||
template<typename T1, typename T2, typename spglue_type>
|
||||
template<typename eT2>
|
||||
arma_inline
|
||||
bool
|
||||
SpGlue<T1,T2,spglue_type>::is_alias(const SpMat<typename T1::elem_type>& X) const
|
||||
SpGlue<T1,T2,spglue_type>::is_alias(const SpMat<eT2>& X) const
|
||||
{
|
||||
return (A.is_alias(X) || B.is_alias(X));
|
||||
}
|
||||
|
||||
@@ -647,7 +647,8 @@ class SpMat : public SpBase< eT, SpMat<eT> >
|
||||
template<typename eT2, typename T1, typename Functor> inline void init_xform_mt(const SpBase<eT2,T1>& x, const Functor& func);
|
||||
|
||||
//! don't use this unless you're writing internal Armadillo code
|
||||
arma_inline bool is_alias(const SpMat<eT>& X) const;
|
||||
template<typename eT2>
|
||||
arma_inline bool is_alias(const SpMat<eT2>& X) const;
|
||||
|
||||
|
||||
protected:
|
||||
@@ -741,6 +742,10 @@ class SpMat_aux
|
||||
|
||||
|
||||
|
||||
template<typename eT> class SpMat_noalias : public SpMat<eT> {};
|
||||
|
||||
|
||||
|
||||
#define ARMA_HAS_SPMAT
|
||||
|
||||
|
||||
|
||||
@@ -688,15 +688,22 @@ SpMat<eT>::operator=(const SpMat<eT>& x)
|
||||
template<typename eT>
|
||||
inline
|
||||
SpMat<eT>&
|
||||
SpMat<eT>::operator+=(const SpMat<eT>& x)
|
||||
SpMat<eT>::operator+=(const SpMat<eT>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
sync_csc();
|
||||
|
||||
SpMat<eT> out = (*this) + x;
|
||||
|
||||
steal_mem(out);
|
||||
if(X.n_nonzero == 0)
|
||||
{
|
||||
arma_conform_assert_same_size(n_rows, n_cols, X.n_rows, X.n_cols, "addition");
|
||||
}
|
||||
else
|
||||
{
|
||||
SpMat<eT> tmp = (*this) + X;
|
||||
|
||||
steal_mem(tmp);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -706,15 +713,22 @@ SpMat<eT>::operator+=(const SpMat<eT>& x)
|
||||
template<typename eT>
|
||||
inline
|
||||
SpMat<eT>&
|
||||
SpMat<eT>::operator-=(const SpMat<eT>& x)
|
||||
SpMat<eT>::operator-=(const SpMat<eT>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
sync_csc();
|
||||
|
||||
SpMat<eT> out = (*this) - x;
|
||||
|
||||
steal_mem(out);
|
||||
if(X.n_nonzero == 0)
|
||||
{
|
||||
arma_conform_assert_same_size(n_rows, n_cols, X.n_rows, X.n_cols, "subtraction");
|
||||
}
|
||||
else
|
||||
{
|
||||
SpMat<eT> tmp = (*this) - X;
|
||||
|
||||
steal_mem(tmp);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -724,15 +738,15 @@ SpMat<eT>::operator-=(const SpMat<eT>& x)
|
||||
template<typename eT>
|
||||
inline
|
||||
SpMat<eT>&
|
||||
SpMat<eT>::operator*=(const SpMat<eT>& y)
|
||||
SpMat<eT>::operator*=(const SpMat<eT>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
sync_csc();
|
||||
|
||||
SpMat<eT> z = (*this) * y;
|
||||
SpMat<eT> tmp = (*this) * X;
|
||||
|
||||
steal_mem(z);
|
||||
steal_mem(tmp);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -743,15 +757,24 @@ SpMat<eT>::operator*=(const SpMat<eT>& y)
|
||||
template<typename eT>
|
||||
inline
|
||||
SpMat<eT>&
|
||||
SpMat<eT>::operator%=(const SpMat<eT>& y)
|
||||
SpMat<eT>::operator%=(const SpMat<eT>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
sync_csc();
|
||||
|
||||
SpMat<eT> z = (*this) % y;
|
||||
|
||||
steal_mem(z);
|
||||
if(X.n_nonzero == 0)
|
||||
{
|
||||
arma_conform_assert_same_size(n_rows, n_cols, X.n_rows, X.n_cols, "element-wise multiplication");
|
||||
|
||||
(*this).zeros();
|
||||
}
|
||||
else
|
||||
{
|
||||
SpMat<eT> tmp = (*this) % X;
|
||||
|
||||
steal_mem(tmp);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -1338,9 +1361,16 @@ SpMat<eT>::operator+=(const SpSubview<eT>& X)
|
||||
|
||||
sync_csc();
|
||||
|
||||
SpMat<eT> tmp = (*this) + X;
|
||||
|
||||
steal_mem(tmp);
|
||||
if(X.n_nonzero == 0)
|
||||
{
|
||||
arma_conform_assert_same_size(n_rows, n_cols, X.n_rows, X.n_cols, "addition");
|
||||
}
|
||||
else
|
||||
{
|
||||
SpMat<eT> tmp = (*this) + X;
|
||||
|
||||
steal_mem(tmp);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -1356,64 +1386,82 @@ SpMat<eT>::operator-=(const SpSubview<eT>& X)
|
||||
|
||||
sync_csc();
|
||||
|
||||
SpMat<eT> tmp = (*this) - X;
|
||||
|
||||
steal_mem(tmp);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
SpMat<eT>&
|
||||
SpMat<eT>::operator*=(const SpSubview<eT>& y)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
sync_csc();
|
||||
|
||||
SpMat<eT> z = (*this) * y;
|
||||
|
||||
steal_mem(z);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
SpMat<eT>&
|
||||
SpMat<eT>::operator%=(const SpSubview<eT>& x)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
sync_csc();
|
||||
|
||||
SpMat<eT> tmp = (*this) % x;
|
||||
|
||||
steal_mem(tmp);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
SpMat<eT>&
|
||||
SpMat<eT>::operator/=(const SpSubview<eT>& x)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
arma_conform_assert_same_size(n_rows, n_cols, x.n_rows, x.n_cols, "element-wise division");
|
||||
|
||||
// There is no pretty way to do this.
|
||||
for(uword elem = 0; elem < n_elem; elem++)
|
||||
if(X.n_nonzero == 0)
|
||||
{
|
||||
at(elem) /= x(elem);
|
||||
arma_conform_assert_same_size(n_rows, n_cols, X.n_rows, X.n_cols, "subtraction");
|
||||
}
|
||||
else
|
||||
{
|
||||
SpMat<eT> tmp = (*this) - X;
|
||||
|
||||
steal_mem(tmp);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
SpMat<eT>&
|
||||
SpMat<eT>::operator*=(const SpSubview<eT>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
sync_csc();
|
||||
|
||||
SpMat<eT> tmp = (*this) * X;
|
||||
|
||||
steal_mem(tmp);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
SpMat<eT>&
|
||||
SpMat<eT>::operator%=(const SpSubview<eT>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
sync_csc();
|
||||
|
||||
if(X.n_nonzero == 0)
|
||||
{
|
||||
arma_conform_assert_same_size(n_rows, n_cols, X.n_rows, X.n_cols, "element-wise multiplication");
|
||||
|
||||
(*this).zeros();
|
||||
}
|
||||
else
|
||||
{
|
||||
SpMat<eT> tmp = (*this) % X;
|
||||
|
||||
steal_mem(tmp);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
SpMat<eT>&
|
||||
SpMat<eT>::operator/=(const SpSubview<eT>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
// NOTE: use of this function is not advised; it is implemented only for completeness
|
||||
|
||||
arma_conform_assert_same_size(n_rows, n_cols, X.n_rows, X.n_cols, "element-wise division");
|
||||
|
||||
for(uword c = 0; c < n_cols; ++c)
|
||||
for(uword r = 0; r < n_rows; ++r)
|
||||
{
|
||||
at(r, c) /= X.at(r, c);
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -1507,9 +1555,9 @@ SpMat<eT>::operator*=(const SpSubview_col_list<eT,T1>& X)
|
||||
|
||||
sync_csc();
|
||||
|
||||
SpMat<eT> z = (*this) * X;
|
||||
SpMat<eT> tmp = (*this) * X;
|
||||
|
||||
steal_mem(z);
|
||||
steal_mem(tmp);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -1666,7 +1714,7 @@ SpMat<eT>::SpMat(const SpOp<T1, spop_type>& X)
|
||||
|
||||
arma_type_check(( is_same_type< eT, typename T1::elem_type >::no ));
|
||||
|
||||
spop_type::apply(*this, X);
|
||||
spop_type::apply(static_cast< SpMat_noalias<eT>& >(*this), X);
|
||||
|
||||
sync_csc(); // in case apply() used element accessors
|
||||
invalidate_cache(); // in case apply() modified the CSC representation
|
||||
@@ -1806,7 +1854,7 @@ SpMat<eT>::SpMat(const SpGlue<T1, T2, spglue_type>& X)
|
||||
|
||||
arma_type_check(( is_same_type< eT, typename T1::elem_type >::no ));
|
||||
|
||||
spglue_type::apply(*this, X);
|
||||
spglue_type::apply(static_cast< SpMat_noalias<eT>& >(*this), X);
|
||||
|
||||
sync_csc(); // in case apply() used element accessors
|
||||
invalidate_cache(); // in case apply() modified the CSC representation
|
||||
@@ -3517,7 +3565,7 @@ SpMat<eT>::is_symmetric(const typename get_pod_type<elem_type>::result tol) cons
|
||||
|
||||
if(tol == T(0)) { return (*this).is_symmetric(); }
|
||||
|
||||
arma_conform_check( (tol < T(0)), "is_symmetric(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_symmetric(): parameter 'tol' must be > 0" );
|
||||
|
||||
const SpMat<eT>& A = (*this);
|
||||
|
||||
@@ -3527,8 +3575,12 @@ SpMat<eT>::is_symmetric(const typename get_pod_type<elem_type>::result tol) cons
|
||||
|
||||
if(norm_A == T(0)) { return true; }
|
||||
|
||||
if(arma_isnan(norm_A)) { return false; }
|
||||
|
||||
const T norm_A_Ast = as_scalar( arma::max(sum(abs(A - A.st()), 1), 0) );
|
||||
|
||||
if(arma_isnan(norm_A_Ast)) { return false; }
|
||||
|
||||
return ( (norm_A_Ast / norm_A) <= tol );
|
||||
}
|
||||
|
||||
@@ -3563,7 +3615,7 @@ SpMat<eT>::is_hermitian(const typename get_pod_type<elem_type>::result tol) cons
|
||||
|
||||
if(tol == T(0)) { return (*this).is_hermitian(); }
|
||||
|
||||
arma_conform_check( (tol < T(0)), "is_hermitian(): parameter 'tol' must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "is_hermitian(): parameter 'tol' must be > 0" );
|
||||
|
||||
const SpMat<eT>& A = (*this);
|
||||
|
||||
@@ -3573,8 +3625,12 @@ SpMat<eT>::is_hermitian(const typename get_pod_type<elem_type>::result tol) cons
|
||||
|
||||
if(norm_A == T(0)) { return true; }
|
||||
|
||||
if(arma_isnan(norm_A)) { return false; }
|
||||
|
||||
const T norm_A_At = as_scalar( arma::max(sum(abs(A - A.t()), 1), 0) );
|
||||
|
||||
if(arma_isnan(norm_A_At)) { return false; }
|
||||
|
||||
return ( (norm_A_At / norm_A) <= tol );
|
||||
}
|
||||
|
||||
@@ -4156,12 +4212,12 @@ SpMat<eT>::clamp(const eT min_val, const eT max_val)
|
||||
|
||||
if(is_cx<eT>::no)
|
||||
{
|
||||
arma_conform_check( (access::tmp_real(min_val) > access::tmp_real(max_val)), "SpMat::clamp(): min_val must be less than max_val" );
|
||||
arma_conform_check( ((access::tmp_real(min_val) <= access::tmp_real(max_val)) == false), "SpMat::clamp(): min_val must be less than max_val" );
|
||||
}
|
||||
else
|
||||
{
|
||||
arma_conform_check( (access::tmp_real(min_val) > access::tmp_real(max_val)), "SpMat::clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( (access::tmp_imag(min_val) > access::tmp_imag(max_val)), "SpMat::clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
arma_conform_check( ((access::tmp_real(min_val) <= access::tmp_real(max_val)) == false), "SpMat::clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( ((access::tmp_imag(min_val) <= access::tmp_imag(max_val)) == false), "SpMat::clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
}
|
||||
|
||||
if(n_nonzero == 0) { return *this; }
|
||||
@@ -4341,7 +4397,7 @@ SpMat<eT>::sprandu(const uword in_rows, const uword in_cols, const double densit
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
arma_conform_check( ( (density < double(0)) || (density > double(1)) ), "sprandu(): density must be in the [0,1] interval" );
|
||||
arma_conform_check( ( ((density >= double(0)) == false) || ((density <= double(1)) == false) ), "sprandu(): density must be in the [0,1] interval" );
|
||||
|
||||
const uword new_n_nonzero = uword(density * double(in_rows) * double(in_cols) + 0.5);
|
||||
|
||||
@@ -4418,7 +4474,7 @@ SpMat<eT>::sprandn(const uword in_rows, const uword in_cols, const double densit
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
arma_conform_check( ( (density < double(0)) || (density > double(1)) ), "sprandn(): density must be in the [0,1] interval" );
|
||||
arma_conform_check( ( ((density >= double(0)) == false) || ((density <= double(1)) == false) ), "sprandn(): density must be in the [0,1] interval" );
|
||||
|
||||
const uword new_n_nonzero = uword(density * double(in_rows) * double(in_cols) + 0.5);
|
||||
|
||||
@@ -5959,11 +6015,14 @@ SpMat<eT>::init_xform_mt(const SpBase<eT2,T1>& A, const Functor& func)
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<typename eT2>
|
||||
arma_inline
|
||||
bool
|
||||
SpMat<eT>::is_alias(const SpMat<eT>& X) const
|
||||
SpMat<eT>::is_alias(const SpMat<eT2>& X) const
|
||||
{
|
||||
return (&X == this);
|
||||
arma_debug_sigprint();
|
||||
|
||||
return (is_same_type<eT,eT2>::yes) && (void_ptr(this) == void_ptr(&X));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ struct SpOp : public SpBase< typename T1::elem_type, SpOp<T1, op_type> >
|
||||
inline SpOp(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b);
|
||||
inline ~SpOp();
|
||||
|
||||
arma_inline bool is_alias(const SpMat<elem_type>& X) const;
|
||||
template<typename eT2>
|
||||
arma_inline bool is_alias(const SpMat<eT2>& X) const;
|
||||
|
||||
const T1& m; //!< the operand; must be derived from SpBase
|
||||
elem_type aux; //!< auxiliary data, using the element type as used by T1
|
||||
|
||||
@@ -64,9 +64,10 @@ SpOp<T1, op_type>::~SpOp()
|
||||
|
||||
|
||||
template<typename T1, typename op_type>
|
||||
template<typename eT2>
|
||||
arma_inline
|
||||
bool
|
||||
SpOp<T1, op_type>::is_alias(const SpMat<typename T1::elem_type>& X) const
|
||||
SpOp<T1, op_type>::is_alias(const SpMat<eT2>& X) const
|
||||
{
|
||||
return m.is_alias(X);
|
||||
}
|
||||
|
||||
@@ -321,7 +321,8 @@ class SpSubview : public SpBase< eT, SpSubview<eT> >
|
||||
inline const_row_iterator end_row(const uword row_num) const;
|
||||
|
||||
//! don't use this unless you're writing internal Armadillo code
|
||||
arma_inline bool is_alias(const SpMat<eT>& X) const;
|
||||
template<typename eT2>
|
||||
arma_inline bool is_alias(const SpMat<eT2>& X) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -87,6 +87,8 @@ class SpSubview_col_list : public SpBase< eT, SpSubview_col_list<eT,T1> >
|
||||
inline static void schur_inplace(SpMat<eT>& out, const SpSubview_col_list& in);
|
||||
inline static void div_inplace(SpMat<eT>& out, const SpSubview_col_list& in);
|
||||
|
||||
template<typename eT2>
|
||||
arma_inline bool is_alias(const SpMat<eT2>& X) const;
|
||||
|
||||
friend class SpMat<eT>;
|
||||
};
|
||||
|
||||
@@ -714,4 +714,15 @@ SpSubview_col_list<eT,T1>::div_inplace(SpMat<eT>& out, const SpSubview_col_list&
|
||||
|
||||
|
||||
|
||||
template<typename eT, typename T1>
|
||||
template<typename eT2>
|
||||
arma_inline
|
||||
bool
|
||||
SpSubview_col_list<eT,T1>::is_alias(const SpMat<eT2>& X) const
|
||||
{
|
||||
return m.is_alias(X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
@@ -44,6 +44,8 @@ SpSubview<eT>::SpSubview(const SpMat<eT>& in_m, const uword in_row1, const uword
|
||||
|
||||
m.sync_csc();
|
||||
|
||||
if( (n_elem == 0) || (m.n_nonzero == 0) ) { return; } // (*this).n_nonzero already set to zero
|
||||
|
||||
// count the number of non-zeros in the subview
|
||||
uword count = 0;
|
||||
|
||||
@@ -127,6 +129,8 @@ SpSubview<eT>::operator+=(const eT val)
|
||||
|
||||
tmp.fill(val);
|
||||
|
||||
if(n_nonzero == 0) { return (*this).operator=(tmp); }
|
||||
|
||||
return (*this).operator=( (*this) + tmp );
|
||||
}
|
||||
|
||||
@@ -319,6 +323,15 @@ SpSubview<eT>::operator+=(const Base<eT, T1>& x)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
if(n_nonzero == 0)
|
||||
{
|
||||
const quasi_unwrap<T1> U(x.get_ref());
|
||||
|
||||
arma_conform_assert_same_size(n_rows, n_cols, U.M.n_rows, U.M.n_cols, "addition");
|
||||
|
||||
return (*this).operator=(U.M);
|
||||
}
|
||||
|
||||
return (*this).operator=( (*this) + x.get_ref() );
|
||||
}
|
||||
|
||||
@@ -369,6 +382,8 @@ SpSubview<eT>::operator%=(const Base<eT, T1>& x)
|
||||
|
||||
arma_conform_assert_same_size(sv.n_rows, sv.n_cols, B.n_rows, B.n_cols, "element-wise multiplication");
|
||||
|
||||
if(n_nonzero == 0) { return *this; }
|
||||
|
||||
SpMat<eT>& sv_m = access::rw(sv.m);
|
||||
|
||||
sv_m.sync_csc();
|
||||
@@ -555,6 +570,15 @@ SpSubview<eT>::operator+=(const SpBase<eT, T1>& x)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
if(n_nonzero == 0)
|
||||
{
|
||||
const unwrap_spmat<T1> U(x.get_ref());
|
||||
|
||||
arma_conform_assert_same_size(n_rows, n_cols, U.M.n_rows, U.M.n_cols, "addition");
|
||||
|
||||
return (*this).operator_equ_common(U.M);
|
||||
}
|
||||
|
||||
// TODO: implement dedicated machinery
|
||||
return (*this).operator=( (*this) + x.get_ref() );
|
||||
}
|
||||
@@ -596,6 +620,15 @@ SpSubview<eT>::operator%=(const SpBase<eT, T1>& x)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
if(n_nonzero == 0)
|
||||
{
|
||||
const SpProxy<T1> P(x.get_ref());
|
||||
|
||||
arma_conform_assert_same_size(n_rows, n_cols, P.get_n_rows(), P.get_n_cols(), "element-wise multiplication");
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TODO: implement dedicated machinery
|
||||
return (*this).operator=( (*this) % x.get_ref() );
|
||||
}
|
||||
@@ -648,6 +681,8 @@ SpSubview<eT>::for_each(functor F)
|
||||
m.sync_csc();
|
||||
m.invalidate_cache();
|
||||
|
||||
if(n_nonzero == 0) { return; }
|
||||
|
||||
const uword lstart_row = aux_row1;
|
||||
const uword lend_row = aux_row1 + n_rows;
|
||||
|
||||
@@ -704,6 +739,8 @@ SpSubview<eT>::for_each(functor F) const
|
||||
|
||||
m.sync_csc();
|
||||
|
||||
if(n_nonzero == 0) { return; }
|
||||
|
||||
const uword lstart_row = aux_row1;
|
||||
const uword lend_row = aux_row1 + n_rows;
|
||||
|
||||
@@ -743,6 +780,8 @@ SpSubview<eT>::transform(functor F)
|
||||
m.sync_csc();
|
||||
m.invalidate_cache();
|
||||
|
||||
if(n_nonzero == 0) { return; }
|
||||
|
||||
const uword lstart_row = aux_row1;
|
||||
const uword lend_row = aux_row1 + n_rows;
|
||||
|
||||
@@ -813,6 +852,8 @@ SpSubview<eT>::replace(const eT old_val, const eT new_val)
|
||||
m.sync_csc();
|
||||
m.invalidate_cache();
|
||||
|
||||
if(n_nonzero == 0) { return; }
|
||||
|
||||
const uword lstart_row = aux_row1;
|
||||
const uword lend_row = aux_row1 + n_rows;
|
||||
|
||||
@@ -905,12 +946,12 @@ SpSubview<eT>::clamp(const eT min_val, const eT max_val)
|
||||
|
||||
if(is_cx<eT>::no)
|
||||
{
|
||||
arma_conform_check( (access::tmp_real(min_val) > access::tmp_real(max_val)), "SpSubview::clamp(): min_val must be less than max_val" );
|
||||
arma_conform_check( ((access::tmp_real(min_val) <= access::tmp_real(max_val)) == false), "SpSubview::clamp(): min_val must be less than max_val" );
|
||||
}
|
||||
else
|
||||
{
|
||||
arma_conform_check( (access::tmp_real(min_val) > access::tmp_real(max_val)), "SpSubview::clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( (access::tmp_imag(min_val) > access::tmp_imag(max_val)), "SpSubview::clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
arma_conform_check( ((access::tmp_real(min_val) <= access::tmp_real(max_val)) == false), "SpSubview::clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( ((access::tmp_imag(min_val) <= access::tmp_imag(max_val)) == false), "SpSubview::clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
}
|
||||
|
||||
if((n_elem == 0) || (n_nonzero == 0)) { return; }
|
||||
@@ -1745,9 +1786,10 @@ SpSubview<eT>::end_row(const uword row_num) const
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<typename eT2>
|
||||
arma_inline
|
||||
bool
|
||||
SpSubview<eT>::is_alias(const SpMat<eT>& X) const
|
||||
SpSubview<eT>::is_alias(const SpMat<eT2>& X) const
|
||||
{
|
||||
return m.is_alias(X);
|
||||
}
|
||||
|
||||
@@ -72,6 +72,10 @@ template<typename eT, typename T1> class subview_cube_slices;
|
||||
template<typename eT, typename T1> class SpSubview_col_list;
|
||||
|
||||
|
||||
template<typename eT> class Mat_noalias;
|
||||
template<typename eT> class SpMat_noalias;
|
||||
|
||||
|
||||
struct SizeMat;
|
||||
struct SizeCube;
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
#undef ARMA_USE_THREAD_LOCAL
|
||||
#define ARMA_USE_THREAD_LOCAL
|
||||
|
||||
#undef ARMA_USE_THREAD_UNIQUE_RNG_SEED
|
||||
#define ARMA_USE_THREAD_UNIQUE_RNG_SEED
|
||||
|
||||
#if (defined(ARMA_RNG_ALT) || defined(ARMA_DONT_USE_CXX11_RNG))
|
||||
#undef ARMA_USE_CXX11_RNG
|
||||
#endif
|
||||
@@ -34,6 +37,10 @@
|
||||
#undef ARMA_USE_THREAD_LOCAL
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_USE_THREAD_UNIQUE_RNG_SEED)
|
||||
#undef ARMA_USE_THREAD_UNIQUE_RNG_SEED
|
||||
#endif
|
||||
|
||||
|
||||
// NOTE: ARMA_WARMUP_PRODUCER enables a workaround
|
||||
// NOTE: for thread_local issue on macOS 11 and/or AppleClang 12.0
|
||||
@@ -116,6 +123,7 @@ struct arma_rng
|
||||
template<typename eT> struct randu;
|
||||
template<typename eT> struct randn;
|
||||
template<typename eT> struct randg;
|
||||
template<typename eT> struct rande;
|
||||
};
|
||||
|
||||
|
||||
@@ -128,24 +136,42 @@ arma_rng::get_producer()
|
||||
{
|
||||
#if defined(ARMA_USE_THREAD_LOCAL)
|
||||
|
||||
// use a thread-safe RNG, with each thread having its own unique starting seed
|
||||
// thread-safe RNG
|
||||
|
||||
static std::atomic<std::size_t> mt19937_64_producer_counter(0);
|
||||
|
||||
static thread_local std::mt19937_64 mt19937_64_producer( std::mt19937_64::default_seed + mt19937_64_producer_counter++ );
|
||||
|
||||
arma_rng::warmup_producer(mt19937_64_producer);
|
||||
#if defined(ARMA_USE_THREAD_UNIQUE_RNG_SEED)
|
||||
|
||||
// each thread has unique starting seed
|
||||
|
||||
#if defined(ARMA_USE_OPENMP)
|
||||
|
||||
static thread_local std::mt19937_64 mt19937_64_producer( std::mt19937_64::default_seed + arma_rng::seed_type(omp_get_thread_num()) );
|
||||
|
||||
#else
|
||||
|
||||
static std::atomic<std::size_t> mt19937_64_producer_counter(0);
|
||||
|
||||
static thread_local std::mt19937_64 mt19937_64_producer( std::mt19937_64::default_seed + mt19937_64_producer_counter++ );
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
// each thread has the same starting seed
|
||||
|
||||
static thread_local std::mt19937_64 mt19937_64_producer( std::mt19937_64::default_seed );
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
// use a plain RNG in case we don't have thread_local
|
||||
// plain RNG in case we don't have thread_local
|
||||
|
||||
static std::mt19937_64 mt19937_64_producer( std::mt19937_64::default_seed );
|
||||
|
||||
arma_rng::warmup_producer(mt19937_64_producer);
|
||||
|
||||
#endif
|
||||
|
||||
arma_rng::warmup_producer(mt19937_64_producer);
|
||||
|
||||
return mt19937_64_producer;
|
||||
}
|
||||
|
||||
@@ -225,9 +251,45 @@ arma_rng::set_seed(const arma_rng::seed_type val)
|
||||
}
|
||||
#elif defined(ARMA_USE_CXX11_RNG)
|
||||
{
|
||||
arma_rng::lock_producer();
|
||||
arma_rng::get_producer().seed(val);
|
||||
arma_rng::unlock_producer();
|
||||
#if defined(ARMA_USE_OPENMP) && defined(ARMA_USE_THREAD_LOCAL)
|
||||
{
|
||||
arma_rng::lock_producer();
|
||||
|
||||
#if defined(ARMA_USE_THREAD_UNIQUE_RNG_SEED)
|
||||
constexpr bool thread_unique_rng_seed = true;
|
||||
#else
|
||||
constexpr bool thread_unique_rng_seed = false;
|
||||
#endif
|
||||
|
||||
// if we're already in a parallel region, assume the user is setting the seed for each thread
|
||||
|
||||
if( (thread_unique_rng_seed == false) || bool(omp_in_parallel()) )
|
||||
{
|
||||
arma_rng::get_producer().seed(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int n_threads = int( (std::max)( int(1), int(omp_get_max_threads()) ) );
|
||||
|
||||
#pragma omp parallel for ordered schedule(static) num_threads(n_threads)
|
||||
for(int t=0; t < n_threads; ++t)
|
||||
{
|
||||
#pragma omp ordered
|
||||
{
|
||||
arma_rng::get_producer().seed(val + arma_rng::seed_type(omp_get_thread_num()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
arma_rng::unlock_producer();
|
||||
}
|
||||
#else
|
||||
{
|
||||
arma_rng::lock_producer();
|
||||
arma_rng::get_producer().seed(val);
|
||||
arma_rng::unlock_producer();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
{
|
||||
@@ -1029,4 +1091,45 @@ struct arma_rng::randg
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
struct arma_rng::rande
|
||||
{
|
||||
inline
|
||||
static
|
||||
void
|
||||
fill(eT* mem, const uword N, const double lambda)
|
||||
{
|
||||
#if defined(ARMA_USE_CXX11_RNG)
|
||||
{
|
||||
std::exponential_distribution<double> local_e_distr(lambda);
|
||||
|
||||
std::mt19937_64& producer = arma_rng::get_producer();
|
||||
|
||||
arma_rng::lock_producer();
|
||||
|
||||
for(uword i=0; i<N; ++i) { mem[i] = eT(local_e_distr(producer)); }
|
||||
|
||||
arma_rng::unlock_producer();
|
||||
}
|
||||
#else
|
||||
{
|
||||
typedef typename std::mt19937_64::result_type local_seed_type;
|
||||
|
||||
std::mt19937_64 local_engine;
|
||||
std::exponential_distribution<double> local_e_distr(lambda);
|
||||
|
||||
local_engine.seed( local_seed_type(arma_rng::randi<local_seed_type>()) );
|
||||
|
||||
for(uword i=0; i<N; ++i) { mem[i] = eT(local_e_distr(local_engine)); }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
|
||||
#define ARMA_VERSION_MAJOR 15
|
||||
#define ARMA_VERSION_MINOR 0
|
||||
#define ARMA_VERSION_PATCH 1
|
||||
#define ARMA_VERSION_NAME "Medium Roast"
|
||||
#define ARMA_VERSION_MINOR 2
|
||||
#define ARMA_VERSION_PATCH 8
|
||||
#define ARMA_VERSION_NAME "Medium Roast Deluxe"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -994,7 +994,7 @@ arrayops::is_zero(const eT* mem, const uword n_elem, const eT abs_limit, const t
|
||||
{
|
||||
for(uword i=0; i<n_elem; ++i)
|
||||
{
|
||||
if(eop_aux::arma_abs(mem[i]) > abs_limit) { return false; }
|
||||
if( (eop_aux::arma_abs(mem[i]) <= abs_limit) == false ) { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1028,8 +1028,8 @@ arrayops::is_zero(const std::complex<T>* mem, const uword n_elem, const T abs_li
|
||||
{
|
||||
const eT& val = mem[i];
|
||||
|
||||
if(std::abs(std::real(val)) > abs_limit) { return false; }
|
||||
if(std::abs(std::imag(val)) > abs_limit) { return false; }
|
||||
if( (std::abs(std::real(val)) <= abs_limit) == false ) { return false; }
|
||||
if( (std::abs(std::imag(val)) <= abs_limit) == false ) { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -330,18 +330,6 @@
|
||||
#undef ARMA_OPTIMISE_POWEXPR
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_CHECK_CONFORMANCE)
|
||||
#if defined(ARMA_CHECK_CONFORMANCE) && (ARMA_WARN_LEVEL >= 2)
|
||||
#pragma message ("WARNING: conformance checks disabled")
|
||||
#endif
|
||||
|
||||
#undef ARMA_CHECK_CONFORMANCE
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_CHECK_NONFINITE)
|
||||
#undef ARMA_CHECK_NONFINITE
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_NO_DEBUG)
|
||||
#undef ARMA_DEBUG
|
||||
#undef ARMA_EXTRA_DEBUG
|
||||
@@ -361,6 +349,18 @@
|
||||
#define ARMA_WARN_LEVEL 3
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_CHECK_CONFORMANCE)
|
||||
#if defined(ARMA_CHECK_CONFORMANCE) && (ARMA_WARN_LEVEL >= 2)
|
||||
#pragma message ("WARNING: conformance checks disabled")
|
||||
#endif
|
||||
|
||||
#undef ARMA_CHECK_CONFORMANCE
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_CHECK_NONFINITE)
|
||||
#undef ARMA_CHECK_NONFINITE
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_PRINT_EXCEPTIONS)
|
||||
#undef ARMA_PRINT_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
@@ -330,18 +330,6 @@
|
||||
#undef ARMA_OPTIMISE_POWEXPR
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_CHECK_CONFORMANCE)
|
||||
#if defined(ARMA_CHECK_CONFORMANCE) && (ARMA_WARN_LEVEL >= 2)
|
||||
#pragma message ("WARNING: conformance checks disabled")
|
||||
#endif
|
||||
|
||||
#undef ARMA_CHECK_CONFORMANCE
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_CHECK_NONFINITE)
|
||||
#undef ARMA_CHECK_NONFINITE
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_NO_DEBUG)
|
||||
#undef ARMA_DEBUG
|
||||
#undef ARMA_EXTRA_DEBUG
|
||||
@@ -361,6 +349,18 @@
|
||||
#define ARMA_WARN_LEVEL 3
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_CHECK_CONFORMANCE)
|
||||
#if defined(ARMA_CHECK_CONFORMANCE) && (ARMA_WARN_LEVEL >= 2)
|
||||
#pragma message ("WARNING: conformance checks disabled")
|
||||
#endif
|
||||
|
||||
#undef ARMA_CHECK_CONFORMANCE
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_CHECK_NONFINITE)
|
||||
#undef ARMA_CHECK_NONFINITE
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_DONT_PRINT_EXCEPTIONS)
|
||||
#undef ARMA_PRINT_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace priv
|
||||
{
|
||||
template<typename eT>
|
||||
static
|
||||
constexpr
|
||||
typename arma_real_only<eT>::result
|
||||
nan(typename arma_real_only<eT>::result* junk = nullptr)
|
||||
{
|
||||
@@ -37,6 +38,7 @@ namespace priv
|
||||
|
||||
template<typename eT>
|
||||
static
|
||||
constexpr
|
||||
typename arma_cx_only<eT>::result
|
||||
nan(typename arma_cx_only<eT>::result* junk = nullptr)
|
||||
{
|
||||
@@ -50,6 +52,7 @@ namespace priv
|
||||
|
||||
template<typename eT>
|
||||
static
|
||||
constexpr
|
||||
typename arma_integral_only<eT>::result
|
||||
nan(typename arma_integral_only<eT>::result* junk = nullptr)
|
||||
{
|
||||
@@ -59,10 +62,14 @@ namespace priv
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
template<typename eT>
|
||||
static
|
||||
constexpr
|
||||
typename arma_real_only<eT>::result
|
||||
inf(typename arma_real_only<eT>::result* junk = nullptr)
|
||||
pos_inf(typename arma_real_only<eT>::result* junk = nullptr)
|
||||
{
|
||||
arma_ignore(junk);
|
||||
|
||||
@@ -72,26 +79,70 @@ namespace priv
|
||||
|
||||
template<typename eT>
|
||||
static
|
||||
constexpr
|
||||
typename arma_cx_only<eT>::result
|
||||
inf(typename arma_cx_only<eT>::result* junk = nullptr)
|
||||
pos_inf(typename arma_cx_only<eT>::result* junk = nullptr)
|
||||
{
|
||||
arma_ignore(junk);
|
||||
|
||||
typedef typename get_pod_type<eT>::result T;
|
||||
|
||||
return eT( Datum_helper::inf<T>(), Datum_helper::inf<T>() );
|
||||
return eT( Datum_helper::pos_inf<T>(), Datum_helper::pos_inf<T>() );
|
||||
}
|
||||
|
||||
|
||||
template<typename eT>
|
||||
static
|
||||
constexpr
|
||||
typename arma_integral_only<eT>::result
|
||||
inf(typename arma_integral_only<eT>::result* junk = nullptr)
|
||||
pos_inf(typename arma_integral_only<eT>::result* junk = nullptr)
|
||||
{
|
||||
arma_ignore(junk);
|
||||
|
||||
return std::numeric_limits<eT>::max();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
template<typename eT>
|
||||
static
|
||||
constexpr
|
||||
typename arma_real_only<eT>::result
|
||||
neg_inf(typename arma_real_only<eT>::result* junk = nullptr)
|
||||
{
|
||||
arma_ignore(junk);
|
||||
|
||||
return (std::numeric_limits<eT>::has_infinity) ? eT(-std::numeric_limits<eT>::infinity()) : eT(std::numeric_limits<eT>::lowest());
|
||||
}
|
||||
|
||||
|
||||
template<typename eT>
|
||||
static
|
||||
constexpr
|
||||
typename arma_cx_only<eT>::result
|
||||
neg_inf(typename arma_cx_only<eT>::result* junk = nullptr)
|
||||
{
|
||||
arma_ignore(junk);
|
||||
|
||||
typedef typename get_pod_type<eT>::result T;
|
||||
|
||||
return eT( Datum_helper::neg_inf<T>(), Datum_helper::neg_inf<T>() );
|
||||
}
|
||||
|
||||
|
||||
template<typename eT>
|
||||
static
|
||||
constexpr
|
||||
typename arma_integral_only<eT>::result
|
||||
neg_inf(typename arma_integral_only<eT>::result* junk = nullptr)
|
||||
{
|
||||
arma_ignore(junk);
|
||||
|
||||
return std::numeric_limits<eT>::lowest();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -119,7 +170,9 @@ struct Datum
|
||||
static const eT log_min; //!< log of the minimum representable value
|
||||
static const eT log_max; //!< log of the maximum representable value
|
||||
static const eT nan; //!< "not a number"
|
||||
static const eT inf; //!< infinity
|
||||
static const eT inf; //!< positive infinity
|
||||
static const eT pos_inf; //!< positive infinity
|
||||
static const eT neg_inf; //!< negative infinity
|
||||
|
||||
//
|
||||
|
||||
@@ -170,7 +223,9 @@ template<typename eT> const eT Datum<eT>::eps = std::numeric_limits<eT>:
|
||||
template<typename eT> const eT Datum<eT>::log_min = std::log(std::numeric_limits<eT>::min());
|
||||
template<typename eT> const eT Datum<eT>::log_max = std::log(std::numeric_limits<eT>::max());
|
||||
template<typename eT> const eT Datum<eT>::nan = priv::Datum_helper::nan<eT>();
|
||||
template<typename eT> const eT Datum<eT>::inf = priv::Datum_helper::inf<eT>();
|
||||
template<typename eT> const eT Datum<eT>::inf = priv::Datum_helper::pos_inf<eT>();
|
||||
template<typename eT> const eT Datum<eT>::pos_inf = priv::Datum_helper::pos_inf<eT>();
|
||||
template<typename eT> const eT Datum<eT>::neg_inf = priv::Datum_helper::neg_inf<eT>();
|
||||
|
||||
template<typename eT> const eT Datum<eT>::m_u = eT(1.66053906892e-27);
|
||||
template<typename eT> const eT Datum<eT>::N_A = eT(6.02214076e23);
|
||||
|
||||
@@ -134,15 +134,25 @@ diagview<eT>::operator+=(const eT val)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
|
||||
diagview<eT>& d = *this;
|
||||
|
||||
const uword t_n_elem = n_elem;
|
||||
const uword t_row_offset = row_offset;
|
||||
const uword t_col_offset = col_offset;
|
||||
Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
|
||||
|
||||
for(uword ii=0; ii < t_n_elem; ++ii)
|
||||
const uword d_n_elem = d.n_elem;
|
||||
const uword d_row_offset = d.row_offset;
|
||||
const uword d_col_offset = d.col_offset;
|
||||
|
||||
uword ii,jj;
|
||||
|
||||
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
|
||||
{
|
||||
t_m.at( ii + t_row_offset, ii + t_col_offset) += val;
|
||||
d_m.at( ii + d_row_offset, ii + d_col_offset) += val;
|
||||
d_m.at( jj + d_row_offset, jj + d_col_offset) += val;
|
||||
}
|
||||
|
||||
if(ii < d_n_elem)
|
||||
{
|
||||
d_m.at( ii + d_row_offset, ii + d_col_offset) += val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,15 +165,25 @@ diagview<eT>::operator-=(const eT val)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
|
||||
diagview<eT>& d = *this;
|
||||
|
||||
const uword t_n_elem = n_elem;
|
||||
const uword t_row_offset = row_offset;
|
||||
const uword t_col_offset = col_offset;
|
||||
Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
|
||||
|
||||
for(uword ii=0; ii < t_n_elem; ++ii)
|
||||
const uword d_n_elem = d.n_elem;
|
||||
const uword d_row_offset = d.row_offset;
|
||||
const uword d_col_offset = d.col_offset;
|
||||
|
||||
uword ii,jj;
|
||||
|
||||
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
|
||||
{
|
||||
t_m.at( ii + t_row_offset, ii + t_col_offset) -= val;
|
||||
d_m.at( ii + d_row_offset, ii + d_col_offset) -= val;
|
||||
d_m.at( jj + d_row_offset, jj + d_col_offset) -= val;
|
||||
}
|
||||
|
||||
if(ii < d_n_elem)
|
||||
{
|
||||
d_m.at( ii + d_row_offset, ii + d_col_offset) -= val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,15 +196,25 @@ diagview<eT>::operator*=(const eT val)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
|
||||
diagview<eT>& d = *this;
|
||||
|
||||
const uword t_n_elem = n_elem;
|
||||
const uword t_row_offset = row_offset;
|
||||
const uword t_col_offset = col_offset;
|
||||
Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
|
||||
|
||||
for(uword ii=0; ii < t_n_elem; ++ii)
|
||||
const uword d_n_elem = d.n_elem;
|
||||
const uword d_row_offset = d.row_offset;
|
||||
const uword d_col_offset = d.col_offset;
|
||||
|
||||
uword ii,jj;
|
||||
|
||||
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
|
||||
{
|
||||
t_m.at( ii + t_row_offset, ii + t_col_offset) *= val;
|
||||
d_m.at( ii + d_row_offset, ii + d_col_offset) *= val;
|
||||
d_m.at( jj + d_row_offset, jj + d_col_offset) *= val;
|
||||
}
|
||||
|
||||
if(ii < d_n_elem)
|
||||
{
|
||||
d_m.at( ii + d_row_offset, ii + d_col_offset) *= val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,15 +227,25 @@ diagview<eT>::operator/=(const eT val)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<eT>& t_m = const_cast< Mat<eT>& >(m);
|
||||
diagview<eT>& d = *this;
|
||||
|
||||
const uword t_n_elem = n_elem;
|
||||
const uword t_row_offset = row_offset;
|
||||
const uword t_col_offset = col_offset;
|
||||
Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
|
||||
|
||||
for(uword ii=0; ii < t_n_elem; ++ii)
|
||||
const uword d_n_elem = d.n_elem;
|
||||
const uword d_row_offset = d.row_offset;
|
||||
const uword d_col_offset = d.col_offset;
|
||||
|
||||
uword ii,jj;
|
||||
|
||||
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
|
||||
{
|
||||
t_m.at( ii + t_row_offset, ii + t_col_offset) /= val;
|
||||
d_m.at( ii + d_row_offset, ii + d_col_offset) /= val;
|
||||
d_m.at( jj + d_row_offset, jj + d_col_offset) /= val;
|
||||
}
|
||||
|
||||
if(ii < d_n_elem)
|
||||
{
|
||||
d_m.at( ii + d_row_offset, ii + d_col_offset) /= val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +276,12 @@ diagview<eT>::operator= (const Base<eT,T1>& o)
|
||||
"diagview: given object has incompatible size"
|
||||
);
|
||||
|
||||
constexpr bool is_gen_zeros = (is_same_type< T1, Gen<Mat<eT>, gen_zeros> >::yes) || (is_same_type< T1, Gen<Col<eT>, gen_zeros> >::yes);
|
||||
constexpr bool is_gen_ones = (is_same_type< T1, Gen<Mat<eT>, gen_ones > >::yes) || (is_same_type< T1, Gen<Col<eT>, gen_ones > >::yes);
|
||||
|
||||
if(is_gen_zeros) { d.zeros(); return; }
|
||||
if(is_gen_ones ) { d.ones(); return; }
|
||||
|
||||
const bool have_alias = P.is_alias(d_m);
|
||||
|
||||
if(have_alias) { arma_debug_print("aliasing detected"); }
|
||||
@@ -948,13 +994,25 @@ diagview<eT>::fill(const eT val)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<eT>& x = const_cast< Mat<eT>& >(m);
|
||||
diagview<eT>& d = *this;
|
||||
|
||||
const uword local_n_elem = n_elem;
|
||||
Mat<eT>& d_m = const_cast< Mat<eT>& >(d.m);
|
||||
|
||||
for(uword ii=0; ii < local_n_elem; ++ii)
|
||||
const uword d_n_elem = d.n_elem;
|
||||
const uword d_row_offset = d.row_offset;
|
||||
const uword d_col_offset = d.col_offset;
|
||||
|
||||
uword ii,jj;
|
||||
|
||||
for(ii=0, jj=1; jj < d_n_elem; ii+=2, jj+=2)
|
||||
{
|
||||
x.at(ii+row_offset, ii+col_offset) = val;
|
||||
d_m.at( ii + d_row_offset, ii + d_col_offset) = val;
|
||||
d_m.at( jj + d_row_offset, jj + d_col_offset) = val;
|
||||
}
|
||||
|
||||
if(ii < d_n_elem)
|
||||
{
|
||||
d_m.at( ii + d_row_offset, ii + d_col_offset) = val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,9 @@ struct diskio
|
||||
|
||||
template<typename eT> inline static std::streamsize prepare_stream(std::ostream& f);
|
||||
|
||||
template<typename eT> inline static constexpr eT real_as_int_lower_limit();
|
||||
template<typename eT> inline static constexpr eT real_as_int_upper_limit();
|
||||
|
||||
|
||||
//
|
||||
// matrix saving
|
||||
|
||||
@@ -373,29 +373,37 @@ inline
|
||||
std::string
|
||||
diskio::gen_tmp_name(const std::string& x)
|
||||
{
|
||||
union { uword val; void* ptr; } u;
|
||||
arma_debug_sigprint();
|
||||
|
||||
u.val = uword(0);
|
||||
u.ptr = const_cast<std::string*>(&x);
|
||||
const char* charlist = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
const char* suffix1 = ".!";
|
||||
|
||||
const u16 a = u16( (u.val >> 8) & 0xFFFF );
|
||||
const u16 b = u16( (std::clock()) & 0xFFFF );
|
||||
constexpr std::size_t charlist_length = 36;
|
||||
constexpr std::size_t suffix1_length = 2;
|
||||
constexpr std::size_t suffix2_length = 6;
|
||||
|
||||
std::ostringstream ss;
|
||||
typedef typename std::minstd_rand::result_type local_seed_type;
|
||||
|
||||
ss << x << ".tmp_";
|
||||
std::minstd_rand local_engine;
|
||||
std::uniform_int_distribution<std::size_t> local_distr(0, charlist_length - 1);
|
||||
|
||||
ss.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||
local_engine.seed( static_cast<local_seed_type>( (std::clock()) & 0xFFFF ) );
|
||||
|
||||
ss.width(4);
|
||||
ss.fill('0');
|
||||
ss << a;
|
||||
const std::size_t x_length = x.length();
|
||||
|
||||
ss.width(4);
|
||||
ss.fill('0');
|
||||
ss << b;
|
||||
std::string out(x_length + suffix1_length + suffix2_length, '0'); // create string filled with char '0' (not 0)
|
||||
|
||||
return ss.str();
|
||||
std::size_t count = 0;
|
||||
|
||||
for(; count < x_length; ++count) { out[count] = x[count]; }
|
||||
|
||||
for(std::size_t i=0; i < suffix1_length; ++i, ++count) { out[count] = suffix1[i]; }
|
||||
|
||||
local_distr(local_engine); // ignore first random number
|
||||
|
||||
for(std::size_t i=0; i < suffix2_length; ++i, ++count) { out[count] = charlist[ local_distr(local_engine)]; }
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -688,7 +696,32 @@ diskio::prepare_stream(std::ostream& f)
|
||||
|
||||
return cell_width;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
constexpr
|
||||
eT
|
||||
diskio::real_as_int_lower_limit()
|
||||
{
|
||||
constexpr eT eT_int_accuracy_lower_limit = -( (is_fp16<eT>::value) ? eT(0x800) : ( (is_float<eT>::value) ? eT(0x1000000) : eT(0x20000000000000) ) );
|
||||
|
||||
return (std::max)( eT(std::numeric_limits<int>::lowest()), eT_int_accuracy_lower_limit );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
constexpr
|
||||
eT
|
||||
diskio::real_as_int_upper_limit()
|
||||
{
|
||||
constexpr eT eT_int_accuracy_upper_limit = (is_fp16<eT>::value) ? eT(0x800) : ( (is_float<eT>::value) ? eT(0x1000000) : eT(0x20000000000000) );
|
||||
|
||||
return (std::min)( eT(std::numeric_limits<int>::max()), eT_int_accuracy_upper_limit );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -935,8 +968,8 @@ diskio::save_csv_ascii(const Mat<eT>& x, std::ostream& f, const char separator)
|
||||
uword x_n_rows = x.n_rows;
|
||||
uword x_n_cols = x.n_cols;
|
||||
|
||||
const eT eT_int_lowest = eT(std::numeric_limits<int>::lowest());
|
||||
const eT eT_int_max = eT(std::numeric_limits<int>::max());
|
||||
constexpr eT eT_int_lower = diskio::real_as_int_lower_limit<eT>();
|
||||
constexpr eT eT_int_upper = diskio::real_as_int_upper_limit<eT>();
|
||||
|
||||
for(uword row=0; row < x_n_rows; ++row)
|
||||
{
|
||||
@@ -944,7 +977,7 @@ diskio::save_csv_ascii(const Mat<eT>& x, std::ostream& f, const char separator)
|
||||
{
|
||||
const eT val = x.at(row,col);
|
||||
|
||||
const bool is_real_int = (is_real<eT>::yes) && arma_isfinite(val) && (val > eT_int_lowest) && (val < eT_int_max) && (eT(int(val)) == val);
|
||||
const bool is_real_int = (is_real<eT>::yes) && arma_isfinite(val) && (val > eT_int_lower) && (val < eT_int_upper) && (eT(int(val)) == val);
|
||||
|
||||
(is_real_int) ? arma_ostream::raw_print_elem(f, int(val)) : arma_ostream::raw_print_elem(f, val);
|
||||
|
||||
@@ -977,8 +1010,8 @@ diskio::save_csv_ascii(const Mat< std::complex<T> >& x, std::ostream& f, const c
|
||||
|
||||
diskio::prepare_stream<eT>(f);
|
||||
|
||||
const T T_int_lowest = T(std::numeric_limits<int>::lowest());
|
||||
const T T_int_max = T(std::numeric_limits<int>::max());
|
||||
constexpr T T_int_lower = diskio::real_as_int_lower_limit<T>();
|
||||
constexpr T T_int_upper = diskio::real_as_int_upper_limit<T>();
|
||||
|
||||
uword x_n_rows = x.n_rows;
|
||||
uword x_n_cols = x.n_cols;
|
||||
@@ -994,8 +1027,8 @@ diskio::save_csv_ascii(const Mat< std::complex<T> >& x, std::ostream& f, const c
|
||||
const T abs_i = (val_i < T(0)) ? T(-val_i) : T(val_i);
|
||||
const char sgn_i = (val_i < T(0)) ? char('-') : char('+');
|
||||
|
||||
const bool val_r_is_real_int = (is_real<T>::yes) && arma_isfinite(val_r) && (val_r > T_int_lowest) && (val_r < T_int_max) && (T(int(val_r)) == val_r);
|
||||
const bool abs_i_is_real_int = (is_real<T>::yes) && arma_isfinite(abs_i) && (abs_i < T_int_max) && (T(int(abs_i)) == abs_i);
|
||||
const bool val_r_is_real_int = (is_real<T>::yes) && arma_isfinite(val_r) && (val_r > T_int_lower) && (val_r < T_int_upper) && (T(int(val_r)) == val_r);
|
||||
const bool abs_i_is_real_int = (is_real<T>::yes) && arma_isfinite(abs_i) && (abs_i < T_int_upper) && (T(int(abs_i)) == abs_i);
|
||||
|
||||
(val_r_is_real_int) ? arma_ostream::raw_print_elem(f, int(val_r)) : arma_ostream::raw_print_elem(f, val_r);
|
||||
|
||||
@@ -1061,9 +1094,9 @@ diskio::save_coord_ascii(const Mat<eT>& x, std::ostream& f)
|
||||
|
||||
diskio::prepare_stream<eT>(f);
|
||||
|
||||
const eT eT_zero = eT(0);
|
||||
const eT eT_int_lowest = eT(std::numeric_limits<int>::lowest());
|
||||
const eT eT_int_max = eT(std::numeric_limits<int>::max());
|
||||
constexpr eT eT_zero = eT(0);
|
||||
constexpr eT eT_int_lower = diskio::real_as_int_lower_limit<eT>();
|
||||
constexpr eT eT_int_upper = diskio::real_as_int_upper_limit<eT>();
|
||||
|
||||
for(uword col=0; col < x.n_cols; ++col)
|
||||
for(uword row=0; row < x.n_rows; ++row)
|
||||
@@ -1075,7 +1108,7 @@ diskio::save_coord_ascii(const Mat<eT>& x, std::ostream& f)
|
||||
f << row; f.put(' ');
|
||||
f << col; f.put(' ');
|
||||
|
||||
const bool is_real_int = (is_real<eT>::yes) && arma_isfinite(val) && (val > eT_int_lowest) && (val < eT_int_max) && (eT(int(val)) == val);
|
||||
const bool is_real_int = (is_real<eT>::yes) && arma_isfinite(val) && (val > eT_int_lower) && (val < eT_int_upper) && (eT(int(val)) == val);
|
||||
|
||||
(is_real_int) ? arma_ostream::raw_print_elem(f, int(val)) : arma_ostream::raw_print_elem(f, val);
|
||||
|
||||
@@ -1116,9 +1149,9 @@ diskio::save_coord_ascii(const Mat< std::complex<T> >& x, std::ostream& f)
|
||||
|
||||
diskio::prepare_stream<eT>(f);
|
||||
|
||||
const eT eT_zero = eT(0);
|
||||
const T T_int_lowest = T(std::numeric_limits<int>::lowest());
|
||||
const T T_int_max = T(std::numeric_limits<int>::max());
|
||||
constexpr eT eT_zero = eT(0);
|
||||
constexpr T T_int_lower = diskio::real_as_int_lower_limit<T>();
|
||||
constexpr T T_int_upper = diskio::real_as_int_upper_limit<T>();
|
||||
|
||||
for(uword col=0; col < x.n_cols; ++col)
|
||||
for(uword row=0; row < x.n_rows; ++row)
|
||||
@@ -1133,8 +1166,8 @@ diskio::save_coord_ascii(const Mat< std::complex<T> >& x, std::ostream& f)
|
||||
const T val_r = std::real(val);
|
||||
const T val_i = std::imag(val);
|
||||
|
||||
const bool val_r_is_real_int = (is_real<T>::yes) && arma_isfinite(val_r) && (val_r > T_int_lowest) && (val_r < T_int_max) && (T(int(val_r)) == val_r);
|
||||
const bool val_i_is_real_int = (is_real<T>::yes) && arma_isfinite(val_i) && (val_i > T_int_lowest) && (val_i < T_int_max) && (T(int(val_i)) == val_i);
|
||||
const bool val_r_is_real_int = (is_real<T>::yes) && arma_isfinite(val_r) && (val_r > T_int_lower) && (val_r < T_int_upper) && (T(int(val_r)) == val_r);
|
||||
const bool val_i_is_real_int = (is_real<T>::yes) && arma_isfinite(val_i) && (val_i > T_int_lower) && (val_i < T_int_upper) && (T(int(val_i)) == val_i);
|
||||
|
||||
(val_r_is_real_int) ? arma_ostream::raw_print_elem(f, int(val_r)) : arma_ostream::raw_print_elem(f, val_r);
|
||||
|
||||
@@ -2966,9 +2999,9 @@ diskio::save_csv_ascii(const SpMat<eT>& x, std::ostream& f, const char separator
|
||||
uword x_n_rows = x.n_rows;
|
||||
uword x_n_cols = x.n_cols;
|
||||
|
||||
const eT eT_zero = eT(0);
|
||||
const eT eT_int_lowest = eT(std::numeric_limits<int>::lowest());
|
||||
const eT eT_int_max = eT(std::numeric_limits<int>::max());
|
||||
constexpr eT eT_zero = eT(0);
|
||||
constexpr eT eT_int_lower = diskio::real_as_int_lower_limit<eT>();
|
||||
constexpr eT eT_int_upper = diskio::real_as_int_upper_limit<eT>();
|
||||
|
||||
for(uword row=0; row < x_n_rows; ++row)
|
||||
{
|
||||
@@ -2982,7 +3015,7 @@ diskio::save_csv_ascii(const SpMat<eT>& x, std::ostream& f, const char separator
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool is_real_int = (is_real<eT>::yes) && arma_isfinite(val) && (val > eT_int_lowest) && (val < eT_int_max) && (eT(int(val)) == val);
|
||||
const bool is_real_int = (is_real<eT>::yes) && arma_isfinite(val) && (val > eT_int_lower) && (val < eT_int_upper) && (eT(int(val)) == val);
|
||||
|
||||
(is_real_int) ? arma_ostream::raw_print_elem(f, int(val)) : arma_ostream::raw_print_elem(f, val);
|
||||
}
|
||||
@@ -3064,8 +3097,8 @@ diskio::save_coord_ascii(const SpMat<eT>& x, std::ostream& f)
|
||||
|
||||
diskio::prepare_stream<eT>(f);
|
||||
|
||||
const eT eT_int_lowest = eT(std::numeric_limits<int>::lowest());
|
||||
const eT eT_int_max = eT(std::numeric_limits<int>::max());
|
||||
constexpr eT eT_int_lower = diskio::real_as_int_lower_limit<eT>();
|
||||
constexpr eT eT_int_upper = diskio::real_as_int_upper_limit<eT>();
|
||||
|
||||
typename SpMat<eT>::const_iterator iter = x.begin();
|
||||
typename SpMat<eT>::const_iterator iter_end = x.end();
|
||||
@@ -3077,7 +3110,7 @@ diskio::save_coord_ascii(const SpMat<eT>& x, std::ostream& f)
|
||||
|
||||
const eT val = (*iter);
|
||||
|
||||
const bool is_real_int = (is_real<eT>::yes) && arma_isfinite(val) && (val > eT_int_lowest) && (val < eT_int_max) && (eT(int(val)) == val);
|
||||
const bool is_real_int = (is_real<eT>::yes) && arma_isfinite(val) && (val > eT_int_lower) && (val < eT_int_upper) && (eT(int(val)) == val);
|
||||
|
||||
(is_real_int) ? arma_ostream::raw_print_elem(f, int(val)) : arma_ostream::raw_print_elem(f, val);
|
||||
|
||||
@@ -3120,8 +3153,8 @@ diskio::save_coord_ascii(const SpMat< std::complex<T> >& x, std::ostream& f)
|
||||
|
||||
diskio::prepare_stream<eT>(f);
|
||||
|
||||
const T T_int_lowest = T(std::numeric_limits<int>::lowest());
|
||||
const T T_int_max = T(std::numeric_limits<int>::max());
|
||||
constexpr T T_int_lower = diskio::real_as_int_lower_limit<T>();
|
||||
constexpr T T_int_upper = diskio::real_as_int_upper_limit<T>();
|
||||
|
||||
typename SpMat<eT>::const_iterator iter = x.begin();
|
||||
typename SpMat<eT>::const_iterator iter_end = x.end();
|
||||
@@ -3136,8 +3169,8 @@ diskio::save_coord_ascii(const SpMat< std::complex<T> >& x, std::ostream& f)
|
||||
const T val_r = std::real(val);
|
||||
const T val_i = std::imag(val);
|
||||
|
||||
const bool val_r_is_real_int = (is_real<T>::yes) && arma_isfinite(val_r) && (val_r > T_int_lowest) && (val_r < T_int_max) && (T(int(val_r)) == val_r);
|
||||
const bool val_i_is_real_int = (is_real<T>::yes) && arma_isfinite(val_i) && (val_i > T_int_lowest) && (val_i < T_int_max) && (T(int(val_i)) == val_i);
|
||||
const bool val_r_is_real_int = (is_real<T>::yes) && arma_isfinite(val_r) && (val_r > T_int_lower) && (val_r < T_int_upper) && (T(int(val_r)) == val_r);
|
||||
const bool val_i_is_real_int = (is_real<T>::yes) && arma_isfinite(val_i) && (val_i > T_int_lower) && (val_i < T_int_upper) && (T(int(val_i)) == val_i);
|
||||
|
||||
(val_r_is_real_int) ? arma_ostream::raw_print_elem(f, int(val_r)) : arma_ostream::raw_print_elem(f, val_r);
|
||||
|
||||
|
||||
@@ -48,6 +48,26 @@ class distr_param
|
||||
}
|
||||
|
||||
|
||||
inline explicit distr_param(const int a)
|
||||
: state (1)
|
||||
, a_int (a)
|
||||
, b_int (0)
|
||||
, a_double(double(a))
|
||||
, b_double(double(0))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline explicit distr_param(const double a)
|
||||
: state (2)
|
||||
, a_int (int(a))
|
||||
, b_int (int(0))
|
||||
, a_double(a)
|
||||
, b_double(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline explicit distr_param(const int a, const int b)
|
||||
: state (1)
|
||||
, a_int (a)
|
||||
|
||||
@@ -94,7 +94,9 @@ field<oT>::field(const subview_field<oT>& X)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
this->operator=(X);
|
||||
init(X.n_rows, X.n_cols, X.n_slices);
|
||||
|
||||
subview_field<oT>::extract(*this, X);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +109,20 @@ field<oT>::operator=(const subview_field<oT>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
subview_field<oT>::extract(*this, X);
|
||||
const bool alias = (this == &(X.f));
|
||||
|
||||
if(alias == false)
|
||||
{
|
||||
(*this).init(X.n_rows, X.n_cols, X.n_slices);
|
||||
|
||||
subview_field<oT>::extract(*this, X);
|
||||
}
|
||||
else
|
||||
{
|
||||
field<oT> tmp(X);
|
||||
|
||||
(*this).operator=(std::move(tmp));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -22,22 +22,29 @@
|
||||
|
||||
namespace fill
|
||||
{
|
||||
struct fill_none {};
|
||||
struct fill_zeros {};
|
||||
struct fill_ones {};
|
||||
struct fill_eye {};
|
||||
struct fill_randu {};
|
||||
struct fill_randn {};
|
||||
struct fill_none {};
|
||||
struct fill_zeros {};
|
||||
struct fill_ones {};
|
||||
struct fill_eye {};
|
||||
struct fill_randu {};
|
||||
struct fill_randn {};
|
||||
struct fill_nan {};
|
||||
struct fill_pos_inf {};
|
||||
struct fill_neg_inf {};
|
||||
|
||||
template<typename fill_type>
|
||||
struct fill_class { inline constexpr fill_class() {} };
|
||||
|
||||
static constexpr fill_class<fill_none > none;
|
||||
static constexpr fill_class<fill_zeros> zeros;
|
||||
static constexpr fill_class<fill_ones > ones;
|
||||
static constexpr fill_class<fill_eye > eye;
|
||||
static constexpr fill_class<fill_randu> randu;
|
||||
static constexpr fill_class<fill_randn> randn;
|
||||
static constexpr fill_class<fill_none > none;
|
||||
static constexpr fill_class<fill_zeros > zeros;
|
||||
static constexpr fill_class<fill_ones > ones;
|
||||
static constexpr fill_class<fill_eye > eye;
|
||||
static constexpr fill_class<fill_randu > randu;
|
||||
static constexpr fill_class<fill_randn > randn;
|
||||
static constexpr fill_class<fill_nan > nan;
|
||||
static constexpr fill_class<fill_pos_inf> inf;
|
||||
static constexpr fill_class<fill_pos_inf> pos_inf;
|
||||
static constexpr fill_class<fill_neg_inf> neg_inf;
|
||||
|
||||
//
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ all(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -59,7 +59,7 @@ all(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -78,7 +78,7 @@ all(const T1& X, const uword dim)
|
||||
//! for compatibility purposes: allows compiling user code designed for earlier versions of Armadillo
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
|
||||
@@ -41,7 +41,7 @@ any(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -59,7 +59,7 @@ any(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -78,7 +78,7 @@ any(const T1& X, const uword dim)
|
||||
//! for compatibility purposes: allows compiling user code designed for earlier versions of Armadillo
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
|
||||
@@ -110,8 +110,8 @@ internal_approx_equal_worker
|
||||
|
||||
arma_conform_check( ((use_abs_diff == false) && (use_rel_diff == false)), "internal_approx_equal_worker(): both 'use_abs_diff' and 'use_rel_diff' are false" );
|
||||
|
||||
if(use_abs_diff) { arma_conform_check( cond_rel< is_signed<T>::value >::lt(abs_tol, T(0)), "approx_equal(): argument 'abs_tol' must be >= 0" ); }
|
||||
if(use_rel_diff) { arma_conform_check( cond_rel< is_signed<T>::value >::lt(rel_tol, T(0)), "approx_equal(): argument 'rel_tol' must be >= 0" ); }
|
||||
if(use_abs_diff) { arma_conform_check( (cond_rel< is_signed<T>::value >::lt(abs_tol, T(0)) || arma_isnan(abs_tol)), "approx_equal(): argument 'abs_tol' must be >= 0" ); }
|
||||
if(use_rel_diff) { arma_conform_check( (cond_rel< is_signed<T>::value >::lt(rel_tol, T(0)) || arma_isnan(rel_tol)), "approx_equal(): argument 'rel_tol' must be >= 0" ); }
|
||||
|
||||
const Proxy<T1> PA(A.get_ref());
|
||||
const Proxy<T2> PB(B.get_ref());
|
||||
@@ -203,8 +203,8 @@ internal_approx_equal_worker
|
||||
|
||||
arma_conform_check( ((use_abs_diff == false) && (use_rel_diff == false)), "internal_approx_equal_worker(): both 'use_abs_diff' and 'use_rel_diff' are false" );
|
||||
|
||||
if(use_abs_diff) { arma_conform_check( cond_rel< is_signed<T>::value >::lt(abs_tol, T(0)), "approx_equal(): argument 'abs_tol' must be >= 0" ); }
|
||||
if(use_rel_diff) { arma_conform_check( cond_rel< is_signed<T>::value >::lt(rel_tol, T(0)), "approx_equal(): argument 'rel_tol' must be >= 0" ); }
|
||||
if(use_abs_diff) { arma_conform_check( (cond_rel< is_signed<T>::value >::lt(abs_tol, T(0)) || arma_isnan(abs_tol)), "approx_equal(): argument 'abs_tol' must be >= 0" ); }
|
||||
if(use_rel_diff) { arma_conform_check( (cond_rel< is_signed<T>::value >::lt(rel_tol, T(0)) || arma_isnan(rel_tol)), "approx_equal(): argument 'rel_tol' must be >= 0" ); }
|
||||
|
||||
const ProxyCube<T1> PA(A.get_ref());
|
||||
const ProxyCube<T2> PB(B.get_ref());
|
||||
@@ -418,7 +418,7 @@ approx_equal(const SpBase<typename T1::elem_type,T1>& A, const SpBase<typename T
|
||||
|
||||
arma_conform_check( (sig == 'r'), "approx_equal(): only the \"absdiff\" method is currently implemented for sparse matrices" );
|
||||
|
||||
arma_conform_check( cond_rel< is_signed<T>::value >::lt(tol, T(0)), "approx_equal(): argument 'tol' must be >= 0" );
|
||||
arma_conform_check( (cond_rel< is_signed<T>::value >::lt(tol, T(0)) || arma_isnan(tol)), "approx_equal(): argument 'tol' must be >= 0" );
|
||||
|
||||
const unwrap_spmat<T1> UA(A.get_ref());
|
||||
const unwrap_spmat<T2> UB(B.get_ref());
|
||||
@@ -460,8 +460,8 @@ approx_equal(const SpBase<typename T1::elem_type,T1>& A, const SpBase<typename T
|
||||
|
||||
arma_conform_check( ((sig == 'r') || (sig == 'b')), "approx_equal(): only the \"absdiff\" method is currently implemented for sparse matrices" );
|
||||
|
||||
arma_conform_check( cond_rel< is_signed<T>::value >::lt(abs_tol, T(0)), "approx_equal(): argument 'abs_tol' must be >= 0" );
|
||||
arma_conform_check( cond_rel< is_signed<T>::value >::lt(rel_tol, T(0)), "approx_equal(): argument 'rel_tol' must be >= 0" );
|
||||
arma_conform_check( (cond_rel< is_signed<T>::value >::lt(abs_tol, T(0)) || arma_isnan(abs_tol)), "approx_equal(): argument 'abs_tol' must be >= 0" );
|
||||
arma_conform_check( (cond_rel< is_signed<T>::value >::lt(rel_tol, T(0)) || arma_isnan(rel_tol)), "approx_equal(): argument 'rel_tol' must be >= 0" );
|
||||
|
||||
return approx_equal(A.get_ref(), B.get_ref(), "abs", abs_tol);
|
||||
}
|
||||
|
||||
@@ -17,15 +17,14 @@
|
||||
|
||||
|
||||
|
||||
//! \addtogroup fn_shift
|
||||
//! \addtogroup fn_circshift
|
||||
//! @{
|
||||
|
||||
|
||||
|
||||
// TODO: deprecate in favour of circshift()
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
// [[deprecated("use circshift() instead")]]
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -50,7 +49,7 @@ shift
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -73,9 +72,8 @@ circshift
|
||||
|
||||
|
||||
|
||||
// TODO: deprecate in favour of circshift()
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
// [[deprecated("use circshift() instead")]]
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
@@ -140,9 +138,8 @@ circshift
|
||||
|
||||
|
||||
|
||||
// TODO: deprecate in favour of circshift()
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
// [[deprecated("use circshift() instead")]]
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
@@ -217,9 +214,8 @@ circshift
|
||||
|
||||
|
||||
|
||||
// TODO: deprecate in favour of circshift()
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
// [[deprecated("use circshift() instead")]]
|
||||
inline
|
||||
SpMat<typename T1::elem_type>
|
||||
shift
|
||||
|
||||
@@ -97,12 +97,12 @@ clamp(const SpBase<typename T1::elem_type,T1>& X, const typename T1::elem_type m
|
||||
|
||||
if(is_cx<eT>::no)
|
||||
{
|
||||
arma_conform_check( (access::tmp_real(min_val) > access::tmp_real(max_val)), "clamp(): min_val must be less than max_val" );
|
||||
arma_conform_check( ((access::tmp_real(min_val) <= access::tmp_real(max_val)) == false), "clamp(): min_val must be less than max_val" );
|
||||
}
|
||||
else
|
||||
{
|
||||
arma_conform_check( (access::tmp_real(min_val) > access::tmp_real(max_val)), "clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( (access::tmp_imag(min_val) > access::tmp_imag(max_val)), "clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
arma_conform_check( ((access::tmp_real(min_val) <= access::tmp_real(max_val)) == false), "clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( ((access::tmp_imag(min_val) <= access::tmp_imag(max_val)) == false), "clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
}
|
||||
|
||||
SpMat<eT> out = X.get_ref();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -41,7 +41,7 @@ cumprod(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -59,7 +59,7 @@ cumprod(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -77,7 +77,7 @@ cumprod(const T1& X, const uword dim)
|
||||
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename arma_scalar_only<T>::result
|
||||
cumprod(const T& x)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -41,7 +41,7 @@ cumsum(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -59,7 +59,7 @@ cumsum(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -77,7 +77,7 @@ cumsum(const T1& X, const uword dim)
|
||||
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename arma_scalar_only<T>::result
|
||||
cumsum(const T& x)
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ det(typename T1::elem_type& out_val, const Base<typename T1::elem_type,T1>& X)
|
||||
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename arma_scalar_only<T>::result
|
||||
det(const T& x)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
//! interpret a matrix or a vector as a diagonal matrix (ie. off-diagonal entries are zero)
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -42,7 +42,7 @@ diagmat(const T1& X)
|
||||
//! create a matrix with the k-th diagonal set to the given vector
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
//! extract main diagonal from matrix
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const Op<T1, op_diagvec>
|
||||
diagvec(const Base<typename T1::elem_type,T1>& X)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ diagvec(const Base<typename T1::elem_type,T1>& X)
|
||||
//! extract arbitrary diagonal from matrix
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const Op<T1, op_diagvec2>
|
||||
diagvec(const Base<typename T1::elem_type,T1>& X, const sword diag_id)
|
||||
{
|
||||
@@ -50,7 +50,7 @@ diagvec(const Base<typename T1::elem_type,T1>& X, const sword diag_id)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const mtSpReduceOp<typename T1::elem_type, T1, op_sp_diagvec>
|
||||
diagvec(const SpBase<typename T1::elem_type,T1>& X, const sword diag_id = 0)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -45,7 +45,7 @@ diff
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -67,7 +67,7 @@ diff
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
|
||||
@@ -69,7 +69,7 @@ expmat(Mat<typename T1::elem_type>& B, const Base<typename T1::elem_type,T1>& A)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_blas_type<typename T1::elem_type>::value, const Op<T1, op_expmat_sym> >::result
|
||||
expmat_sym(const Base<typename T1::elem_type,T1>& X)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_flipud> >::result
|
||||
flipud(const T1& X)
|
||||
{
|
||||
@@ -36,7 +36,7 @@ flipud(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_fliplr> >::result
|
||||
fliplr(const T1& X)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ fliplr(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const SpOp<T1, spop_flipud>
|
||||
flipud(const SpBase<typename T1::elem_type,T1>& X)
|
||||
{
|
||||
@@ -62,7 +62,7 @@ flipud(const SpBase<typename T1::elem_type,T1>& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const SpOp<T1, spop_fliplr>
|
||||
fliplr(const SpBase<typename T1::elem_type,T1>& X)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -40,7 +40,7 @@ hist(const T1& A, const uword n_bins = 10)
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -58,7 +58,7 @@ hist(const T1& X, const T2& Y)
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -40,7 +40,7 @@ histc(const T1& X, const T2& Y)
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
|
||||
@@ -35,7 +35,7 @@ index_max(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value && resolves_to_vector<T1>::no, const mtOp<uword, T1, op_index_max> >::result
|
||||
index_max(const T1& X)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ index_max(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value, const mtOp<uword, T1, op_index_max> >::result
|
||||
index_max(const T1& X, const uword dim)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ index_max(const T1& X, const uword dim)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const mtOpCube<uword, T1, op_index_max>
|
||||
index_max
|
||||
(
|
||||
|
||||
@@ -35,7 +35,7 @@ index_min(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value && resolves_to_vector<T1>::no, const mtOp<uword, T1, op_index_min> >::result
|
||||
index_min(const T1& X)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ index_min(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value, const mtOp<uword, T1, op_index_min> >::result
|
||||
index_min(const T1& X, const uword dim)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ index_min(const T1& X, const uword dim)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const mtOpCube<uword, T1, op_index_min>
|
||||
index_min
|
||||
(
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const Glue<T1,T2,glue_kron>
|
||||
kron(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_type,T2>& B)
|
||||
{
|
||||
@@ -90,7 +90,7 @@ kron(const Base<T,T1>& X, const Base<std::complex<T>,T2>& Y)
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const SpGlue<T1, T2, spglue_kron>
|
||||
kron(const SpBase<typename T1::elem_type,T1>& A, const SpBase<typename T1::elem_type,T2>& B)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< (is_blas_type<typename T1::elem_type>::value && is_cx<typename T1::elem_type>::no), const mtOp<std::complex<typename T1::elem_type>, T1, op_logmat> >::result
|
||||
logmat(const Base<typename T1::elem_type,T1>& X, const uword n_iters = 100u)
|
||||
{
|
||||
@@ -36,7 +36,7 @@ logmat(const Base<typename T1::elem_type,T1>& X, const uword n_iters = 100u)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< (is_blas_type<typename T1::elem_type>::value && is_cx<typename T1::elem_type>::yes), const Op<T1, op_logmat_cx> >::result
|
||||
logmat(const Base<typename T1::elem_type,T1>& X, const uword n_iters = 100u)
|
||||
{
|
||||
@@ -93,7 +93,7 @@ logmat(Mat<typename T1::elem_type>& Y, const Base<typename T1::elem_type,T1>& X,
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_blas_type<typename T1::elem_type>::value, const Op<T1, op_logmat_sympd> >::result
|
||||
logmat_sympd(const Base<typename T1::elem_type,T1>& X)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ max(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value && resolves_to_vector<T1>::no, const Op<T1, op_max> >::result
|
||||
max(const T1& X)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ max(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_max> >::result
|
||||
max(const T1& X, const uword dim)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ max(const T1& X, const uword dim)
|
||||
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename arma_scalar_only<T>::result
|
||||
max(const T& x)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ max(const T& x)
|
||||
//! element-wise maximum
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -95,7 +95,7 @@ max
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const OpCube<T1, op_max>
|
||||
max
|
||||
(
|
||||
@@ -112,7 +112,7 @@ max
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const GlueCube<T1, T2, glue_max>
|
||||
max
|
||||
(
|
||||
|
||||
@@ -36,7 +36,7 @@ mean(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value && resolves_to_vector<T1>::no, const Op<T1, op_mean> >::result
|
||||
mean(const T1& X)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ mean(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_mean> >::result
|
||||
mean(const T1& X, const uword dim)
|
||||
{
|
||||
@@ -62,7 +62,7 @@ mean(const T1& X, const uword dim)
|
||||
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename arma_scalar_only<T>::result
|
||||
mean(const T& x)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ mean(const T& x)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const OpCube<T1, op_mean>
|
||||
mean
|
||||
(
|
||||
|
||||
@@ -35,7 +35,7 @@ median(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value && resolves_to_vector<T1>::no, const Op<T1, op_median> >::result
|
||||
median(const T1& X)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ median(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_median> >::result
|
||||
median(const T1& X, const uword dim)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ median(const T1& X, const uword dim)
|
||||
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename arma_scalar_only<T>::result
|
||||
median(const T& x)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ min(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value && resolves_to_vector<T1>::no, const Op<T1, op_min> >::result
|
||||
min(const T1& X)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ min(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_min> >::result
|
||||
min(const T1& X, const uword dim)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ min(const T1& X, const uword dim)
|
||||
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename arma_scalar_only<T>::result
|
||||
min(const T& x)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ min(const T& x)
|
||||
//! element-wise minimum
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -95,7 +95,7 @@ min
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const OpCube<T1, op_min>
|
||||
min
|
||||
(
|
||||
@@ -112,7 +112,7 @@ min
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const GlueCube<T1, T2, glue_min>
|
||||
min
|
||||
(
|
||||
|
||||
@@ -95,7 +95,7 @@ normalise
|
||||
//! for compatibility purposes: allows compiling user code designed for earlier versions of Armadillo
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_blas_real<typename T1::pod_type>::value, const Op<T1, op_orth> >::result
|
||||
orth(const Base<typename T1::elem_type, T1>& X, const typename T1::pod_type tol = 0.0)
|
||||
{
|
||||
@@ -62,7 +62,7 @@ orth(Mat<typename T1::elem_type>& out, const Base<typename T1::elem_type, T1>& X
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_blas_real<typename T1::pod_type>::value, const Op<T1, op_null> >::result
|
||||
null(const Base<typename T1::elem_type, T1>& X, const typename T1::pod_type tol = 0.0)
|
||||
{
|
||||
|
||||
@@ -20,13 +20,6 @@
|
||||
//! @{
|
||||
|
||||
|
||||
//! \brief
|
||||
//! Delayed product of elements of a matrix along a specified dimension (either rows or columns).
|
||||
//! The result is stored in a dense matrix that has either one column or one row.
|
||||
//! For dim = 0, find the sum of each column (ie. traverse across rows)
|
||||
//! For dim = 1, find the sum of each row (ie. traverse across columns)
|
||||
//! The default is dim = 0.
|
||||
//! NOTE: this function works differently than in Matlab/Octave.
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
@@ -43,7 +36,7 @@ prod(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value && resolves_to_vector<T1>::no, const Op<T1, op_prod> >::result
|
||||
prod(const T1& X)
|
||||
{
|
||||
@@ -56,7 +49,7 @@ prod(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_prod> >::result
|
||||
prod(const T1& X, const uword dim)
|
||||
{
|
||||
@@ -69,7 +62,7 @@ prod(const T1& X, const uword dim)
|
||||
|
||||
template<typename T>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename arma_scalar_only<T>::result
|
||||
prod(const T& x)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -40,7 +40,7 @@ quantile(const T1& X, const Base<typename T2::elem_type,T2>& P)
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// Copyright 2008-2016 Conrad Sanderson (https://conradsanderson.id.au)
|
||||
// Copyright 2008-2016 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
|
||||
// https://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.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
//! \addtogroup fn_rande
|
||||
//! @{
|
||||
|
||||
|
||||
|
||||
template<typename obj_type>
|
||||
arma_warn_unused
|
||||
inline
|
||||
obj_type
|
||||
rande(const uword n_rows, const uword n_cols, const distr_param& param = distr_param(), const typename arma_Mat_Col_Row_only<obj_type>::result* junk = nullptr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
typedef typename obj_type::elem_type eT;
|
||||
|
||||
if(is_Col<obj_type>::value)
|
||||
{
|
||||
arma_conform_check( (n_cols != 1), "rande(): incompatible size" );
|
||||
}
|
||||
else
|
||||
if(is_Row<obj_type>::value)
|
||||
{
|
||||
arma_conform_check( (n_rows != 1), "rande(): incompatible size" );
|
||||
}
|
||||
|
||||
double lambda = double(1);
|
||||
double unused = double(0);
|
||||
|
||||
param.get_double_vals(lambda, unused);
|
||||
|
||||
arma_conform_check( ((lambda > double(0)) == false), "rande(): incorrect distribution parameters; lambda must be greater than zero" );
|
||||
|
||||
obj_type out(n_rows, n_cols, arma_nozeros_indicator());
|
||||
|
||||
arma_rng::rande<eT>::fill(out.memptr(), out.n_elem, lambda);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename obj_type>
|
||||
arma_warn_unused
|
||||
inline
|
||||
obj_type
|
||||
rande(const SizeMat& s, const distr_param& param = distr_param(), const typename arma_Mat_Col_Row_only<obj_type>::result* junk = nullptr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
return rande<obj_type>(s.n_rows, s.n_cols, param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename obj_type>
|
||||
arma_warn_unused
|
||||
inline
|
||||
obj_type
|
||||
rande(const uword n_elem, const distr_param& param = distr_param(), const arma_empty_class junk1 = arma_empty_class(), const typename arma_Mat_Col_Row_only<obj_type>::result* junk2 = nullptr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk1);
|
||||
arma_ignore(junk2);
|
||||
|
||||
const uword n_rows = (is_Row<obj_type>::value) ? uword(1) : n_elem;
|
||||
const uword n_cols = (is_Row<obj_type>::value) ? n_elem : uword(1);
|
||||
|
||||
return rande<obj_type>(n_rows, n_cols, param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
arma_warn_unused
|
||||
inline
|
||||
mat
|
||||
rande(const uword n_rows, const uword n_cols, const distr_param& param = distr_param())
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
return rande<mat>(n_rows, n_cols, param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
arma_warn_unused
|
||||
inline
|
||||
mat
|
||||
rande(const SizeMat& s, const distr_param& param = distr_param())
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
return rande<mat>(s.n_rows, s.n_cols, param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
arma_warn_unused
|
||||
inline
|
||||
vec
|
||||
rande(const uword n_elem, const distr_param& param = distr_param())
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
return rande<vec>(n_elem, uword(1), param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
arma_warn_unused
|
||||
inline
|
||||
double
|
||||
rande(const distr_param& param = distr_param())
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
double lambda = double(1);
|
||||
double unused = double(0);
|
||||
|
||||
param.get_double_vals(lambda, unused);
|
||||
|
||||
arma_conform_check( ((lambda > double(0)) == false), "rande(): incorrect distribution parameters; lambda must be greater than zero" );
|
||||
|
||||
double out_val = double(0);
|
||||
|
||||
arma_rng::rande<double>::fill(&out_val, uword(1), lambda);
|
||||
|
||||
return out_val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
arma_warn_unused
|
||||
inline
|
||||
typename arma_real_or_cx_only<eT>::result
|
||||
rande(const distr_param& param = distr_param())
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
double lambda = double(1);
|
||||
double unused = double(0);
|
||||
|
||||
param.get_double_vals(lambda, unused);
|
||||
|
||||
arma_conform_check( ((lambda > double(0)) == false), "rande(): incorrect distribution parameters; lambda must be greater than zero" );
|
||||
|
||||
eT out_val = eT(0);
|
||||
|
||||
arma_rng::rande<eT>::fill(&out_val, uword(1), lambda);
|
||||
|
||||
return out_val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename cube_type>
|
||||
arma_warn_unused
|
||||
inline
|
||||
cube_type
|
||||
rande(const uword n_rows, const uword n_cols, const uword n_slices, const distr_param& param = distr_param(), const typename arma_Cube_only<cube_type>::result* junk = nullptr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
typedef typename cube_type::elem_type eT;
|
||||
|
||||
double lambda = double(1);
|
||||
double unused = double(0);
|
||||
|
||||
param.get_double_vals(lambda, unused);
|
||||
|
||||
arma_conform_check( ((lambda > double(0)) == false), "rande(): incorrect distribution parameters; lambda must be greater than zero" );
|
||||
|
||||
cube_type out(n_rows, n_cols, n_slices, arma_nozeros_indicator());
|
||||
|
||||
arma_rng::rande<eT>::fill(out.memptr(), out.n_elem, lambda);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename cube_type>
|
||||
arma_warn_unused
|
||||
inline
|
||||
cube_type
|
||||
rande(const SizeCube& s, const distr_param& param = distr_param(), const typename arma_Cube_only<cube_type>::result* junk = nullptr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
return rande<cube_type>(s.n_rows, s.n_cols, s.n_slices, param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
arma_warn_unused
|
||||
inline
|
||||
cube
|
||||
rande(const uword n_rows, const uword n_cols, const uword n_slices, const distr_param& param = distr_param())
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
return rande<cube>(n_rows, n_cols, n_slices, param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
arma_warn_unused
|
||||
inline
|
||||
cube
|
||||
rande(const SizeCube& s, const distr_param& param = distr_param())
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
return rande<cube>(s.n_rows, s.n_cols, s.n_slices, param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
@@ -47,7 +47,7 @@ randg(const uword n_rows, const uword n_cols, const distr_param& param = distr_p
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( ((a <= double(0)) || (b <= double(0))), "randg(): incorrect distribution parameters; a and b must be greater than zero" );
|
||||
arma_conform_check( ( ((a > double(0)) == false) || ((b > double(0)) == false) ), "randg(): incorrect distribution parameters; a and b must be greater than zero" );
|
||||
|
||||
obj_type out(n_rows, n_cols, arma_nozeros_indicator());
|
||||
|
||||
@@ -138,7 +138,7 @@ randg(const distr_param& param = distr_param())
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( ((a <= double(0)) || (b <= double(0))), "randg(): incorrect distribution parameters; a and b must be greater than zero" );
|
||||
arma_conform_check( ( ((a > double(0)) == false) || ((b > double(0)) == false) ), "randg(): incorrect distribution parameters; a and b must be greater than zero" );
|
||||
|
||||
double out_val = double(0);
|
||||
|
||||
@@ -162,7 +162,7 @@ randg(const distr_param& param = distr_param())
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( ((a <= double(0)) || (b <= double(0))), "randg(): incorrect distribution parameters; a and b must be greater than zero" );
|
||||
arma_conform_check( ( ((a > double(0)) == false) || ((b > double(0)) == false) ), "randg(): incorrect distribution parameters; a and b must be greater than zero" );
|
||||
|
||||
eT out_val = eT(0);
|
||||
|
||||
@@ -189,7 +189,7 @@ randg(const uword n_rows, const uword n_cols, const uword n_slices, const distr_
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( ((a <= double(0)) || (b <= double(0))), "randg(): incorrect distribution parameters; a and b must be greater than zero" );
|
||||
arma_conform_check( ( ((a > double(0)) == false) || ((b > double(0)) == false) ), "randg(): incorrect distribution parameters; a and b must be greater than zero" );
|
||||
|
||||
cube_type out(n_rows, n_cols, n_slices, arma_nozeros_indicator());
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ randi(const uword n_rows, const uword n_cols, const distr_param& param = distr_p
|
||||
|
||||
param.get_int_vals(a,b);
|
||||
|
||||
arma_conform_check( (a > b), "randi(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a <= b) == false), "randi(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
obj_type out(n_rows, n_cols, arma_nozeros_indicator());
|
||||
|
||||
@@ -142,7 +142,7 @@ randi(const distr_param& param)
|
||||
|
||||
param.get_int_vals(a,b);
|
||||
|
||||
arma_conform_check( (a > b), "randi(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a <= b) == false), "randi(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
sword out_val = sword(0);
|
||||
|
||||
@@ -166,7 +166,7 @@ randi(const distr_param& param)
|
||||
|
||||
param.get_int_vals(a,b);
|
||||
|
||||
arma_conform_check( (a > b), "randi(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a <= b) == false), "randi(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
eT out_val = eT(0);
|
||||
|
||||
@@ -218,7 +218,7 @@ randi(const uword n_rows, const uword n_cols, const uword n_slices, const distr_
|
||||
|
||||
param.get_int_vals(a,b);
|
||||
|
||||
arma_conform_check( (a > b), "randi(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a <= b) == false), "randi(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
cube_type out(n_rows, n_cols, n_slices, arma_nozeros_indicator());
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ randn(const distr_param& param)
|
||||
|
||||
param.get_double_vals(mu,sd);
|
||||
|
||||
arma_conform_check( (sd <= double(0)), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
arma_conform_check( ((sd > double(0)) == false), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
|
||||
const double val = double(arma_rng::randn<double>());
|
||||
|
||||
@@ -86,7 +86,7 @@ randn(const distr_param& param)
|
||||
|
||||
param.get_double_vals(mu,sd);
|
||||
|
||||
arma_conform_check( (sd <= double(0)), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
arma_conform_check( ((sd > double(0)) == false), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
|
||||
eT val = eT(0);
|
||||
|
||||
@@ -119,7 +119,7 @@ randn(const uword n_elem, const distr_param& param = distr_param())
|
||||
|
||||
param.get_double_vals(mu,sd);
|
||||
|
||||
arma_conform_check( (sd <= double(0)), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
arma_conform_check( ((sd > double(0)) == false), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
|
||||
arma_rng::randn<double>::fill(out.memptr(), n_elem, mu, sd);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ randn(const uword n_elem, const distr_param& param = distr_param(), const typena
|
||||
|
||||
param.get_double_vals(mu,sd);
|
||||
|
||||
arma_conform_check( (sd <= double(0)), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
arma_conform_check( ((sd > double(0)) == false), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
|
||||
arma_rng::randn<eT>::fill(out.memptr(), out.n_elem, mu, sd);
|
||||
}
|
||||
@@ -188,7 +188,7 @@ randn(const uword n_rows, const uword n_cols, const distr_param& param = distr_p
|
||||
|
||||
param.get_double_vals(mu,sd);
|
||||
|
||||
arma_conform_check( (sd <= double(0)), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
arma_conform_check( ((sd > double(0)) == false), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
|
||||
arma_rng::randn<double>::fill(out.memptr(), out.n_elem, mu, sd);
|
||||
}
|
||||
@@ -237,7 +237,7 @@ randn(const uword n_rows, const uword n_cols, const distr_param& param = distr_p
|
||||
|
||||
param.get_double_vals(mu,sd);
|
||||
|
||||
arma_conform_check( (sd <= double(0)), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
arma_conform_check( ((sd > double(0)) == false), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
|
||||
arma_rng::randn<eT>::fill(out.memptr(), out.n_elem, mu, sd);
|
||||
}
|
||||
@@ -284,7 +284,7 @@ randn(const uword n_rows, const uword n_cols, const uword n_slices, const distr_
|
||||
|
||||
param.get_double_vals(mu,sd);
|
||||
|
||||
arma_conform_check( (sd <= double(0)), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
arma_conform_check( ((sd > double(0)) == false), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
|
||||
arma_rng::randn<double>::fill(out.memptr(), out.n_elem, mu, sd);
|
||||
}
|
||||
@@ -330,7 +330,7 @@ randn(const uword n_rows, const uword n_cols, const uword n_slices, const distr_
|
||||
|
||||
param.get_double_vals(mu,sd);
|
||||
|
||||
arma_conform_check( (sd <= double(0)), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
arma_conform_check( ((sd > double(0)) == false), "randn(): incorrect distribution parameters; standard deviation must be > 0" );
|
||||
|
||||
arma_rng::randn<eT>::fill(out.memptr(), out.n_elem, mu, sd);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ randu(const distr_param& param)
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( (a >= b), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a < b) == false), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
const double val = double(arma_rng::randu<double>());
|
||||
|
||||
@@ -86,7 +86,7 @@ randu(const distr_param& param)
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( (a >= b), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a < b) == false), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
eT val = eT(0);
|
||||
|
||||
@@ -119,7 +119,7 @@ randu(const uword n_elem, const distr_param& param = distr_param())
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( (a >= b), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a < b) == false), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
arma_rng::randu<double>::fill(out.memptr(), n_elem, a, b);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ randu(const uword n_elem, const distr_param& param = distr_param(), const typena
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( (a >= b), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a < b) == false), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
arma_rng::randu<eT>::fill(out.memptr(), out.n_elem, a, b);
|
||||
}
|
||||
@@ -188,7 +188,7 @@ randu(const uword n_rows, const uword n_cols, const distr_param& param = distr_p
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( (a >= b), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a < b) == false), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
arma_rng::randu<double>::fill(out.memptr(), out.n_elem, a, b);
|
||||
}
|
||||
@@ -237,7 +237,7 @@ randu(const uword n_rows, const uword n_cols, const distr_param& param = distr_p
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( (a >= b), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a < b) == false), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
arma_rng::randu<eT>::fill(out.memptr(), out.n_elem, a, b);
|
||||
}
|
||||
@@ -284,7 +284,7 @@ randu(const uword n_rows, const uword n_cols, const uword n_slices, const distr_
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( (a >= b), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a < b) == false), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
arma_rng::randu<double>::fill(out.memptr(), out.n_elem, a, b);
|
||||
}
|
||||
@@ -330,7 +330,7 @@ randu(const uword n_rows, const uword n_cols, const uword n_slices, const distr_
|
||||
|
||||
param.get_double_vals(a,b);
|
||||
|
||||
arma_conform_check( (a >= b), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
arma_conform_check( ((a < b) == false), "randu(): incorrect distribution parameters; a must be less than b" );
|
||||
|
||||
arma_rng::randu<eT>::fill(out.memptr(), out.n_elem, a, b);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ range(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value && resolves_to_vector<T1>::no, const Op<T1, op_range> >::result
|
||||
range(const T1& X)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ range(const T1& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_range> >::result
|
||||
range(const T1& X, const uword dim)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -41,7 +41,7 @@ repelem(const T1& A, const uword r, const uword c)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const SpOp<T1, spop_repelem>
|
||||
repelem(const SpBase<typename T1::elem_type,T1>& A, const uword r, const uword c)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -44,7 +44,7 @@ shuffle
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -65,7 +65,7 @@ shuffle
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
@@ -44,7 +44,7 @@ sort
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename
|
||||
enable_if2
|
||||
<
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const mtOp<uword,T1,op_sort_index>
|
||||
sort_index
|
||||
(
|
||||
@@ -70,7 +70,7 @@ sort_index
|
||||
// DO NOT USE: kept only for compatibility with old user code
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const mtOp<uword,T1,op_sort_index>
|
||||
stable_sort_index
|
||||
(
|
||||
|
||||
@@ -55,7 +55,7 @@ spsolve_helper
|
||||
|
||||
const superlu_opts& opts = (settings.id == 1) ? static_cast<const superlu_opts&>(settings) : superlu_opts_default;
|
||||
|
||||
arma_conform_check( ( (opts.pivot_thresh < double(0)) || (opts.pivot_thresh > double(1)) ), "spsolve(): pivot_thresh must be in the [0,1] interval" );
|
||||
arma_conform_check( ( ((opts.pivot_thresh >= double(0)) == false) || ((opts.pivot_thresh <= double(1)) == false) ), "spsolve(): pivot_thresh must be in the [0,1] interval" );
|
||||
|
||||
if(sig == 's') // SuperLU solver
|
||||
{
|
||||
@@ -110,12 +110,12 @@ spsolve_helper
|
||||
|
||||
if( (status == false) && (rcond > T(0)) )
|
||||
{
|
||||
arma_warn(2, "spsolve(): system is singular (rcond: ", rcond, ")");
|
||||
arma_warn(2, "spsolve(): system is singular; rcond: ", rcond);
|
||||
}
|
||||
|
||||
if( (status == true) && (rcond > T(0)) && (rcond < std::numeric_limits<T>::epsilon()) )
|
||||
{
|
||||
arma_warn(2, "solve(): solution computed, but system is singular to working precision (rcond: ", rcond, ")");
|
||||
arma_warn(2, "spsolve(): solution computed, but system is singular to working precision; rcond: ", rcond);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< (is_blas_type<typename T1::elem_type>::value && is_cx<typename T1::elem_type>::no), const mtOp<std::complex<typename T1::elem_type>, T1, op_sqrtmat> >::result
|
||||
sqrtmat(const Base<typename T1::elem_type,T1>& X)
|
||||
{
|
||||
@@ -36,7 +36,7 @@ sqrtmat(const Base<typename T1::elem_type,T1>& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< (is_blas_type<typename T1::elem_type>::value && is_cx<typename T1::elem_type>::yes), const Op<T1, op_sqrtmat_cx> >::result
|
||||
sqrtmat(const Base<typename T1::elem_type,T1>& X)
|
||||
{
|
||||
@@ -91,7 +91,7 @@ sqrtmat(Mat<typename T1::elem_type>& Y, const Base<typename T1::elem_type,T1>& X
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_blas_type<typename T1::elem_type>::value, const Op<T1, op_sqrtmat_sympd> >::result
|
||||
sqrtmat_sympd(const Base<typename T1::elem_type,T1>& X)
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ svds_helper
|
||||
"svds(): two or more output objects are the same object"
|
||||
);
|
||||
|
||||
arma_conform_check( (tol < T(0)), "svds(): tol must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "svds(): tol must be >= 0" );
|
||||
|
||||
const unwrap_spmat<T1> tmp(X.get_ref());
|
||||
const SpMat<eT>& A = tmp.M;
|
||||
@@ -171,7 +171,7 @@ svds_helper
|
||||
"svds(): two or more output objects are the same object"
|
||||
);
|
||||
|
||||
arma_conform_check( (tol < T(0)), "svds(): tol must be >= 0" );
|
||||
arma_conform_check( ((tol >= T(0)) == false), "svds(): tol must be >= 0" );
|
||||
|
||||
const unwrap_spmat<T1> tmp(X.get_ref());
|
||||
const SpMat<eT>& A = tmp.M;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_cx<typename T1::elem_type>::no, const Op<T1, op_symmatu> >::result
|
||||
symmatu(const Base<typename T1::elem_type,T1>& X, const bool do_conj = false)
|
||||
{
|
||||
@@ -36,7 +36,7 @@ symmatu(const Base<typename T1::elem_type,T1>& X, const bool do_conj = false)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_cx<typename T1::elem_type>::no, const Op<T1, op_symmatl> >::result
|
||||
symmatl(const Base<typename T1::elem_type,T1>& X, const bool do_conj = false)
|
||||
{
|
||||
@@ -50,7 +50,7 @@ symmatl(const Base<typename T1::elem_type,T1>& X, const bool do_conj = false)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_cx<typename T1::elem_type>::yes, const Op<T1, op_symmatu_cx> >::result
|
||||
symmatu(const Base<typename T1::elem_type,T1>& X, const bool do_conj = true)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ symmatu(const Base<typename T1::elem_type,T1>& X, const bool do_conj = true)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_cx<typename T1::elem_type>::yes, const Op<T1, op_symmatl_cx> >::result
|
||||
symmatl(const Base<typename T1::elem_type,T1>& X, const bool do_conj = true)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ symmatl(const Base<typename T1::elem_type,T1>& X, const bool do_conj = true)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_cx<typename T1::elem_type>::no, const SpOp<T1, spop_symmat> >::result
|
||||
symmatu(const SpBase<typename T1::elem_type,T1>& X, const bool do_conj = false)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ symmatu(const SpBase<typename T1::elem_type,T1>& X, const bool do_conj = false)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_cx<typename T1::elem_type>::no, const SpOp<T1, spop_symmat> >::result
|
||||
symmatl(const SpBase<typename T1::elem_type,T1>& X, const bool do_conj = false)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ symmatl(const SpBase<typename T1::elem_type,T1>& X, const bool do_conj = false)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_cx<typename T1::elem_type>::yes, const SpOp<T1, spop_symmat_cx> >::result
|
||||
symmatu(const SpBase<typename T1::elem_type,T1>& X, const bool do_conj = true)
|
||||
{
|
||||
@@ -121,7 +121,7 @@ symmatu(const SpBase<typename T1::elem_type,T1>& X, const bool do_conj = true)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_cx<typename T1::elem_type>::yes, const SpOp<T1, spop_symmat_cx> >::result
|
||||
symmatl(const SpBase<typename T1::elem_type,T1>& X, const bool do_conj = true)
|
||||
{
|
||||
|
||||
@@ -109,7 +109,7 @@ glue_hist::apply_noalias(Mat<uword>& out, const Mat<eT>& X, const Mat<eT>& C, co
|
||||
{
|
||||
const eT val = X_mem[i];
|
||||
|
||||
if(is_finite(val))
|
||||
if(arma_isfinite(val))
|
||||
{
|
||||
eT opt_dist = (val >= center_0) ? (val - center_0) : (center_0 - val);
|
||||
uword opt_index = 0;
|
||||
|
||||
@@ -36,7 +36,10 @@ struct glue_join_cols
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_join_cols>& X);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply_noalias(Mat<typename T1::elem_type>& out, const Proxy<T1>& A, const Proxy<T2>& B);
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_join_cols>& X);
|
||||
|
||||
template<typename eT>
|
||||
inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B);
|
||||
|
||||
template<typename eT, typename T1, typename T2, typename T3>
|
||||
inline static void apply(Mat<eT>& out, const Base<eT,T1>& A, const Base<eT,T2>& B, const Base<eT,T3>& C);
|
||||
@@ -61,7 +64,10 @@ struct glue_join_rows
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_join_rows>& X);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply_noalias(Mat<typename T1::elem_type>& out, const Proxy<T1>& A, const Proxy<T2>& B);
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_join_rows>& X);
|
||||
|
||||
template<typename eT>
|
||||
inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B);
|
||||
|
||||
template<typename eT, typename T1, typename T2, typename T3>
|
||||
inline static void apply(Mat<eT>& out, const Base<eT,T1>& A, const Base<eT,T2>& B, const Base<eT,T3>& C);
|
||||
|
||||
@@ -21,44 +21,38 @@
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
template<typename eT>
|
||||
inline
|
||||
void
|
||||
glue_join_cols::apply_noalias(Mat<typename T1::elem_type>& out, const Proxy<T1>& A, const Proxy<T2>& B)
|
||||
glue_join_cols::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword A_n_rows = A.get_n_rows();
|
||||
const uword A_n_cols = A.get_n_cols();
|
||||
|
||||
const uword B_n_rows = B.get_n_rows();
|
||||
const uword B_n_cols = B.get_n_cols();
|
||||
|
||||
arma_conform_check
|
||||
(
|
||||
( (A_n_cols != B_n_cols) && ( (A_n_rows > 0) || (A_n_cols > 0) ) && ( (B_n_rows > 0) || (B_n_cols > 0) ) ),
|
||||
( (A.n_cols != B.n_cols) && ( (A.n_rows > 0) || (A.n_cols > 0) ) && ( (B.n_rows > 0) || (B.n_cols > 0) ) ),
|
||||
"join_cols() / join_vert(): number of columns must be the same"
|
||||
);
|
||||
|
||||
out.set_size( A_n_rows + B_n_rows, (std::max)(A_n_cols, B_n_cols) );
|
||||
out.set_size( A.n_rows + B.n_rows, (std::max)(A.n_cols, B.n_cols) );
|
||||
|
||||
if( out.n_elem > 0 )
|
||||
{
|
||||
if(A.get_n_elem() > 0)
|
||||
if(A.n_elem> 0)
|
||||
{
|
||||
out.submat(0, 0, A_n_rows-1, out.n_cols-1) = A.Q;
|
||||
out.submat(0, 0, A.n_rows-1, out.n_cols-1) = A;
|
||||
}
|
||||
|
||||
if(B.get_n_elem() > 0)
|
||||
if(B.n_elem > 0)
|
||||
{
|
||||
out.submat(A_n_rows, 0, out.n_rows-1, out.n_cols-1) = B.Q;
|
||||
out.submat(A.n_rows, 0, out.n_rows-1, out.n_cols-1) = B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
@@ -68,18 +62,18 @@ glue_join_cols::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_jo
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
const Proxy<T1> A(X.A);
|
||||
const Proxy<T2> B(X.B);
|
||||
const quasi_unwrap<T1> UA(X.A);
|
||||
const quasi_unwrap<T2> UB(X.B);
|
||||
|
||||
if( (A.is_alias(out) == false) && (B.is_alias(out) == false) )
|
||||
if( (UA.is_alias(out) == false) && (UB.is_alias(out) == false) )
|
||||
{
|
||||
glue_join_cols::apply_noalias(out, A, B);
|
||||
glue_join_cols::apply_noalias(out, UA.M, UB.M);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat<eT> tmp;
|
||||
|
||||
glue_join_cols::apply_noalias(tmp, A, B);
|
||||
glue_join_cols::apply_noalias(tmp, UA.M, UB.M);
|
||||
|
||||
out.steal_mem(tmp);
|
||||
}
|
||||
@@ -87,6 +81,21 @@ glue_join_cols::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_jo
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_join_cols::apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_join_cols>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const quasi_unwrap<T1> UA(X.A);
|
||||
const quasi_unwrap<T2> UB(X.B);
|
||||
|
||||
glue_join_cols::apply_noalias(out, UA.M, UB.M);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT, typename T1, typename T2, typename T3>
|
||||
inline
|
||||
void
|
||||
@@ -178,44 +187,42 @@ glue_join_cols::apply(Mat<eT>& out, const Base<eT,T1>& A_expr, const Base<eT,T2>
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
//
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
void
|
||||
glue_join_rows::apply_noalias(Mat<typename T1::elem_type>& out, const Proxy<T1>& A, const Proxy<T2>& B)
|
||||
glue_join_rows::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword A_n_rows = A.get_n_rows();
|
||||
const uword A_n_cols = A.get_n_cols();
|
||||
|
||||
const uword B_n_rows = B.get_n_rows();
|
||||
const uword B_n_cols = B.get_n_cols();
|
||||
|
||||
arma_conform_check
|
||||
(
|
||||
( (A_n_rows != B_n_rows) && ( (A_n_rows > 0) || (A_n_cols > 0) ) && ( (B_n_rows > 0) || (B_n_cols > 0) ) ),
|
||||
( (A.n_rows != B.n_rows) && ( (A.n_rows > 0) || (A.n_cols > 0) ) && ( (B.n_rows > 0) || (B.n_cols > 0) ) ),
|
||||
"join_rows() / join_horiz(): number of rows must be the same"
|
||||
);
|
||||
|
||||
out.set_size( (std::max)(A_n_rows, B_n_rows), A_n_cols + B_n_cols );
|
||||
out.set_size( (std::max)(A.n_rows, B.n_rows), A.n_cols + B.n_cols );
|
||||
|
||||
if( out.n_elem > 0 )
|
||||
{
|
||||
if(A.get_n_elem() > 0)
|
||||
if(A.n_elem > 0)
|
||||
{
|
||||
out.submat(0, 0, out.n_rows-1, A_n_cols-1) = A.Q;
|
||||
out.submat(0, 0, out.n_rows-1, A.n_cols-1) = A;
|
||||
}
|
||||
|
||||
if(B.get_n_elem() > 0)
|
||||
if(B.n_elem > 0)
|
||||
{
|
||||
out.submat(0, A_n_cols, out.n_rows-1, out.n_cols-1) = B.Q;
|
||||
out.submat(0, A.n_cols, out.n_rows-1, out.n_cols-1) = B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
@@ -225,18 +232,18 @@ glue_join_rows::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_jo
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
const Proxy<T1> A(X.A);
|
||||
const Proxy<T2> B(X.B);
|
||||
const quasi_unwrap<T1> UA(X.A);
|
||||
const quasi_unwrap<T2> UB(X.B);
|
||||
|
||||
if( (A.is_alias(out) == false) && (B.is_alias(out) == false) )
|
||||
if( (UA.is_alias(out) == false) && (UB.is_alias(out) == false) )
|
||||
{
|
||||
glue_join_rows::apply_noalias(out, A, B);
|
||||
glue_join_rows::apply_noalias(out, UA.M, UB.M);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat<eT> tmp;
|
||||
|
||||
glue_join_rows::apply_noalias(tmp, A, B);
|
||||
glue_join_rows::apply_noalias(tmp, UA.M, UB.M);
|
||||
|
||||
out.steal_mem(tmp);
|
||||
}
|
||||
@@ -244,6 +251,21 @@ glue_join_rows::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_jo
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_join_rows::apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_join_rows>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const quasi_unwrap<T1> UA(X.A);
|
||||
const quasi_unwrap<T2> UB(X.B);
|
||||
|
||||
glue_join_rows::apply_noalias(out, UA.M, UB.M);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT, typename T1, typename T2, typename T3>
|
||||
inline
|
||||
void
|
||||
@@ -335,6 +357,10 @@ glue_join_rows::apply(Mat<eT>& out, const Base<eT,T1>& A_expr, const Base<eT,T2>
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
|
||||
@@ -36,7 +36,9 @@ struct glue_kron
|
||||
template<typename T> inline static void direct_kron(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const Mat<T>& B);
|
||||
template<typename T> inline static void direct_kron(Mat< std::complex<T> >& out, const Mat<T>& A, const Mat< std::complex<T> >& B);
|
||||
|
||||
template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_kron>& X);
|
||||
template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_kron>& X);
|
||||
|
||||
template<typename T1, typename T2> inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_kron>& X);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
|
||||
|
||||
|
||||
//! \brief
|
||||
//! both input matrices have the same element type
|
||||
template<typename eT>
|
||||
inline
|
||||
void
|
||||
@@ -50,9 +48,6 @@ glue_kron::direct_kron(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
|
||||
|
||||
|
||||
|
||||
//! \brief
|
||||
//! different types of input matrices
|
||||
//! A -> complex, B -> basic element type
|
||||
template<typename T>
|
||||
inline
|
||||
void
|
||||
@@ -84,9 +79,6 @@ glue_kron::direct_kron(Mat< std::complex<T> >& out, const Mat< std::complex<T> >
|
||||
|
||||
|
||||
|
||||
//! \brief
|
||||
//! different types of input matrices
|
||||
//! A -> basic element type, B -> complex
|
||||
template<typename T>
|
||||
inline
|
||||
void
|
||||
@@ -114,8 +106,6 @@ glue_kron::direct_kron(Mat< std::complex<T> >& out, const Mat<T>& A, const Mat<
|
||||
|
||||
|
||||
|
||||
//! \brief
|
||||
//! apply Kronecker product for two objects with same element type
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
@@ -144,4 +134,19 @@ glue_kron::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_kron>&
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_kron::apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_kron>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const quasi_unwrap<T1> UA(X.A);
|
||||
const quasi_unwrap<T2> UB(X.B);
|
||||
|
||||
glue_kron::direct_kron(out, UA.M, UB.M);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
@@ -36,7 +36,11 @@ struct glue_polyfit
|
||||
|
||||
template<typename T1, typename T2> inline static bool apply_direct(Mat<typename T1::elem_type>& out, const Base<typename T1::elem_type,T1>& X_expr, const Base<typename T1::elem_type, T2>& Y_expr, const uword N);
|
||||
|
||||
template<typename T1, typename T2> inline static bool apply_direct(Mat_noalias<typename T1::elem_type>& out, const Base<typename T1::elem_type,T1>& X_expr, const Base<typename T1::elem_type, T2>& Y_expr, const uword N);
|
||||
|
||||
template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_polyfit>& expr);
|
||||
|
||||
template<typename T1, typename T2> inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_polyfit>& expr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -83,11 +83,7 @@ glue_polyfit::apply_direct(Mat<typename T1::elem_type>& out, const Base<typename
|
||||
|
||||
arma_conform_check( (X.n_elem != Y.n_elem), "polyfit(): given vectors must have the same number of elements" );
|
||||
|
||||
if(X.n_elem == 0)
|
||||
{
|
||||
out.reset();
|
||||
return true;
|
||||
}
|
||||
if(X.n_elem == 0) { out.reset(); return true; }
|
||||
|
||||
arma_conform_check( (N >= X.n_elem), "polyfit(): N must be less than the number of elements in X" );
|
||||
|
||||
@@ -99,7 +95,9 @@ glue_polyfit::apply_direct(Mat<typename T1::elem_type>& out, const Base<typename
|
||||
if(UX.is_alias(out) || UY.is_alias(out))
|
||||
{
|
||||
Mat<eT> tmp;
|
||||
|
||||
status = glue_polyfit::apply_noalias(tmp, X_as_colvec, Y_as_colvec, N);
|
||||
|
||||
out.steal_mem(tmp);
|
||||
}
|
||||
else
|
||||
@@ -112,6 +110,41 @@ glue_polyfit::apply_direct(Mat<typename T1::elem_type>& out, const Base<typename
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
bool
|
||||
glue_polyfit::apply_direct(Mat_noalias<typename T1::elem_type>& out, const Base<typename T1::elem_type,T1>& X_expr, const Base<typename T1::elem_type, T2>& Y_expr, const uword N)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
const quasi_unwrap<T1> UX(X_expr.get_ref());
|
||||
const quasi_unwrap<T2> UY(Y_expr.get_ref());
|
||||
|
||||
const Mat<eT>& X = UX.M;
|
||||
const Mat<eT>& Y = UY.M;
|
||||
|
||||
arma_conform_check
|
||||
(
|
||||
( ((X.is_vec() == false) && (X.is_empty() == false)) || ((Y.is_vec() == false) && (Y.is_empty() == false)) ),
|
||||
"polyfit(): given object must be a vector"
|
||||
);
|
||||
|
||||
arma_conform_check( (X.n_elem != Y.n_elem), "polyfit(): given vectors must have the same number of elements" );
|
||||
|
||||
if(X.n_elem == 0) { out.reset(); return true; }
|
||||
|
||||
arma_conform_check( (N >= X.n_elem), "polyfit(): N must be less than the number of elements in X" );
|
||||
|
||||
const Col<eT> X_as_colvec( const_cast<eT*>(X.memptr()), X.n_elem, false, false);
|
||||
const Col<eT> Y_as_colvec( const_cast<eT*>(Y.memptr()), Y.n_elem, false, false);
|
||||
|
||||
return glue_polyfit::apply_noalias(out, X_as_colvec, Y_as_colvec, N);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
@@ -130,4 +163,22 @@ glue_polyfit::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_poly
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_polyfit::apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_polyfit>& expr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const bool status = glue_polyfit::apply_direct(out, expr.A, expr.B, expr.aux_uword);
|
||||
|
||||
if(status == false)
|
||||
{
|
||||
out.soft_reset();
|
||||
arma_stop_runtime_error("polyfit(): failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
@@ -35,9 +35,10 @@ struct glue_polyval
|
||||
template<typename eT> inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& P, const Mat<eT>& X);
|
||||
|
||||
template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_polyval>& expr);
|
||||
|
||||
template<typename T1, typename T2> inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_polyval>& expr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
|
||||
@@ -55,29 +55,43 @@ glue_polyval::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_poly
|
||||
const quasi_unwrap<T1> UP(expr.A);
|
||||
const quasi_unwrap<T2> UX(expr.B);
|
||||
|
||||
const Mat<eT>& P = UP.M;
|
||||
const Mat<eT>& X = UX.M;
|
||||
arma_conform_check( ((UP.M.is_vec() == false) && (UP.M.is_empty() == false)), "polyval(): argument P must be a vector" );
|
||||
|
||||
arma_conform_check( ((P.is_vec() == false) && (P.is_empty() == false)), "polyval(): argument P must be a vector" );
|
||||
|
||||
if(P.is_empty() || X.is_empty())
|
||||
{
|
||||
out.zeros(X.n_rows, X.n_cols);
|
||||
return;
|
||||
}
|
||||
if(UP.M.is_empty() || UX.M.is_empty()) { out.zeros(UX.M.n_rows, UX.M.n_cols); return; }
|
||||
|
||||
if(UP.is_alias(out) || UX.is_alias(out))
|
||||
{
|
||||
Mat<eT> tmp;
|
||||
glue_polyval::apply_noalias(tmp, P, X);
|
||||
|
||||
glue_polyval::apply_noalias(tmp, UP.M, UX.M);
|
||||
|
||||
out.steal_mem(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
glue_polyval::apply_noalias(out, P, X);
|
||||
glue_polyval::apply_noalias(out, UP.M, UX.M);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_polyval::apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_polyval>& expr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const quasi_unwrap<T1> UP(expr.A);
|
||||
const quasi_unwrap<T2> UX(expr.B);
|
||||
|
||||
arma_conform_check( ((UP.M.is_vec() == false) && (UP.M.is_empty() == false)), "polyval(): argument P must be a vector" );
|
||||
|
||||
if(UP.M.is_empty() || UX.M.is_empty()) { out.zeros(UX.M.n_rows, UX.M.n_cols); return; }
|
||||
|
||||
glue_polyval::apply_noalias(out, UP.M, UX.M);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
@@ -32,6 +32,9 @@ struct glue_quantile
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply(Mat<typename T2::elem_type>& out, const mtGlue<typename T2::elem_type,T1,T2,glue_quantile>& expr);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply(Mat_noalias<typename T2::elem_type>& out, const mtGlue<typename T2::elem_type,T1,T2,glue_quantile>& expr);
|
||||
};
|
||||
|
||||
|
||||
@@ -48,6 +51,9 @@ struct glue_quantile_default
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply(Mat<typename T2::elem_type>& out, const mtGlue<typename T2::elem_type,T1,T2,glue_quantile_default>& expr);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply(Mat_noalias<typename T2::elem_type>& out, const mtGlue<typename T2::elem_type,T1,T2,glue_quantile_default>& expr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -196,6 +196,31 @@ glue_quantile::apply(Mat<typename T2::elem_type>& out, const mtGlue<typename T2:
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_quantile::apply(Mat_noalias<typename T2::elem_type>& out, const mtGlue<typename T2::elem_type,T1,T2,glue_quantile>& expr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword dim = expr.aux_uword;
|
||||
|
||||
arma_conform_check( (dim > 1), "quantile(): parameter 'dim' must be 0 or 1" );
|
||||
|
||||
const quasi_unwrap<T1> UA(expr.A);
|
||||
const quasi_unwrap<T2> UB(expr.B);
|
||||
|
||||
arma_conform_check((UA.M.internal_has_nan() || UB.M.internal_has_nan()), "quantile(): detected NaN");
|
||||
|
||||
glue_quantile::apply_noalias(out, UA.M, UB.M, dim);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
@@ -227,4 +252,23 @@ glue_quantile_default::apply(Mat<typename T2::elem_type>& out, const mtGlue<type
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_quantile_default::apply(Mat_noalias<typename T2::elem_type>& out, const mtGlue<typename T2::elem_type,T1,T2,glue_quantile_default>& expr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const quasi_unwrap<T1> UA(expr.A);
|
||||
const quasi_unwrap<T2> UB(expr.B);
|
||||
|
||||
const uword dim = (T1::is_xvec) ? uword(UA.M.is_rowvec() ? 1 : 0) : uword((T1::is_row) ? 1 : 0);
|
||||
|
||||
arma_conform_check((UA.M.internal_has_nan() || UB.M.internal_has_nan()), "quantile(): detected NaN");
|
||||
|
||||
glue_quantile::apply_noalias(out, UA.M, UB.M, dim);
|
||||
}
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
@@ -380,7 +380,7 @@ glue_solve_gen_full::apply(Mat<eT>& actual_out, const Base<eT,T1>& A_expr, const
|
||||
}
|
||||
else
|
||||
{
|
||||
arma_warn(2, "solve(): system is singular (rcond: ", rcond, "); attempting approx solution");
|
||||
arma_warn(2, "solve(): system is singular; rcond: ", rcond, "; attempting approx solution");
|
||||
}
|
||||
|
||||
// TODO: conditionally recreate A: have a separate state flag which indicates whether A was previously overwritten
|
||||
@@ -472,7 +472,7 @@ glue_solve_tri_default::apply(Mat<eT>& actual_out, const Base<eT,T1>& A_expr, co
|
||||
}
|
||||
else
|
||||
{
|
||||
arma_warn(2, "solve(): system is singular (rcond: ", rcond, "); attempting approx solution");
|
||||
arma_warn(2, "solve(): system is singular; rcond: ", rcond, "; attempting approx solution");
|
||||
}
|
||||
|
||||
Mat<eT> triA = (triu) ? trimatu(A) : trimatl(A); // trimatu() and trimatl() return the same type
|
||||
@@ -598,7 +598,7 @@ glue_solve_tri_full::apply(Mat<eT>& actual_out, const Base<eT,T1>& A_expr, const
|
||||
}
|
||||
else
|
||||
{
|
||||
arma_warn(2, "solve(): system is singular (rcond: ", rcond, "); attempting approx solution");
|
||||
arma_warn(2, "solve(): system is singular; rcond: ", rcond, "; attempting approx solution");
|
||||
}
|
||||
|
||||
Mat<eT> triA = (triu) ? trimatu(A) : trimatl(A); // trimatu() and trimatl() return the same type
|
||||
|
||||
@@ -40,7 +40,7 @@ struct depth_lhs< glue_type, Glue<T1,T2,glue_type> >
|
||||
|
||||
|
||||
|
||||
template<bool do_inv_detect>
|
||||
template<bool do_inv_detect, bool check_alias>
|
||||
struct glue_times_redirect2_helper
|
||||
{
|
||||
template<typename T1, typename T2>
|
||||
@@ -48,8 +48,8 @@ struct glue_times_redirect2_helper
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct glue_times_redirect2_helper<true>
|
||||
template<bool check_alias>
|
||||
struct glue_times_redirect2_helper<true, check_alias>
|
||||
{
|
||||
template<typename T1, typename T2>
|
||||
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
|
||||
@@ -57,7 +57,7 @@ struct glue_times_redirect2_helper<true>
|
||||
|
||||
|
||||
|
||||
template<bool do_inv_detect>
|
||||
template<bool do_inv_detect, bool check_alias>
|
||||
struct glue_times_redirect3_helper
|
||||
{
|
||||
template<typename T1, typename T2, typename T3>
|
||||
@@ -65,8 +65,8 @@ struct glue_times_redirect3_helper
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct glue_times_redirect3_helper<true>
|
||||
template<bool check_alias>
|
||||
struct glue_times_redirect3_helper<true, check_alias>
|
||||
{
|
||||
template<typename T1, typename T2, typename T3>
|
||||
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>,T3,glue_times>& X);
|
||||
@@ -74,7 +74,7 @@ struct glue_times_redirect3_helper<true>
|
||||
|
||||
|
||||
|
||||
template<uword N>
|
||||
template<uword N, bool check_alias>
|
||||
struct glue_times_redirect
|
||||
{
|
||||
template<typename T1, typename T2>
|
||||
@@ -82,24 +82,24 @@ struct glue_times_redirect
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct glue_times_redirect<2>
|
||||
template<bool check_alias>
|
||||
struct glue_times_redirect<2, check_alias>
|
||||
{
|
||||
template<typename T1, typename T2>
|
||||
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct glue_times_redirect<3>
|
||||
template<bool check_alias>
|
||||
struct glue_times_redirect<3, check_alias>
|
||||
{
|
||||
template<typename T1, typename T2, typename T3>
|
||||
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>,T3,glue_times>& X);
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct glue_times_redirect<4>
|
||||
template<bool check_alias>
|
||||
struct glue_times_redirect<4, check_alias>
|
||||
{
|
||||
template<typename T1, typename T2, typename T3, typename T4>
|
||||
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X);
|
||||
@@ -121,6 +121,9 @@ struct glue_times
|
||||
template<typename T1, typename T2>
|
||||
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_hot inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
|
||||
|
||||
|
||||
template<typename T1>
|
||||
arma_hot inline static void apply_inplace(Mat<typename T1::elem_type>& out, const T1& X);
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
|
||||
|
||||
|
||||
template<bool do_inv_detect>
|
||||
template<bool do_inv_detect, bool check_alias>
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_times_redirect2_helper<do_inv_detect>::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X)
|
||||
glue_times_redirect2_helper<do_inv_detect, check_alias>::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
@@ -55,7 +55,7 @@ glue_times_redirect2_helper<do_inv_detect>::apply(Mat<typename T1::elem_type>& o
|
||||
return;
|
||||
}
|
||||
|
||||
const bool alias = U1.is_alias(out) || U2.is_alias(out);
|
||||
const bool alias = (check_alias) && (U1.is_alias(out) || U2.is_alias(out));
|
||||
|
||||
if(alias == false)
|
||||
{
|
||||
@@ -87,10 +87,11 @@ glue_times_redirect2_helper<do_inv_detect>::apply(Mat<typename T1::elem_type>& o
|
||||
|
||||
|
||||
|
||||
template<bool check_alias>
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_times_redirect2_helper<true>::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X)
|
||||
glue_times_redirect2_helper<true, check_alias>::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
@@ -148,14 +149,27 @@ glue_times_redirect2_helper<true>::apply(Mat<typename T1::elem_type>& out, const
|
||||
if(is_cx<eT>::yes) { arma_warn(1, "inv_sympd(): given matrix is not hermitian"); }
|
||||
}
|
||||
|
||||
const unwrap_check<T2> B_tmp(X.B, out);
|
||||
const Mat<eT>& B = B_tmp.M;
|
||||
const quasi_unwrap<T2> UB(X.B);
|
||||
const Mat<eT>& B = UB.M;
|
||||
|
||||
arma_conform_assert_mul_size(A, B, "matrix multiplication");
|
||||
|
||||
const bool is_sym = (strip_inv<T1>::do_inv_spd) ? false : ( arma_config::optimise_sym && (is_sym_expr<T1>::eval(X.A) || sym_helper::is_approx_sym(A, uword(100))) );
|
||||
|
||||
const bool status = (strip_inv<T1>::do_inv_spd) ? auxlib::solve_sympd_fast(out, A, B) : ( (is_sym) ? auxlib::solve_sym_fast(out, A, B) : auxlib::solve_square_fast(out, A, B) );
|
||||
bool status = false;
|
||||
|
||||
if( (check_alias) && UB.is_alias(out) )
|
||||
{
|
||||
Mat<eT> tmp;
|
||||
|
||||
status = (strip_inv<T1>::do_inv_spd) ? auxlib::solve_sympd_fast(tmp, A, B) : ( (is_sym) ? auxlib::solve_sym_fast(tmp, A, B) : auxlib::solve_square_fast(tmp, A, B) );
|
||||
|
||||
out.steal_mem(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = (strip_inv<T1>::do_inv_spd) ? auxlib::solve_sympd_fast(out, A, B) : ( (is_sym) ? auxlib::solve_sym_fast(out, A, B) : auxlib::solve_square_fast(out, A, B) );
|
||||
}
|
||||
|
||||
if(status == false)
|
||||
{
|
||||
@@ -202,16 +216,16 @@ glue_times_redirect2_helper<true>::apply(Mat<typename T1::elem_type>& out, const
|
||||
return;
|
||||
}
|
||||
|
||||
glue_times_redirect2_helper<false>::apply(out, X);
|
||||
glue_times_redirect2_helper<false, check_alias>::apply(out, X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<bool do_inv_detect>
|
||||
template<bool do_inv_detect, bool check_alias>
|
||||
template<typename T1, typename T2, typename T3>
|
||||
inline
|
||||
void
|
||||
glue_times_redirect3_helper<do_inv_detect>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
|
||||
glue_times_redirect3_helper<do_inv_detect, check_alias>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
@@ -231,7 +245,7 @@ glue_times_redirect3_helper<do_inv_detect>::apply(Mat<typename T1::elem_type>& o
|
||||
constexpr bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times || partial_unwrap<T3>::do_times;
|
||||
const eT alpha = use_alpha ? (U1.get_val() * U2.get_val() * U3.get_val()) : eT(0);
|
||||
|
||||
const bool alias = U1.is_alias(out) || U2.is_alias(out) || U3.is_alias(out);
|
||||
const bool alias = (check_alias) && (U1.is_alias(out) || U2.is_alias(out) || U3.is_alias(out));
|
||||
|
||||
if(alias == false)
|
||||
{
|
||||
@@ -265,10 +279,11 @@ glue_times_redirect3_helper<do_inv_detect>::apply(Mat<typename T1::elem_type>& o
|
||||
|
||||
|
||||
|
||||
template<bool check_alias>
|
||||
template<typename T1, typename T2, typename T3>
|
||||
inline
|
||||
void
|
||||
glue_times_redirect3_helper<true>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
|
||||
glue_times_redirect3_helper<true, check_alias>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
@@ -371,7 +386,7 @@ glue_times_redirect3_helper<true>::apply(Mat<typename T1::elem_type>& out, const
|
||||
constexpr bool use_alpha = partial_unwrap<T1>::do_times;
|
||||
const eT alpha = use_alpha ? U1.get_val() : eT(0);
|
||||
|
||||
if(U1.is_alias(out))
|
||||
if( (check_alias) && U1.is_alias(out) )
|
||||
{
|
||||
Mat<eT> tmp;
|
||||
|
||||
@@ -388,16 +403,16 @@ glue_times_redirect3_helper<true>::apply(Mat<typename T1::elem_type>& out, const
|
||||
}
|
||||
|
||||
|
||||
glue_times_redirect3_helper<false>::apply(out, X);
|
||||
glue_times_redirect3_helper<false, check_alias>::apply(out, X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<uword N>
|
||||
template<uword N, bool check_alias>
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X)
|
||||
glue_times_redirect<N, check_alias>::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
@@ -412,7 +427,7 @@ glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2
|
||||
constexpr bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times;
|
||||
const eT alpha = use_alpha ? (U1.get_val() * U2.get_val()) : eT(0);
|
||||
|
||||
const bool alias = U1.is_alias(out) || U2.is_alias(out);
|
||||
const bool alias = (check_alias) && (U1.is_alias(out) || U2.is_alias(out));
|
||||
|
||||
if(alias == false)
|
||||
{
|
||||
@@ -444,38 +459,41 @@ glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2
|
||||
|
||||
|
||||
|
||||
template<bool check_alias>
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_times_redirect<2>::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X)
|
||||
glue_times_redirect<2, check_alias>::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
glue_times_redirect2_helper< is_blas_type<eT>::value >::apply(out, X);
|
||||
glue_times_redirect2_helper< is_blas_type<eT>::value, check_alias >::apply(out, X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<bool check_alias>
|
||||
template<typename T1, typename T2, typename T3>
|
||||
inline
|
||||
void
|
||||
glue_times_redirect<3>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
|
||||
glue_times_redirect<3, check_alias>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
glue_times_redirect3_helper< is_blas_type<eT>::value >::apply(out, X);
|
||||
glue_times_redirect3_helper< is_blas_type<eT>::value, check_alias >::apply(out, X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<bool check_alias>
|
||||
template<typename T1, typename T2, typename T3, typename T4>
|
||||
inline
|
||||
void
|
||||
glue_times_redirect<4>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X)
|
||||
glue_times_redirect<4, check_alias>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
@@ -497,7 +515,7 @@ glue_times_redirect<4>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue
|
||||
constexpr bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times || partial_unwrap<T3>::do_times || partial_unwrap<T4>::do_times;
|
||||
const eT alpha = use_alpha ? (U1.get_val() * U2.get_val() * U3.get_val() * U4.get_val()) : eT(0);
|
||||
|
||||
const bool alias = U1.is_alias(out) || U2.is_alias(out) || U3.is_alias(out) || U4.is_alias(out);
|
||||
const bool alias = (check_alias) && (U1.is_alias(out) || U2.is_alias(out) || U3.is_alias(out) || U4.is_alias(out));
|
||||
|
||||
if(alias == false)
|
||||
{
|
||||
@@ -544,7 +562,23 @@ glue_times::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>
|
||||
|
||||
arma_debug_print(arma_str::format("glue_times::apply(): N_mat: %u") % N_mat);
|
||||
|
||||
glue_times_redirect<N_mat>::apply(out, X);
|
||||
glue_times_redirect<N_mat, true>::apply(out, X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_times::apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
constexpr uword N_mat = 1 + depth_lhs< glue_times, Glue<T1,T2,glue_times> >::num;
|
||||
|
||||
arma_debug_print(arma_str::format("glue_times::apply(): N_mat: %u") % N_mat);
|
||||
|
||||
glue_times_redirect<N_mat, false>::apply(out, X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ struct glue_trapz
|
||||
|
||||
template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_trapz>& in);
|
||||
|
||||
template<typename T1, typename T2> inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_trapz>& in);
|
||||
|
||||
template<typename eT> inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& X, const Mat<eT>& Y, const uword dim);
|
||||
};
|
||||
|
||||
@@ -44,6 +46,8 @@ struct op_trapz
|
||||
{
|
||||
template<typename T1> inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trapz>& in);
|
||||
|
||||
template<typename T1> inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_trapz>& in);
|
||||
|
||||
template<typename eT> inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& Y, const uword dim);
|
||||
};
|
||||
|
||||
|
||||
@@ -51,6 +51,23 @@ glue_trapz::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_trapz>
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
glue_trapz::apply(Mat_noalias<typename T1::elem_type>& out, const Glue<T1,T2,glue_trapz>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword dim = in.aux_uword;
|
||||
|
||||
const quasi_unwrap<T1> UX(in.A);
|
||||
const quasi_unwrap<T2> UY(in.B);
|
||||
|
||||
glue_trapz::apply_noalias(out, UX.M, UY.M, dim);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
void
|
||||
@@ -101,6 +118,10 @@ glue_trapz::apply_noalias(Mat<eT>& out, const Mat<eT>& X, const Mat<eT>& Y, cons
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
@@ -130,6 +151,22 @@ op_trapz::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trapz>& in)
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
op_trapz::apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_trapz>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword dim = in.aux_uword_a;
|
||||
|
||||
const quasi_unwrap<T1> UY(in.m);
|
||||
|
||||
op_trapz::apply_noalias(out, UY.M, dim);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
void
|
||||
|
||||
@@ -683,9 +683,9 @@ gmm_diag<eT>::learn
|
||||
|| (seed_mode == random_subset)
|
||||
|| (seed_mode == random_spread);
|
||||
|
||||
arma_conform_check( (dist_mode_ok == false), "gmm_diag::learn(): dist_mode must be eucl_dist or maha_dist" );
|
||||
arma_conform_check( (seed_mode_ok == false), "gmm_diag::learn(): unknown seed_mode" );
|
||||
arma_conform_check( (var_floor < eT(0) ), "gmm_diag::learn(): variance floor is negative" );
|
||||
arma_conform_check( (dist_mode_ok == false), "gmm_diag::learn(): dist_mode must be eucl_dist or maha_dist" );
|
||||
arma_conform_check( (seed_mode_ok == false), "gmm_diag::learn(): unknown seed_mode" );
|
||||
arma_conform_check( ((var_floor >= eT(0)) == false), "gmm_diag::learn(): variance floor must be > 0" );
|
||||
|
||||
const unwrap<T1> tmp_X(data.get_ref());
|
||||
const Mat<eT>& X = tmp_X.M;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user