Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc2e8d5fcc | ||
|
|
c8b3ac8df1 | ||
|
|
fef5c5954d | ||
|
|
9ce600b03b | ||
|
|
37744f9a3c | ||
|
|
1954f4a1d8 | ||
|
|
9d731a6565 | ||
|
|
c7ffb88d54 | ||
|
|
fe2930b966 | ||
|
|
25aca17550 | ||
|
|
23f652e542 | ||
|
|
c6f4af01d8 | ||
|
|
1441e9f1a0 | ||
|
|
f41149d528 | ||
|
|
3d7fd53b53 | ||
|
|
340a1b3592 | ||
|
|
07414596d4 | ||
|
|
585b369988 | ||
|
|
a957b25a29 | ||
|
|
61bb3e0ae8 | ||
|
|
d5f00fd4a8 | ||
|
|
4dc011f5d3 | ||
|
|
922ccf9154 | ||
|
|
ba33c24e8a | ||
|
|
fea46c6f84 | ||
|
|
033c93196c | ||
|
|
453bef9283 | ||
|
|
598df0100e | ||
|
|
45347ce825 | ||
|
|
3318e018d0 | ||
|
|
8d350a1534 | ||
|
|
11b885085a | ||
|
|
724dc98eb8 | ||
|
|
452a6c1b49 | ||
|
|
5c2892a2b5 | ||
|
|
88003f8ab8 | ||
|
|
248ce5fe7f | ||
|
|
e493eb3b34 | ||
|
|
03411c40a6 | ||
|
|
3c6c443be6 | ||
|
|
a638683e6f | ||
|
|
e299f5e189 | ||
|
|
053de98101 | ||
|
|
6b1ce2116b | ||
|
|
b7afc7e5fb | ||
|
|
1e61d46e5b | ||
|
|
139d9f4d62 | ||
|
|
f123904e82 | ||
|
|
6e224f38bd | ||
|
|
c088151876 | ||
|
|
a839bc49d3 | ||
|
|
c13b71fc69 | ||
|
|
69fc9f29a0 | ||
|
|
730594f6da | ||
|
|
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 |
+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,8 @@ 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. [Related Software Using Armadillo](#15-related-software-using-armadillo)
|
||||
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)
|
||||
|
||||
---
|
||||
|
||||
@@ -390,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`.
|
||||
|
||||
---
|
||||
|
||||
@@ -451,7 +452,16 @@ https://arma.sourceforge.net/faq.html
|
||||
|
||||
---
|
||||
|
||||
### 15: Related Software Using Armadillo
|
||||
### 15: Prohibition on Use of Large Language Models (LLMs)
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
### 16: Related Software Using Armadillo
|
||||
|
||||
* MLPACK: extensive library of machine learning algorithms
|
||||
https://mlpack.org
|
||||
|
||||
Binary file not shown.
@@ -306,6 +306,7 @@ namespace arma
|
||||
#include "armadillo_bits/op_orth_null_bones.hpp"
|
||||
#include "armadillo_bits/op_relational_bones.hpp"
|
||||
#include "armadillo_bits/op_find_bones.hpp"
|
||||
#include "armadillo_bits/op_find_aux_bones.hpp"
|
||||
#include "armadillo_bits/op_find_unique_bones.hpp"
|
||||
#include "armadillo_bits/op_chol_bones.hpp"
|
||||
#include "armadillo_bits/op_cx_scalar_bones.hpp"
|
||||
@@ -765,6 +766,7 @@ namespace arma
|
||||
#include "armadillo_bits/op_orth_null_meat.hpp"
|
||||
#include "armadillo_bits/op_relational_meat.hpp"
|
||||
#include "armadillo_bits/op_find_meat.hpp"
|
||||
#include "armadillo_bits/op_find_aux_meat.hpp"
|
||||
#include "armadillo_bits/op_find_unique_meat.hpp"
|
||||
#include "armadillo_bits/op_chol_meat.hpp"
|
||||
#include "armadillo_bits/op_cx_scalar_meat.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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ class Col : public Mat<eT>
|
||||
static constexpr bool is_row = false;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = false;
|
||||
|
||||
inline Col();
|
||||
inline Col(const Col<eT>& X);
|
||||
|
||||
@@ -67,9 +69,6 @@ class Col : public Mat<eT>
|
||||
inline Col(Col&& m);
|
||||
inline Col& operator=(Col&& m);
|
||||
|
||||
// inline Col(Mat<eT>&& m);
|
||||
// inline Col& operator=(Mat<eT>&& m);
|
||||
|
||||
inline Col& operator=(const eT val);
|
||||
inline Col& operator=(const Col& m);
|
||||
|
||||
@@ -153,6 +152,7 @@ class Col : public Mat<eT>
|
||||
arma_warn_unused arma_inline eT& at(const uword in_row, const uword in_col);
|
||||
arma_warn_unused arma_inline const eT& at(const uword in_row, const uword in_col) const;
|
||||
|
||||
inline void push_back(const eT val);
|
||||
|
||||
inline constexpr bool is_vec() const { return true; }
|
||||
inline constexpr bool is_rowvec() const { return false; }
|
||||
@@ -210,6 +210,8 @@ class Col<eT>::fixed : public Col<eT>
|
||||
static constexpr bool is_row = false;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = false;
|
||||
|
||||
static const uword n_rows; // value provided below the class definition
|
||||
static const uword n_cols; // value provided below the class definition
|
||||
static const uword n_elem; // value provided below the class definition
|
||||
@@ -265,6 +267,8 @@ class Col<eT>::fixed : public Col<eT>
|
||||
arma_warn_unused arma_inline eT& operator() (const uword in_row, const uword in_col);
|
||||
arma_warn_unused arma_inline const eT& operator() (const uword in_row, const uword in_col) const;
|
||||
|
||||
inline void push_back(const eT) = delete;
|
||||
|
||||
arma_warn_unused arma_inline eT* memptr();
|
||||
arma_warn_unused arma_inline const eT* memptr() const;
|
||||
|
||||
|
||||
@@ -431,64 +431,6 @@ Col<eT>::operator=(Col<eT>&& X)
|
||||
|
||||
|
||||
|
||||
// template<typename eT>
|
||||
// inline
|
||||
// Col<eT>::Col(Mat<eT>&& X)
|
||||
// : Mat<eT>(arma_vec_indicator(), 1)
|
||||
// {
|
||||
// arma_debug_sigprint(arma_str::format("this: %x; X: %x") % this % &X);
|
||||
//
|
||||
// if(X.n_cols != 1) { const Mat<eT>& XX = X; Mat<eT>::operator=(XX); return; }
|
||||
//
|
||||
// access::rw(Mat<eT>::n_rows) = X.n_rows;
|
||||
// access::rw(Mat<eT>::n_cols) = 1;
|
||||
// access::rw(Mat<eT>::n_elem) = X.n_elem;
|
||||
// access::rw(Mat<eT>::n_alloc) = X.n_alloc;
|
||||
//
|
||||
// if( (X.n_alloc > arma_config::mat_prealloc) || (X.mem_state == 1) || (X.mem_state == 2) )
|
||||
// {
|
||||
// access::rw(Mat<eT>::mem_state) = X.mem_state;
|
||||
// access::rw(Mat<eT>::mem) = X.mem;
|
||||
//
|
||||
// access::rw(X.n_rows) = 0;
|
||||
// access::rw(X.n_elem) = 0;
|
||||
// access::rw(X.n_alloc) = 0;
|
||||
// access::rw(X.mem_state) = 0;
|
||||
// access::rw(X.mem) = nullptr;
|
||||
// }
|
||||
// else // condition: (X.n_alloc <= arma_config::mat_prealloc) || (X.mem_state == 0) || (X.mem_state == 3)
|
||||
// {
|
||||
// (*this).init_cold();
|
||||
//
|
||||
// arrayops::copy( (*this).memptr(), X.mem, X.n_elem );
|
||||
//
|
||||
// if( (X.mem_state == 0) && (X.n_alloc <= arma_config::mat_prealloc) )
|
||||
// {
|
||||
// access::rw(X.n_rows) = 0;
|
||||
// access::rw(X.n_elem) = 0;
|
||||
// access::rw(X.mem) = nullptr;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// template<typename eT>
|
||||
// inline
|
||||
// Col<eT>&
|
||||
// Col<eT>::operator=(Mat<eT>&& X)
|
||||
// {
|
||||
// arma_debug_sigprint(arma_str::format("this: %x; X: %x") % this % &X);
|
||||
//
|
||||
// if(X.n_cols != 1) { const Mat<eT>& XX = X; Mat<eT>::operator=(XX); return *this; }
|
||||
//
|
||||
// (*this).steal_mem(X, true);
|
||||
//
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
Col<eT>&
|
||||
@@ -1208,6 +1150,25 @@ Col<eT>::at(const uword in_row, const uword) const
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
void
|
||||
Col<eT>::push_back(const eT val)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
if(Mat<eT>::mem_state != 0)
|
||||
{
|
||||
arma_conform_check(true, "Col::push_back(): unsupported operation as auxiliary memory is in use");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Mat<eT>::vec_push_back(val, arma_colvec_indicator());
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
typename Col<eT>::row_iterator
|
||||
@@ -1344,6 +1305,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>() ); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ struct CubeToMatOp : public Base< typename T1::elem_type, CubeToMatOp<T1, op_typ
|
||||
static constexpr bool is_row = op_type::template traits<T1>::is_row;
|
||||
static constexpr bool is_col = op_type::template traits<T1>::is_col;
|
||||
static constexpr bool is_xvec = op_type::template traits<T1>::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -82,6 +82,8 @@ class Cube : public BaseCube< eT, Cube<eT> >
|
||||
|
||||
public:
|
||||
|
||||
static constexpr bool has_subview = false;
|
||||
|
||||
inline ~Cube();
|
||||
inline Cube();
|
||||
|
||||
@@ -360,6 +362,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -817,11 +807,29 @@ Cube<eT>::Cube(eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols, cons
|
||||
{
|
||||
init_cold();
|
||||
|
||||
arrayops::copy( memptr(), aux_mem, n_elem );
|
||||
if(aux_mem == nullptr)
|
||||
{
|
||||
arrayops::fill_zeros(memptr(), n_elem);
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayops::copy( memptr(), aux_mem, n_elem );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
create_mat();
|
||||
if(aux_mem == nullptr)
|
||||
{
|
||||
access::rw(mem_state) = 0;
|
||||
|
||||
init_cold();
|
||||
|
||||
arrayops::fill_zeros(memptr(), n_elem);
|
||||
}
|
||||
else
|
||||
{
|
||||
create_mat();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -845,7 +853,14 @@ Cube<eT>::Cube(const eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols
|
||||
|
||||
init_cold();
|
||||
|
||||
arrayops::copy( memptr(), aux_mem, n_elem );
|
||||
if(aux_mem == nullptr)
|
||||
{
|
||||
arrayops::fill_zeros(memptr(), n_elem);
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayops::copy( memptr(), aux_mem, n_elem );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -934,7 +949,7 @@ Cube<eT>::Cube
|
||||
, n_elem(0)
|
||||
, n_alloc(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -1064,7 +1079,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 +2766,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 +3063,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,7 +3159,7 @@ 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);
|
||||
|
||||
@@ -3401,7 +3416,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 +3902,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 +3913,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 +3924,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 +3935,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 +4212,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 +4242,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 +5497,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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,8 +28,9 @@ struct GenCube
|
||||
typedef eT elem_type;
|
||||
typedef typename get_pod_type<elem_type>::result pod_type;
|
||||
|
||||
static constexpr bool use_at = false;
|
||||
static constexpr bool is_simple = (is_same_type<gen_type, gen_ones>::value) || (is_same_type<gen_type, gen_zeros>::value);
|
||||
static constexpr bool use_at = false;
|
||||
static constexpr bool is_simple = (is_same_type<gen_type, gen_ones>::value) || (is_same_type<gen_type, gen_zeros>::value);
|
||||
static constexpr bool has_subview = false;
|
||||
|
||||
const uword n_rows;
|
||||
const uword n_cols;
|
||||
|
||||
@@ -35,6 +35,8 @@ struct Gen
|
||||
static constexpr bool is_col = T1::is_col;
|
||||
static constexpr bool is_xvec = T1::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = false;
|
||||
|
||||
const uword n_rows;
|
||||
const uword n_cols;
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ struct GlueCube : public BaseCube< typename T1::elem_type, GlueCube<T1, T2, glue
|
||||
typedef typename T1::elem_type elem_type;
|
||||
typedef typename get_pod_type<elem_type>::result pod_type;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview || T2::has_subview;
|
||||
|
||||
inline GlueCube(const BaseCube<typename T1::elem_type, T1>& in_A, const BaseCube<typename T1::elem_type, T2>& in_B);
|
||||
inline ~GlueCube();
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ struct Glue
|
||||
typedef typename T1::elem_type elem_type;
|
||||
typedef typename get_pod_type<elem_type>::result pod_type;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview || T2::has_subview;
|
||||
|
||||
inline Glue(const T1& in_A, const T2& in_B);
|
||||
inline Glue(const T1& in_A, const T2& in_B, const uword in_aux_uword);
|
||||
inline ~Glue();
|
||||
|
||||
@@ -57,6 +57,8 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
static constexpr bool is_row = false;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = false;
|
||||
|
||||
inline ~Mat();
|
||||
inline Mat();
|
||||
|
||||
@@ -452,6 +454,8 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
arma_warn_unused arma_inline eT& operator() (const uword in_row, const uword in_col);
|
||||
arma_warn_unused arma_inline const eT& operator() (const uword in_row, const uword in_col) const;
|
||||
|
||||
inline void push_back(const eT val);
|
||||
|
||||
arma_inline const Mat& operator++();
|
||||
arma_inline void operator++(int);
|
||||
|
||||
@@ -819,6 +823,8 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
|
||||
inline Mat(const arma_fixed_indicator&, const uword in_n_rows, const uword in_n_cols, const uhword in_vec_state, const eT* in_mem);
|
||||
|
||||
template<int vec_mode> inline void vec_push_back(const eT val, const arma_vec_mode_indicator<vec_mode>&);
|
||||
|
||||
|
||||
friend class Cube<eT>;
|
||||
friend class subview_cube<eT>;
|
||||
@@ -830,7 +836,7 @@ class Mat : public Base< eT, Mat<eT> >
|
||||
friend struct op_mean;
|
||||
friend struct op_max;
|
||||
friend struct op_min;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@@ -866,6 +872,8 @@ class Mat<eT>::fixed : public Mat<eT>
|
||||
static constexpr bool is_row = (fixed_n_rows == 1);
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = false;
|
||||
|
||||
static const uword n_rows; // value provided below the class definition
|
||||
static const uword n_cols; // value provided below the class definition
|
||||
static const uword n_elem; // value provided below the class definition
|
||||
@@ -922,12 +930,20 @@ class Mat<eT>::fixed : public Mat<eT>
|
||||
arma_warn_unused arma_inline eT& operator() (const uword in_row, const uword in_col);
|
||||
arma_warn_unused arma_inline const eT& operator() (const uword in_row, const uword in_col) const;
|
||||
|
||||
inline void push_back(const eT) = delete;
|
||||
|
||||
arma_warn_unused arma_inline eT* colptr(const uword in_col);
|
||||
arma_warn_unused arma_inline const eT* colptr(const uword in_col) const;
|
||||
|
||||
arma_warn_unused arma_inline eT* memptr();
|
||||
arma_warn_unused arma_inline const eT* memptr() const;
|
||||
|
||||
arma_inline subview_row<eT> row(const uword row_num);
|
||||
arma_inline const subview_row<eT> row(const uword row_num) const;
|
||||
|
||||
arma_inline subview_col<eT> col(const uword col_num);
|
||||
arma_inline const subview_col<eT> col(const uword col_num) const;
|
||||
|
||||
arma_warn_unused arma_inline bool is_vec() const;
|
||||
|
||||
inline const Mat<eT>& fill(const eT val);
|
||||
|
||||
+358
-107
@@ -49,7 +49,7 @@ Mat<eT>::Mat()
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ Mat<eT>::Mat(const arma_vec_indicator&, const uhword in_vec_state)
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
}
|
||||
@@ -312,15 +312,10 @@ Mat<eT>::init_cold()
|
||||
const char* error_message = "Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD";
|
||||
#endif
|
||||
|
||||
arma_conform_check
|
||||
(
|
||||
(
|
||||
( (n_rows > ARMA_MAX_UHWORD) || (n_cols > ARMA_MAX_UHWORD) )
|
||||
? ( (double(n_rows) * double(n_cols)) > double(ARMA_MAX_UWORD) )
|
||||
: false
|
||||
),
|
||||
error_message
|
||||
);
|
||||
if( (n_rows > ARMA_MAX_UHWORD) || (n_cols > ARMA_MAX_UHWORD) )
|
||||
{
|
||||
arma_conform_check( ( (double(n_rows) * double(n_cols)) > double(ARMA_MAX_UWORD) ), error_message );
|
||||
}
|
||||
|
||||
if(n_elem <= arma_config::mat_prealloc)
|
||||
{
|
||||
@@ -383,17 +378,10 @@ Mat<eT>::init_warm(uword in_n_rows, uword in_n_cols)
|
||||
const char* error_message_4 = "Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD";
|
||||
#endif
|
||||
|
||||
arma_conform_set_error
|
||||
(
|
||||
err_state,
|
||||
err_msg,
|
||||
(
|
||||
( (in_n_rows > ARMA_MAX_UHWORD) || (in_n_cols > ARMA_MAX_UHWORD) )
|
||||
? ( (double(in_n_rows) * double(in_n_cols)) > double(ARMA_MAX_UWORD) )
|
||||
: false
|
||||
),
|
||||
error_message_4
|
||||
);
|
||||
if( (in_n_rows > ARMA_MAX_UHWORD) || (in_n_cols > ARMA_MAX_UHWORD) )
|
||||
{
|
||||
arma_conform_set_error( err_state, err_msg, ( (double(in_n_rows) * double(in_n_cols)) > double(ARMA_MAX_UWORD) ), error_message_4 );
|
||||
}
|
||||
|
||||
arma_conform_check(err_state, err_msg);
|
||||
|
||||
@@ -468,7 +456,7 @@ Mat<eT>::Mat(const char* text)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -502,7 +490,7 @@ Mat<eT>::Mat(const std::string& text)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -690,7 +678,7 @@ Mat<eT>::Mat(const std::initializer_list<eT>& list)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -722,7 +710,7 @@ Mat<eT>::Mat(const std::initializer_list< std::initializer_list<eT> >& list)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -889,7 +877,7 @@ Mat<eT>::Mat(const Mat<eT>& in_mat, const arma_vec_indicator&, const uhword in_v
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint(arma_str::format("this: %x; in_mat: %x") % this % &in_mat);
|
||||
|
||||
@@ -1381,7 +1369,23 @@ Mat<eT>::Mat(eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols, const
|
||||
{
|
||||
init_cold();
|
||||
|
||||
arrayops::copy( memptr(), aux_mem, n_elem );
|
||||
if(aux_mem == nullptr)
|
||||
{
|
||||
arrayops::fill_zeros(memptr(), n_elem);
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayops::copy( memptr(), aux_mem, n_elem );
|
||||
}
|
||||
}
|
||||
else
|
||||
if(aux_mem == nullptr)
|
||||
{
|
||||
access::rw(mem_state) = 0;
|
||||
|
||||
init_cold();
|
||||
|
||||
arrayops::fill_zeros(memptr(), n_elem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1404,7 +1408,14 @@ Mat<eT>::Mat(const eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols)
|
||||
|
||||
init_cold();
|
||||
|
||||
arrayops::copy( memptr(), aux_mem, n_elem );
|
||||
if(aux_mem == nullptr)
|
||||
{
|
||||
arrayops::fill_zeros(memptr(), n_elem);
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayops::copy( memptr(), aux_mem, n_elem );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1524,7 +1535,7 @@ Mat<eT>::Mat(const BaseCube<eT,T1>& X, const arma_vec_indicator&, const uhword i
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -1543,7 +1554,7 @@ Mat<eT>::Mat(const BaseCube<eT,T1>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -1990,7 +2001,7 @@ Mat<eT>::Mat(const Base<typename Mat<eT>::pod_type,T1>& A, const Base<typename M
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -2010,7 +2021,7 @@ Mat<eT>::Mat(const Base<typename Mat<eT>::pod_type,T1>& A, const Base<typename M
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -2055,7 +2066,7 @@ Mat<eT>::Mat(const subview<eT>& X, const arma_vec_indicator&, const uhword in_ve
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -2278,7 +2289,7 @@ Mat<eT>::Mat(const subview_cube<eT>& x, const arma_vec_indicator&, const uhword
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -2297,7 +2308,7 @@ Mat<eT>::Mat(const subview_cube<eT>& x)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -2407,7 +2418,7 @@ Mat<eT>::Mat(const diagview<eT>& X, const arma_vec_indicator&, const uhword in_v
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -2552,11 +2563,11 @@ Mat<eT>::Mat(const subview_elem1<eT,T1>& X, const arma_vec_indicator&, const uhw
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
(*this).operator=(X);
|
||||
subview_elem1<eT,T1>::extract_noalias(*this, X);
|
||||
}
|
||||
|
||||
|
||||
@@ -2571,11 +2582,11 @@ Mat<eT>::Mat(const subview_elem1<eT,T1>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
(*this).operator=(X);
|
||||
subview_elem1<eT,T1>::extract_noalias(*this, X);
|
||||
}
|
||||
|
||||
|
||||
@@ -2603,9 +2614,9 @@ Mat<eT>::operator+=(const subview_elem1<eT,T1>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
subview_elem1<eT,T1>::plus_inplace(*this, X);
|
||||
const Mat<eT> tmp(X);
|
||||
|
||||
return *this;
|
||||
return (*this).operator+=(tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -2618,9 +2629,9 @@ Mat<eT>::operator-=(const subview_elem1<eT,T1>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
subview_elem1<eT,T1>::minus_inplace(*this, X);
|
||||
const Mat<eT> tmp(X);
|
||||
|
||||
return *this;
|
||||
return (*this).operator-=(tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -2633,9 +2644,9 @@ Mat<eT>::operator*=(const subview_elem1<eT,T1>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
glue_times::apply_inplace(*this, X);
|
||||
const Mat<eT> tmp(X);
|
||||
|
||||
return *this;
|
||||
return (*this).operator*=(tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -2648,9 +2659,9 @@ Mat<eT>::operator%=(const subview_elem1<eT,T1>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
subview_elem1<eT,T1>::schur_inplace(*this, X);
|
||||
const Mat<eT> tmp(X);
|
||||
|
||||
return *this;
|
||||
return (*this).operator%=(tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -2663,9 +2674,9 @@ Mat<eT>::operator/=(const subview_elem1<eT,T1>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
subview_elem1<eT,T1>::div_inplace(*this, X);
|
||||
const Mat<eT> tmp(X);
|
||||
|
||||
return *this;
|
||||
return (*this).operator/=(tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -2680,11 +2691,11 @@ Mat<eT>::Mat(const subview_elem2<eT,T1,T2>& X, const arma_vec_indicator&, const
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
(*this).operator=(X);
|
||||
subview_elem2<eT,T1,T2>::extract_noalias(*this, X);
|
||||
}
|
||||
|
||||
|
||||
@@ -2699,11 +2710,11 @@ Mat<eT>::Mat(const subview_elem2<eT,T1,T2>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
(*this).operator=(X);
|
||||
subview_elem2<eT,T1,T2>::extract_noalias(*this, X);
|
||||
}
|
||||
|
||||
|
||||
@@ -2731,9 +2742,9 @@ Mat<eT>::operator+=(const subview_elem2<eT,T1,T2>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
subview_elem2<eT,T1,T2>::plus_inplace(*this, X);
|
||||
const Mat<eT> tmp(X);
|
||||
|
||||
return *this;
|
||||
return (*this).operator+=(tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -2746,9 +2757,9 @@ Mat<eT>::operator-=(const subview_elem2<eT,T1,T2>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
subview_elem2<eT,T1,T2>::minus_inplace(*this, X);
|
||||
const Mat<eT> tmp(X);
|
||||
|
||||
return *this;
|
||||
return (*this).operator-=(tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -2761,9 +2772,9 @@ Mat<eT>::operator*=(const subview_elem2<eT,T1,T2>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
glue_times::apply_inplace(*this, X);
|
||||
const Mat<eT> tmp(X);
|
||||
|
||||
return *this;
|
||||
return (*this).operator*=(tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -2776,9 +2787,9 @@ Mat<eT>::operator%=(const subview_elem2<eT,T1,T2>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
subview_elem2<eT,T1,T2>::schur_inplace(*this, X);
|
||||
const Mat<eT> tmp(X);
|
||||
|
||||
return *this;
|
||||
return (*this).operator%=(tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -2791,9 +2802,9 @@ Mat<eT>::operator/=(const subview_elem2<eT,T1,T2>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
subview_elem2<eT,T1,T2>::div_inplace(*this, X);
|
||||
const Mat<eT> tmp(X);
|
||||
|
||||
return *this;
|
||||
return (*this).operator/=(tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -2808,7 +2819,7 @@ Mat<eT>::Mat(const SpBase<eT, T1>& m, const arma_vec_indicator&, const uhword in
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -2827,7 +2838,7 @@ Mat<eT>::Mat(const SpBase<eT, T1>& m)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -2888,6 +2899,8 @@ Mat<eT>::operator+=(const SpBase<eT, T1>& m)
|
||||
|
||||
arma_conform_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(), "addition");
|
||||
|
||||
if(p.get_n_nonzero() == 0) { return *this; }
|
||||
|
||||
typename SpProxy<T1>::const_iterator_type it = p.begin();
|
||||
typename SpProxy<T1>::const_iterator_type it_end = p.end();
|
||||
|
||||
@@ -2910,6 +2923,8 @@ Mat<eT>::operator-=(const SpBase<eT, T1>& m)
|
||||
|
||||
arma_conform_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(), "subtraction");
|
||||
|
||||
if(p.get_n_nonzero() == 0) { return *this; }
|
||||
|
||||
typename SpProxy<T1>::const_iterator_type it = p.begin();
|
||||
typename SpProxy<T1>::const_iterator_type it_end = p.end();
|
||||
|
||||
@@ -2928,9 +2943,9 @@ Mat<eT>::operator*=(const SpBase<eT, T1>& m)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<eT> z = (*this) * m.get_ref();
|
||||
Mat<eT> tmp = (*this) * m.get_ref();
|
||||
|
||||
steal_mem(z);
|
||||
steal_mem(tmp);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -3011,7 +3026,7 @@ Mat<eT>::Mat(const SpSubview<eT>& X, const arma_vec_indicator&, const uhword in_
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -3029,7 +3044,7 @@ Mat<eT>::Mat(const SpSubview<eT>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -3212,7 +3227,7 @@ Mat<eT>::Mat(const spdiagview<eT>& X, const arma_vec_indicator&, const uhword in
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -4988,8 +5003,8 @@ Mat<eT>::insert_rows(const uword row_num, const Base<eT,T1>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(X.get_ref());
|
||||
const Mat<eT>& C = tmp.M;
|
||||
const plain_unwrap<T1> tmp(X.get_ref());
|
||||
const Mat<eT>& C = tmp.M;
|
||||
|
||||
const uword C_n_rows = C.n_rows;
|
||||
const uword C_n_cols = C.n_cols;
|
||||
@@ -5064,8 +5079,8 @@ Mat<eT>::insert_cols(const uword col_num, const Base<eT,T1>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(X.get_ref());
|
||||
const Mat<eT>& C = tmp.M;
|
||||
const plain_unwrap<T1> tmp(X.get_ref());
|
||||
const Mat<eT>& C = tmp.M;
|
||||
|
||||
const uword C_n_rows = C.n_rows;
|
||||
const uword C_n_cols = C.n_cols;
|
||||
@@ -5140,7 +5155,7 @@ Mat<eT>::Mat(const Gen<T1, gen_type>& X, const arma_vec_indicator&, const uhword
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -5290,7 +5305,7 @@ Mat<eT>::Mat(const Op<T1, op_type>& X, const arma_vec_indicator&, const uhword i
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -5312,7 +5327,7 @@ Mat<eT>::Mat(const Op<T1, op_type>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -5441,7 +5456,7 @@ Mat<eT>::Mat(const eOp<T1, eop_type>& X, const arma_vec_indicator&, const uhword
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -5669,7 +5684,7 @@ Mat<eT>::Mat(const mtOp<eT, T1, op_type>& X, const arma_vec_indicator&, const uh
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -5688,7 +5703,7 @@ Mat<eT>::Mat(const mtOp<eT, T1, op_type>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -5797,7 +5812,7 @@ Mat<eT>::Mat(const CubeToMatOp<T1, op_type>& X, const arma_vec_indicator&, const
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -5818,7 +5833,7 @@ Mat<eT>::Mat(const CubeToMatOp<T1, op_type>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -5941,7 +5956,7 @@ Mat<eT>::Mat(const SpToDOp<T1, op_type>& X, const arma_vec_indicator&, const uhw
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -5962,7 +5977,7 @@ Mat<eT>::Mat(const SpToDOp<T1, op_type>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -6091,7 +6106,7 @@ Mat<eT>::Mat(const mtSpReduceOp<eT, T1, op_type>& X, const arma_vec_indicator&,
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -6110,7 +6125,7 @@ Mat<eT>::Mat(const mtSpReduceOp<eT, T1, op_type>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -6219,7 +6234,7 @@ Mat<eT>::Mat(const Glue<T1, T2, glue_type>& X, const arma_vec_indicator&, const
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -6242,7 +6257,7 @@ Mat<eT>::Mat(const Glue<T1, T2, glue_type>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -6408,7 +6423,7 @@ Mat<eT>::Mat(const eGlue<T1, T2, eglue_type>& X, const arma_vec_indicator&, cons
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -6615,7 +6630,7 @@ Mat<eT>::Mat(const mtGlue<eT, T1, T2, glue_type>& X, const arma_vec_indicator&,
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -6634,7 +6649,7 @@ Mat<eT>::Mat(const mtGlue<eT, T1, T2, glue_type>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -6745,7 +6760,7 @@ Mat<eT>::Mat(const SpToDGlue<T1, T2, glue_type>& X, const arma_vec_indicator&, c
|
||||
, n_alloc(0)
|
||||
, vec_state(in_vec_state)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -6767,7 +6782,7 @@ Mat<eT>::Mat(const SpToDGlue<T1, T2, glue_type>& X)
|
||||
, n_alloc(0)
|
||||
, vec_state(0)
|
||||
, mem_state(0)
|
||||
, mem()
|
||||
, mem(nullptr)
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
@@ -7045,6 +7060,31 @@ Mat<eT>::at(const uword in_row, const uword in_col) const
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
void
|
||||
Mat<eT>::push_back(const eT val)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
if(mem_state != 0)
|
||||
{
|
||||
arma_conform_check(true, "Mat::push_back(): unsupported operation as auxiliary memory is in use");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const uword t_n_rows = n_rows;
|
||||
const uword t_n_cols = n_cols;
|
||||
|
||||
if( (vec_state == 1) || (t_n_cols == 1) || ((t_n_cols == 0) && (t_n_rows == 0)) ) { (*this).vec_push_back(val, arma_colvec_indicator()); return; }
|
||||
if( (vec_state == 2) || (t_n_rows == 1) ) { (*this).vec_push_back(val, arma_rowvec_indicator()); return; }
|
||||
|
||||
arma_conform_check(true, "Mat::push_back(): column or row vector layout required");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! prefix ++
|
||||
template<typename eT>
|
||||
arma_inline
|
||||
@@ -7487,7 +7527,7 @@ arma_inline
|
||||
eT*
|
||||
Mat<eT>::colptr(const uword in_col)
|
||||
{
|
||||
return & access::rw(mem[in_col*n_rows]);
|
||||
return access::rwp( mem + (in_col*n_rows) );
|
||||
}
|
||||
|
||||
|
||||
@@ -7498,7 +7538,7 @@ arma_inline
|
||||
const eT*
|
||||
Mat<eT>::colptr(const uword in_col) const
|
||||
{
|
||||
return & mem[in_col*n_rows];
|
||||
return mem + (in_col*n_rows);
|
||||
}
|
||||
|
||||
|
||||
@@ -7580,10 +7620,40 @@ Mat<eT>::resize(const uword new_n_elem)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem);
|
||||
const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 );
|
||||
const bool reuse_mem =
|
||||
( is_vec() && (mem_state == 0) )
|
||||
&&
|
||||
(
|
||||
( (new_n_elem <= arma_config::mat_prealloc) && (n_elem <= arma_config::mat_prealloc) && ( n_elem > 0 ) )
|
||||
|| ( (new_n_elem > arma_config::mat_prealloc) && (n_elem > arma_config::mat_prealloc) && (new_n_elem <= n_alloc) )
|
||||
);
|
||||
|
||||
return (*this).resize(new_n_rows, new_n_cols);
|
||||
if(reuse_mem)
|
||||
{
|
||||
arma_debug_print("Mat::resize(): reusing memory");
|
||||
|
||||
if(new_n_elem > n_elem)
|
||||
{
|
||||
arma_debug_print("Mat::resize(): zeroing memory");
|
||||
|
||||
eT* t_mem = (*this).memptr(); // the (n_elem > 0) check above ensures that (*this).memptr() is a valid pointer
|
||||
|
||||
for(uword ii = n_elem; ii < new_n_elem; ++ii) { t_mem[ii] = eT(0); }
|
||||
}
|
||||
|
||||
access::rw(n_rows) = (vec_state == 2) ? uword(1 ) : uword(new_n_elem);
|
||||
access::rw(n_cols) = (vec_state == 2) ? uword(new_n_elem) : uword(1 );
|
||||
access::rw(n_elem) = new_n_elem;
|
||||
}
|
||||
else
|
||||
{
|
||||
const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem);
|
||||
const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 );
|
||||
|
||||
(*this).resize(new_n_rows, new_n_cols);
|
||||
}
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -7863,12 +7933,12 @@ Mat<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)), "Mat::clamp(): min_val must be less than max_val" );
|
||||
arma_conform_check( ((access::tmp_real(min_val) <= access::tmp_real(max_val)) == false), "Mat::clamp(): min_val must be less than max_val" );
|
||||
}
|
||||
else
|
||||
{
|
||||
arma_conform_check( (access::tmp_real(min_val) > access::tmp_real(max_val)), "Mat::clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( (access::tmp_imag(min_val) > access::tmp_imag(max_val)), "Mat::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), "Mat::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), "Mat::clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
}
|
||||
|
||||
arrayops::clamp(memptr(), n_elem, min_val, max_val);
|
||||
@@ -7908,6 +7978,10 @@ Mat<eT>::fill(const fill::fill_class<fill_type>&)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -10021,6 +10095,119 @@ Mat<eT>::back() const
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<int vec_mode>
|
||||
inline
|
||||
void
|
||||
Mat<eT>::vec_push_back(const eT val, const arma_vec_mode_indicator<vec_mode>&)
|
||||
{
|
||||
arma_debug_sigprint( arma_str::format("n_elem: %u; n_alloc: %u") % n_elem % n_alloc );
|
||||
|
||||
// vec_mode = 1 means col vector layout
|
||||
// vec_mode = 2 means row vector layout
|
||||
|
||||
const uword old_n_elem = n_elem;
|
||||
const uword new_n_elem = old_n_elem + 1;
|
||||
|
||||
if(old_n_elem <= arma_config::mat_prealloc)
|
||||
{
|
||||
if(old_n_elem == 0)
|
||||
{
|
||||
mem_local[0] = val;
|
||||
|
||||
access::rw(mem ) = mem_local;
|
||||
access::rw(n_rows) = 1;
|
||||
access::rw(n_cols) = 1;
|
||||
access::rw(n_elem) = 1;
|
||||
}
|
||||
else
|
||||
if(old_n_elem < arma_config::mat_prealloc)
|
||||
{
|
||||
// condition: (old_n_elem >= 1) && (old_n_elem < arma_config::mat_prealloc)
|
||||
|
||||
mem_local[old_n_elem] = val;
|
||||
|
||||
if(vec_mode == 1) { access::rw(n_rows) = new_n_elem; }
|
||||
if(vec_mode == 2) { access::rw(n_cols) = new_n_elem; }
|
||||
|
||||
access::rw(n_elem) = new_n_elem;
|
||||
}
|
||||
else
|
||||
{
|
||||
// condition: old_n_elem == arma_config::mat_prealloc
|
||||
|
||||
const uword new_n_alloc = (std::max)(uword(64), uword(arma_config::mat_prealloc + arma_config::mat_prealloc/2));
|
||||
|
||||
arma_debug_print( arma_str::format("acquiring new memory; new_n_alloc: %u") % new_n_alloc );
|
||||
|
||||
eT* new_mem_ptr = memory::acquire<eT>(new_n_alloc);
|
||||
|
||||
if(new_mem_ptr == nullptr) { return; }
|
||||
|
||||
arma_debug_print("copying memory");
|
||||
|
||||
arrayops::copy(new_mem_ptr, mem_local, arma_config::mat_prealloc);
|
||||
|
||||
new_mem_ptr[old_n_elem] = val;
|
||||
|
||||
access::rw(mem) = new_mem_ptr;
|
||||
|
||||
if(vec_mode == 1) { access::rw(n_rows) = new_n_elem; }
|
||||
if(vec_mode == 2) { access::rw(n_cols) = new_n_elem; }
|
||||
|
||||
access::rw(n_elem) = new_n_elem;
|
||||
access::rw(n_alloc) = new_n_alloc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// condition: old_n_elem > arma_config::mat_prealloc
|
||||
|
||||
if(n_alloc >= new_n_elem)
|
||||
{
|
||||
access::rw(mem[old_n_elem]) = val;
|
||||
|
||||
if(vec_mode == 1) { access::rw(n_rows) = new_n_elem; }
|
||||
if(vec_mode == 2) { access::rw(n_cols) = new_n_elem; }
|
||||
|
||||
access::rw(n_elem) = new_n_elem;
|
||||
}
|
||||
else
|
||||
{
|
||||
// condition: n_alloc < new_n_elem
|
||||
|
||||
const uword new_n_alloc = (std::max)(uword(256), uword(n_alloc + n_alloc/2));
|
||||
|
||||
arma_debug_print( arma_str::format("acquiring new memory; new_n_alloc: %u") % new_n_alloc );
|
||||
|
||||
const eT* old_mem_ptr = mem;
|
||||
eT* new_mem_ptr = memory::acquire<eT>(new_n_alloc);
|
||||
|
||||
if(new_mem_ptr == nullptr) { return; }
|
||||
|
||||
arma_debug_print("copying memory");
|
||||
|
||||
arrayops::copy(new_mem_ptr, old_mem_ptr, n_elem);
|
||||
|
||||
new_mem_ptr[old_n_elem] = val;
|
||||
|
||||
access::rw(mem) = new_mem_ptr;
|
||||
|
||||
if(vec_mode == 1) { access::rw(n_rows) = new_n_elem; }
|
||||
if(vec_mode == 2) { access::rw(n_cols) = new_n_elem; }
|
||||
|
||||
access::rw(n_elem ) = new_n_elem;
|
||||
access::rw(n_alloc) = new_n_alloc;
|
||||
|
||||
arma_debug_print("releasing old memory");
|
||||
|
||||
memory::release(old_mem_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<uword fixed_n_rows, uword fixed_n_cols>
|
||||
arma_inline
|
||||
@@ -10081,6 +10268,10 @@ Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::fixed(const fill::fill_class<fill_ty
|
||||
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>() ); }
|
||||
}
|
||||
|
||||
|
||||
@@ -10515,7 +10706,7 @@ Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::colptr(const uword in_col)
|
||||
{
|
||||
eT* mem_actual = (use_extra) ? mem_local_extra : mem_local;
|
||||
|
||||
return & access::rw(mem_actual[in_col*fixed_n_rows]);
|
||||
return access::rwp( mem_actual + (in_col*fixed_n_rows) );
|
||||
}
|
||||
|
||||
|
||||
@@ -10528,7 +10719,7 @@ Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::colptr(const uword in_col) const
|
||||
{
|
||||
const eT* mem_actual = (use_extra) ? mem_local_extra : mem_local;
|
||||
|
||||
return & mem_actual[in_col*fixed_n_rows];
|
||||
return mem_actual + (in_col*fixed_n_rows);
|
||||
}
|
||||
|
||||
|
||||
@@ -10555,6 +10746,66 @@ Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::memptr() const
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<uword fixed_n_rows, uword fixed_n_cols>
|
||||
arma_inline
|
||||
subview_row<eT>
|
||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::row(const uword row_num)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
arma_conform_check_bounds( row_num >= fixed_n_rows, "Mat::row(): index out of bounds" );
|
||||
|
||||
return subview_row<eT>(*this, row_num);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<uword fixed_n_rows, uword fixed_n_cols>
|
||||
arma_inline
|
||||
const subview_row<eT>
|
||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::row(const uword row_num) const
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
arma_conform_check_bounds( row_num >= fixed_n_rows, "Mat::row(): index out of bounds" );
|
||||
|
||||
return subview_row<eT>(*this, row_num);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<uword fixed_n_rows, uword fixed_n_cols>
|
||||
arma_inline
|
||||
subview_col<eT>
|
||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::col(const uword col_num)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
arma_conform_check_bounds( col_num >= fixed_n_cols, "Mat::col(): index out of bounds" );
|
||||
|
||||
return subview_col<eT>(*this, col_num);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<uword fixed_n_rows, uword fixed_n_cols>
|
||||
arma_inline
|
||||
const subview_col<eT>
|
||||
Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::col(const uword col_num) const
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
arma_conform_check_bounds( col_num >= fixed_n_cols, "Mat::col(): index out of bounds" );
|
||||
|
||||
return subview_col<eT>(*this, col_num);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
template<uword fixed_n_rows, uword fixed_n_cols>
|
||||
arma_inline
|
||||
@@ -10768,8 +11019,8 @@ Mat_aux::set_real(Mat<eT>& out, const Base<eT,T1>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(X.get_ref());
|
||||
const Mat<eT>& A = tmp.M;
|
||||
const plain_unwrap<T1> tmp(X.get_ref());
|
||||
const Mat<eT>& A = tmp.M;
|
||||
|
||||
arma_conform_assert_same_size( out, A, "Mat::set_real()" );
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ struct OpCube : public BaseCube< typename T1::elem_type, OpCube<T1, op_type> >
|
||||
typedef typename T1::elem_type elem_type;
|
||||
typedef typename get_pod_type<elem_type>::result pod_type;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview;
|
||||
|
||||
inline explicit OpCube(const BaseCube<typename T1::elem_type, T1>& in_m);
|
||||
inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m, const elem_type in_aux);
|
||||
inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m, const elem_type in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux_uword_c);
|
||||
|
||||
@@ -50,6 +50,8 @@ struct Op
|
||||
typedef typename T1::elem_type elem_type;
|
||||
typedef typename get_pod_type<elem_type>::result pod_type;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview;
|
||||
|
||||
inline explicit Op(const T1& in_m);
|
||||
inline Op(const T1& in_m, const elem_type in_aux);
|
||||
inline Op(const T1& in_m, const elem_type in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b);
|
||||
|
||||
@@ -1523,7 +1523,7 @@ struct Proxy_xtrans_default< Op<T1, op_htrans> >
|
||||
static constexpr bool is_col = false;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
const unwrap<T1> U;
|
||||
const plain_unwrap<T1> U;
|
||||
const xtrans_mat<elem_type,true> Q;
|
||||
|
||||
inline explicit Proxy_xtrans_default(const Op<T1, op_htrans>& A)
|
||||
@@ -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); }
|
||||
@@ -1564,7 +1564,7 @@ struct Proxy_xtrans_default< Op<T1, op_strans> >
|
||||
static constexpr bool is_col = false;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
const unwrap<T1> U;
|
||||
const plain_unwrap<T1> U;
|
||||
const xtrans_mat<elem_type,false> Q;
|
||||
|
||||
inline explicit Proxy_xtrans_default(const Op<T1, op_strans>& A)
|
||||
@@ -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); }
|
||||
@@ -2419,8 +2419,8 @@ struct Proxy_vectorise_col_mat< Op<T1, op_vectorise_col> >
|
||||
static constexpr bool is_col = true;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
const unwrap<T1> U;
|
||||
const Mat<elem_type> Q;
|
||||
const plain_unwrap<T1> U;
|
||||
const Mat<elem_type> Q;
|
||||
|
||||
inline explicit Proxy_vectorise_col_mat(const Op<T1, op_vectorise_col>& A)
|
||||
: U(A.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); }
|
||||
|
||||
@@ -33,6 +33,8 @@ class Row : public Mat<eT>
|
||||
static constexpr bool is_row = true;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = false;
|
||||
|
||||
inline Row();
|
||||
inline Row(const Row<eT>& X);
|
||||
|
||||
@@ -67,9 +69,6 @@ class Row : public Mat<eT>
|
||||
inline Row(Row&& m);
|
||||
inline Row& operator=(Row&& m);
|
||||
|
||||
// inline Row(Mat<eT>&& m);
|
||||
// inline Row& operator=(Mat<eT>&& m);
|
||||
|
||||
inline Row& operator=(const eT val);
|
||||
inline Row& operator=(const Row& X);
|
||||
|
||||
@@ -153,6 +152,7 @@ class Row : public Mat<eT>
|
||||
arma_warn_unused arma_inline eT& at(const uword in_row, const uword in_col);
|
||||
arma_warn_unused arma_inline const eT& at(const uword in_row, const uword in_col) const;
|
||||
|
||||
inline void push_back(const eT val);
|
||||
|
||||
inline constexpr bool is_vec() const { return true; }
|
||||
inline constexpr bool is_rowvec() const { return true; }
|
||||
@@ -213,6 +213,8 @@ class Row<eT>::fixed : public Row<eT>
|
||||
static constexpr bool is_row = true;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = false;
|
||||
|
||||
static const uword n_rows; // value provided below the class definition
|
||||
static const uword n_cols; // value provided below the class definition
|
||||
static const uword n_elem; // value provided below the class definition
|
||||
@@ -268,6 +270,8 @@ class Row<eT>::fixed : public Row<eT>
|
||||
arma_warn_unused arma_inline eT& operator() (const uword in_row, const uword in_col);
|
||||
arma_warn_unused arma_inline const eT& operator() (const uword in_row, const uword in_col) const;
|
||||
|
||||
inline void push_back(const eT) = delete;
|
||||
|
||||
arma_warn_unused arma_inline eT* memptr();
|
||||
arma_warn_unused arma_inline const eT* memptr() const;
|
||||
|
||||
|
||||
@@ -431,64 +431,6 @@ Row<eT>::operator=(Row<eT>&& X)
|
||||
|
||||
|
||||
|
||||
// template<typename eT>
|
||||
// inline
|
||||
// Row<eT>::Row(Mat<eT>&& X)
|
||||
// : Mat<eT>(arma_vec_indicator(), 2)
|
||||
// {
|
||||
// arma_debug_sigprint(arma_str::format("this: %x; X: %x") % this % &X);
|
||||
//
|
||||
// if(X.n_rows != 1) { const Mat<eT>& XX = X; Mat<eT>::operator=(XX); return; }
|
||||
//
|
||||
// access::rw(Mat<eT>::n_rows) = 1;
|
||||
// access::rw(Mat<eT>::n_cols) = X.n_cols;
|
||||
// access::rw(Mat<eT>::n_elem) = X.n_elem;
|
||||
// access::rw(Mat<eT>::n_alloc) = X.n_alloc;
|
||||
//
|
||||
// if( (X.n_alloc > arma_config::mat_prealloc) || (X.mem_state == 1) || (X.mem_state == 2) )
|
||||
// {
|
||||
// access::rw(Mat<eT>::mem_state) = X.mem_state;
|
||||
// access::rw(Mat<eT>::mem) = X.mem;
|
||||
//
|
||||
// access::rw(X.n_cols) = 0;
|
||||
// access::rw(X.n_elem) = 0;
|
||||
// access::rw(X.n_alloc) = 0;
|
||||
// access::rw(X.mem_state) = 0;
|
||||
// access::rw(X.mem) = nullptr;
|
||||
// }
|
||||
// else // condition: (X.n_alloc <= arma_config::mat_prealloc) || (X.mem_state == 0) || (X.mem_state == 3)
|
||||
// {
|
||||
// (*this).init_cold();
|
||||
//
|
||||
// arrayops::copy( (*this).memptr(), X.mem, X.n_elem );
|
||||
//
|
||||
// if( (X.mem_state == 0) && (X.n_alloc <= arma_config::mat_prealloc) )
|
||||
// {
|
||||
// access::rw(X.n_cols) = 0;
|
||||
// access::rw(X.n_elem) = 0;
|
||||
// access::rw(X.mem) = nullptr;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// template<typename eT>
|
||||
// inline
|
||||
// Row<eT>&
|
||||
// Row<eT>::operator=(Mat<eT>&& X)
|
||||
// {
|
||||
// arma_debug_sigprint(arma_str::format("this: %x; X: %x") % this % &X);
|
||||
//
|
||||
// if(X.n_rows != 1) { const Mat<eT>& XX = X; Mat<eT>::operator=(XX); return *this; }
|
||||
//
|
||||
// (*this).steal_mem(X, true);
|
||||
//
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
Row<eT>&
|
||||
@@ -1208,6 +1150,25 @@ Row<eT>::at(const uword, const uword in_col) const
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
void
|
||||
Row<eT>::push_back(const eT val)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
if(Mat<eT>::mem_state != 0)
|
||||
{
|
||||
arma_conform_check(true, "Row::push_back(): unsupported operation as auxiliary memory is in use");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Mat<eT>::vec_push_back(val, arma_rowvec_indicator());
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
typename Row<eT>::row_iterator
|
||||
@@ -1351,6 +1312,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>() ); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -31,11 +31,14 @@ struct SpGlue : public SpBase< typename T1::elem_type, SpGlue<T1, T2, spglue_typ
|
||||
static constexpr bool is_col = spglue_type::template traits<T1,T2>::is_col;
|
||||
static constexpr bool is_xvec = spglue_type::template traits<T1,T2>::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview || T2::has_subview;
|
||||
|
||||
inline SpGlue(const T1& in_A, const T2& in_B);
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ class SpMat : public SpBase< eT, SpMat<eT> >
|
||||
static constexpr bool is_col = false;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = false;
|
||||
|
||||
const uword n_rows; //!< number of rows (read-only)
|
||||
const uword n_cols; //!< number of columns (read-only)
|
||||
const uword n_elem; //!< number of elements (read-only)
|
||||
@@ -647,7 +649,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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,12 +31,15 @@ struct SpOp : public SpBase< typename T1::elem_type, SpOp<T1, op_type> >
|
||||
static constexpr bool is_col = op_type::template traits<T1>::is_col;
|
||||
static constexpr bool is_xvec = op_type::template traits<T1>::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview;
|
||||
|
||||
inline explicit SpOp(const T1& in_m);
|
||||
inline SpOp(const T1& in_m, const elem_type in_aux);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ class SpSubview : public SpBase< eT, SpSubview<eT> >
|
||||
static constexpr bool is_col = false;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = true;
|
||||
|
||||
const uword aux_row1;
|
||||
const uword aux_col1;
|
||||
const uword n_rows;
|
||||
@@ -321,7 +323,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:
|
||||
@@ -351,6 +354,8 @@ class SpSubview_col : public SpSubview<eT>
|
||||
static constexpr bool is_col = true;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = true;
|
||||
|
||||
inline void operator= (const SpSubview<eT>& x);
|
||||
inline void operator= (const SpSubview_col& x);
|
||||
|
||||
@@ -391,6 +396,8 @@ class SpSubview_row : public SpSubview<eT>
|
||||
static constexpr bool is_col = false;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = true;
|
||||
|
||||
inline void operator= (const SpSubview<eT>& x);
|
||||
inline void operator= (const SpSubview_row& x);
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ class SpSubview_col_list : public SpBase< eT, SpSubview_col_list<eT,T1> >
|
||||
static constexpr bool is_col = false;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = true;
|
||||
|
||||
const SpMat<eT>& m;
|
||||
const quasi_unwrap<T1> U_ci;
|
||||
|
||||
@@ -87,6 +89,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);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ struct SpToDGlue : public Base< typename T1::elem_type, SpToDGlue<T1, T2, glue_t
|
||||
static constexpr bool is_col = glue_type::template traits<T1,T2>::is_col;
|
||||
static constexpr bool is_xvec = glue_type::template traits<T1,T2>::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview || T2::has_subview;
|
||||
|
||||
inline explicit SpToDGlue(const T1& in_A, const T2& in_B);
|
||||
inline ~SpToDGlue();
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ struct SpToDOp : public Base< typename T1::elem_type, SpToDOp<T1, op_type> >
|
||||
static constexpr bool is_col = op_type::template traits<T1>::is_col;
|
||||
static constexpr bool is_xvec = op_type::template traits<T1>::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview;
|
||||
|
||||
inline explicit SpToDOp(const T1& in_m);
|
||||
inline SpToDOp(const T1& in_m, const elem_type in_aux);
|
||||
inline SpToDOp(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b);
|
||||
|
||||
@@ -286,8 +286,9 @@ template<typename T1> struct ProxyCube;
|
||||
|
||||
template<typename T1> struct diagmat_proxy;
|
||||
|
||||
template<typename T1> struct unwrap;
|
||||
template<typename T1> struct plain_unwrap;
|
||||
template<typename T1> struct quasi_unwrap;
|
||||
|
||||
template<typename T1> struct unwrap_cube;
|
||||
template<typename T1> struct unwrap_spmat;
|
||||
|
||||
@@ -365,6 +366,12 @@ struct arma_zeros_indicator : public arma_initmode_indicator<true > {};
|
||||
struct arma_nozeros_indicator : public arma_initmode_indicator<false> {};
|
||||
|
||||
|
||||
template<int vec_mode> struct arma_vec_mode_indicator {};
|
||||
|
||||
struct arma_colvec_indicator : public arma_vec_mode_indicator<1> {};
|
||||
struct arma_rowvec_indicator : public arma_vec_mode_indicator<2> {};
|
||||
|
||||
|
||||
|
||||
//! \addtogroup injector
|
||||
//! @{
|
||||
|
||||
@@ -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
|
||||
@@ -129,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;
|
||||
}
|
||||
|
||||
@@ -226,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
|
||||
{
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
|
||||
#define ARMA_VERSION_MAJOR 15
|
||||
#define ARMA_VERSION_MINOR 2
|
||||
#define ARMA_VERSION_PATCH 0
|
||||
#define ARMA_VERSION_NAME "Medium Roast Deluxe"
|
||||
#define ARMA_VERSION_MINOR 4
|
||||
#define ARMA_VERSION_PATCH 2
|
||||
#define ARMA_VERSION_NAME "Medium Roast Agave"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2932,8 +2932,8 @@ auxlib::qr_econ(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X)
|
||||
{
|
||||
if(is_Mat<T1>::value)
|
||||
{
|
||||
const unwrap<T1> tmp(X.get_ref());
|
||||
const Mat<eT>& M = tmp.M;
|
||||
const plain_unwrap<T1> tmp(X.get_ref());
|
||||
const Mat<eT>& M = tmp.M;
|
||||
|
||||
if(M.n_rows < M.n_cols) { return auxlib::qr(Q, R, X); }
|
||||
}
|
||||
@@ -5160,8 +5160,8 @@ auxlib::solve_rect_fast(Mat<typename T1::elem_type>& out, Mat<typename T1::elem_
|
||||
{
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
const unwrap<T1> U(B_expr.get_ref());
|
||||
const Mat<eT>& B = U.M;
|
||||
const plain_unwrap<T1> U(B_expr.get_ref());
|
||||
const Mat<eT>& B = U.M;
|
||||
|
||||
arma_conform_check( (A.n_rows != B.n_rows), "solve(): number of rows in given matrices must be the same" );
|
||||
|
||||
@@ -5254,8 +5254,8 @@ auxlib::solve_rect_rcond(Mat<typename T1::elem_type>& out, typename T1::pod_type
|
||||
|
||||
out_rcond = T(0);
|
||||
|
||||
const unwrap<T1> U(B_expr.get_ref());
|
||||
const Mat<eT>& B = U.M;
|
||||
const plain_unwrap<T1> U(B_expr.get_ref());
|
||||
const Mat<eT>& B = U.M;
|
||||
|
||||
arma_conform_check( (A.n_rows != B.n_rows), "solve(): number of rows in given matrices must be the same" );
|
||||
|
||||
@@ -5387,8 +5387,8 @@ auxlib::solve_approx_svd(Mat<typename T1::pod_type>& out, Mat<typename T1::pod_t
|
||||
{
|
||||
typedef typename T1::pod_type eT;
|
||||
|
||||
const unwrap<T1> U(B_expr.get_ref());
|
||||
const Mat<eT>& B = U.M;
|
||||
const plain_unwrap<T1> U(B_expr.get_ref());
|
||||
const Mat<eT>& B = U.M;
|
||||
|
||||
arma_conform_check( (A.n_rows != B.n_rows), "solve(): number of rows in given matrices must be the same" );
|
||||
|
||||
@@ -5509,8 +5509,8 @@ auxlib::solve_approx_svd(Mat< std::complex<typename T1::pod_type> >& out, Mat< s
|
||||
typedef typename T1::pod_type T;
|
||||
typedef typename std::complex<T> eT;
|
||||
|
||||
const unwrap<T1> U(B_expr.get_ref());
|
||||
const Mat<eT>& B = U.M;
|
||||
const plain_unwrap<T1> U(B_expr.get_ref());
|
||||
const Mat<eT>& B = U.M;
|
||||
|
||||
arma_conform_check( (A.n_rows != B.n_rows), "solve(): number of rows in given matrices must be the same" );
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -62,11 +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);
|
||||
|
||||
@@ -78,13 +81,13 @@ namespace priv
|
||||
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>() );
|
||||
}
|
||||
|
||||
|
||||
@@ -92,12 +95,54 @@ namespace priv
|
||||
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();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -125,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
|
||||
|
||||
//
|
||||
|
||||
@@ -176,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);
|
||||
|
||||
@@ -35,6 +35,8 @@ class diagview : public Base< eT, diagview<eT> >
|
||||
static constexpr bool is_col = true;
|
||||
static constexpr bool is_xvec = false;
|
||||
|
||||
static constexpr bool has_subview = true;
|
||||
|
||||
const uword row_offset;
|
||||
const uword col_offset;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -373,29 +373,38 @@ 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]; }
|
||||
|
||||
const std::size_t junk = local_distr(local_engine); // ignore first random number
|
||||
arma_ignore(junk);
|
||||
|
||||
for(std::size_t i=0; i < suffix2_length; ++i, ++count) { out[count] = charlist[ local_distr(local_engine) ]; }
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -1856,7 +1865,7 @@ diskio::load_csv_ascii(Mat<eT>& x, std::istream& f, std::string& err_msg, const
|
||||
|
||||
try { x.zeros(f_n_rows, f_n_cols); } catch(...) { err_msg = "not enough memory"; return false; }
|
||||
|
||||
if(strict) { x.fill(Datum<eT>::nan); } // take into account that each row may have a unique number of columns
|
||||
if(strict && is_real<eT>::yes) { x.fill(Datum<eT>::nan); } // take into account that each row may have a unique number of columns
|
||||
|
||||
const bool use_mp = (arma_config::openmp) && (f_n_rows >= 2) && (f_n_cols >= 64);
|
||||
|
||||
|
||||
@@ -265,6 +265,7 @@ eglue_core<eglue_type>::apply(outT& out, const eGlue<T1, T2, eglue_type>& x)
|
||||
|
||||
constexpr bool use_at = (Proxy<T1>::use_at || Proxy<T2>::use_at);
|
||||
constexpr bool use_mp = (Proxy<T1>::use_mp || Proxy<T2>::use_mp) && (arma_config::openmp);
|
||||
constexpr bool use_ht = (Proxy<T1>::use_mp && Proxy<T2>::use_mp);
|
||||
|
||||
// NOTE: we're assuming that the matrix has already been set to the correct size and there is no aliasing;
|
||||
// size setting and alias checking is done by either the Mat constructor or operator=()
|
||||
@@ -276,7 +277,7 @@ eglue_core<eglue_type>::apply(outT& out, const eGlue<T1, T2, eglue_type>& x)
|
||||
{
|
||||
const uword n_elem = x.get_n_elem();
|
||||
|
||||
if(use_mp && mp_gate<eT, (Proxy<T1>::use_mp && Proxy<T2>::use_mp)>::eval(n_elem))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(n_elem))
|
||||
{
|
||||
typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
|
||||
typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
|
||||
@@ -333,7 +334,7 @@ eglue_core<eglue_type>::apply(outT& out, const eGlue<T1, T2, eglue_type>& x)
|
||||
const Proxy<T1>& P1 = x.P1;
|
||||
const Proxy<T2>& P2 = x.P2;
|
||||
|
||||
if(use_mp && mp_gate<eT, (Proxy<T1>::use_mp && Proxy<T2>::use_mp)>::eval(x.get_n_elem()))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(x.get_n_elem()))
|
||||
{
|
||||
if(is_same_type<eglue_type, eglue_plus >::yes) { arma_applier_2_mp(=, +); }
|
||||
else if(is_same_type<eglue_type, eglue_minus>::yes) { arma_applier_2_mp(=, -); }
|
||||
@@ -371,12 +372,13 @@ eglue_core<eglue_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, con
|
||||
|
||||
constexpr bool use_at = (Proxy<T1>::use_at || Proxy<T2>::use_at);
|
||||
constexpr bool use_mp = (Proxy<T1>::use_mp || Proxy<T2>::use_mp) && (arma_config::openmp);
|
||||
constexpr bool use_ht = (Proxy<T1>::use_mp && Proxy<T2>::use_mp);
|
||||
|
||||
if(use_at == false)
|
||||
{
|
||||
const uword n_elem = x.get_n_elem();
|
||||
|
||||
if(use_mp && mp_gate<eT, (Proxy<T1>::use_mp && Proxy<T2>::use_mp)>::eval(n_elem))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(n_elem))
|
||||
{
|
||||
typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
|
||||
typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
|
||||
@@ -430,7 +432,7 @@ eglue_core<eglue_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, con
|
||||
const Proxy<T1>& P1 = x.P1;
|
||||
const Proxy<T2>& P2 = x.P2;
|
||||
|
||||
if(use_mp && mp_gate<eT, (Proxy<T1>::use_mp && Proxy<T2>::use_mp)>::eval(x.get_n_elem()))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(x.get_n_elem()))
|
||||
{
|
||||
if(is_same_type<eglue_type, eglue_plus >::yes) { arma_applier_2_mp(+=, +); }
|
||||
else if(is_same_type<eglue_type, eglue_minus>::yes) { arma_applier_2_mp(+=, -); }
|
||||
@@ -468,12 +470,13 @@ eglue_core<eglue_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, co
|
||||
|
||||
constexpr bool use_at = (Proxy<T1>::use_at || Proxy<T2>::use_at);
|
||||
constexpr bool use_mp = (Proxy<T1>::use_mp || Proxy<T2>::use_mp) && (arma_config::openmp);
|
||||
constexpr bool use_ht = (Proxy<T1>::use_mp && Proxy<T2>::use_mp);
|
||||
|
||||
if(use_at == false)
|
||||
{
|
||||
const uword n_elem = x.get_n_elem();
|
||||
|
||||
if(use_mp && mp_gate<eT, (Proxy<T1>::use_mp && Proxy<T2>::use_mp)>::eval(n_elem))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(n_elem))
|
||||
{
|
||||
typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
|
||||
typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
|
||||
@@ -527,7 +530,7 @@ eglue_core<eglue_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, co
|
||||
const Proxy<T1>& P1 = x.P1;
|
||||
const Proxy<T2>& P2 = x.P2;
|
||||
|
||||
if(use_mp && mp_gate<eT, (Proxy<T1>::use_mp && Proxy<T2>::use_mp)>::eval(x.get_n_elem()))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(x.get_n_elem()))
|
||||
{
|
||||
if(is_same_type<eglue_type, eglue_plus >::yes) { arma_applier_2_mp(-=, +); }
|
||||
else if(is_same_type<eglue_type, eglue_minus>::yes) { arma_applier_2_mp(-=, -); }
|
||||
@@ -565,12 +568,13 @@ eglue_core<eglue_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, co
|
||||
|
||||
constexpr bool use_at = (Proxy<T1>::use_at || Proxy<T2>::use_at);
|
||||
constexpr bool use_mp = (Proxy<T1>::use_mp || Proxy<T2>::use_mp) && (arma_config::openmp);
|
||||
constexpr bool use_ht = (Proxy<T1>::use_mp && Proxy<T2>::use_mp);
|
||||
|
||||
if(use_at == false)
|
||||
{
|
||||
const uword n_elem = x.get_n_elem();
|
||||
|
||||
if(use_mp && mp_gate<eT, (Proxy<T1>::use_mp && Proxy<T2>::use_mp)>::eval(n_elem))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(n_elem))
|
||||
{
|
||||
typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
|
||||
typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
|
||||
@@ -624,7 +628,7 @@ eglue_core<eglue_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, co
|
||||
const Proxy<T1>& P1 = x.P1;
|
||||
const Proxy<T2>& P2 = x.P2;
|
||||
|
||||
if(use_mp && mp_gate<eT, (Proxy<T1>::use_mp && Proxy<T2>::use_mp)>::eval(x.get_n_elem()))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(x.get_n_elem()))
|
||||
{
|
||||
if(is_same_type<eglue_type, eglue_plus >::yes) { arma_applier_2_mp(*=, +); }
|
||||
else if(is_same_type<eglue_type, eglue_minus>::yes) { arma_applier_2_mp(*=, -); }
|
||||
@@ -662,12 +666,13 @@ eglue_core<eglue_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, cons
|
||||
|
||||
constexpr bool use_at = (Proxy<T1>::use_at || Proxy<T2>::use_at);
|
||||
constexpr bool use_mp = (Proxy<T1>::use_mp || Proxy<T2>::use_mp) && (arma_config::openmp);
|
||||
constexpr bool use_ht = (Proxy<T1>::use_mp && Proxy<T2>::use_mp);
|
||||
|
||||
if(use_at == false)
|
||||
{
|
||||
const uword n_elem = x.get_n_elem();
|
||||
|
||||
if(use_mp && mp_gate<eT, (Proxy<T1>::use_mp && Proxy<T2>::use_mp)>::eval(n_elem))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(n_elem))
|
||||
{
|
||||
typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
|
||||
typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
|
||||
@@ -721,7 +726,7 @@ eglue_core<eglue_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, cons
|
||||
const Proxy<T1>& P1 = x.P1;
|
||||
const Proxy<T2>& P2 = x.P2;
|
||||
|
||||
if(use_mp && mp_gate<eT, (Proxy<T1>::use_mp && Proxy<T2>::use_mp)>::eval(x.get_n_elem()))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(x.get_n_elem()))
|
||||
{
|
||||
if(is_same_type<eglue_type, eglue_plus >::yes) { arma_applier_2_mp(/=, +); }
|
||||
else if(is_same_type<eglue_type, eglue_minus>::yes) { arma_applier_2_mp(/=, -); }
|
||||
@@ -757,6 +762,7 @@ eglue_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const eGlueCube
|
||||
|
||||
constexpr bool use_at = (ProxyCube<T1>::use_at || ProxyCube<T2>::use_at);
|
||||
constexpr bool use_mp = (ProxyCube<T1>::use_mp || ProxyCube<T2>::use_mp) && (arma_config::openmp);
|
||||
constexpr bool use_ht = (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp);
|
||||
|
||||
// NOTE: we're assuming that the cube has already been set to the correct size and there is no aliasing;
|
||||
// size setting and alias checking is done by either the Cube constructor or operator=()
|
||||
@@ -768,7 +774,7 @@ eglue_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const eGlueCube
|
||||
{
|
||||
const uword n_elem = out.n_elem;
|
||||
|
||||
if(use_mp && mp_gate<eT, (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp)>::eval(n_elem))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(n_elem))
|
||||
{
|
||||
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
|
||||
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
|
||||
@@ -826,7 +832,7 @@ eglue_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const eGlueCube
|
||||
const ProxyCube<T1>& P1 = x.P1;
|
||||
const ProxyCube<T2>& P2 = x.P2;
|
||||
|
||||
if(use_mp && mp_gate<eT, (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp)>::eval(x.get_n_elem()))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(x.get_n_elem()))
|
||||
{
|
||||
if(is_same_type<eglue_type, eglue_plus >::yes) { arma_applier_3_mp(=, +); }
|
||||
else if(is_same_type<eglue_type, eglue_minus>::yes) { arma_applier_3_mp(=, -); }
|
||||
@@ -865,12 +871,13 @@ eglue_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type>& out, co
|
||||
|
||||
constexpr bool use_at = (ProxyCube<T1>::use_at || ProxyCube<T2>::use_at);
|
||||
constexpr bool use_mp = (ProxyCube<T1>::use_mp || ProxyCube<T2>::use_mp) && (arma_config::openmp);
|
||||
constexpr bool use_ht = (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp);
|
||||
|
||||
if(use_at == false)
|
||||
{
|
||||
const uword n_elem = out.n_elem;
|
||||
|
||||
if(use_mp && mp_gate<eT, (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp)>::eval(n_elem))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(n_elem))
|
||||
{
|
||||
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
|
||||
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
|
||||
@@ -924,7 +931,7 @@ eglue_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type>& out, co
|
||||
const ProxyCube<T1>& P1 = x.P1;
|
||||
const ProxyCube<T2>& P2 = x.P2;
|
||||
|
||||
if(use_mp && mp_gate<eT, (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp)>::eval(x.get_n_elem()))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(x.get_n_elem()))
|
||||
{
|
||||
if(is_same_type<eglue_type, eglue_plus >::yes) { arma_applier_3_mp(+=, +); }
|
||||
else if(is_same_type<eglue_type, eglue_minus>::yes) { arma_applier_3_mp(+=, -); }
|
||||
@@ -963,12 +970,13 @@ eglue_core<eglue_type>::apply_inplace_minus(Cube<typename T1::elem_type>& out, c
|
||||
|
||||
constexpr bool use_at = (ProxyCube<T1>::use_at || ProxyCube<T2>::use_at);
|
||||
constexpr bool use_mp = (ProxyCube<T1>::use_mp || ProxyCube<T2>::use_mp) && (arma_config::openmp);
|
||||
constexpr bool use_ht = (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp);
|
||||
|
||||
if(use_at == false)
|
||||
{
|
||||
const uword n_elem = out.n_elem;
|
||||
|
||||
if(use_mp && mp_gate<eT, (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp)>::eval(n_elem))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(n_elem))
|
||||
{
|
||||
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
|
||||
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
|
||||
@@ -1022,7 +1030,7 @@ eglue_core<eglue_type>::apply_inplace_minus(Cube<typename T1::elem_type>& out, c
|
||||
const ProxyCube<T1>& P1 = x.P1;
|
||||
const ProxyCube<T2>& P2 = x.P2;
|
||||
|
||||
if(use_mp && mp_gate<eT, (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp)>::eval(x.get_n_elem()))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(x.get_n_elem()))
|
||||
{
|
||||
if(is_same_type<eglue_type, eglue_plus >::yes) { arma_applier_3_mp(-=, +); }
|
||||
else if(is_same_type<eglue_type, eglue_minus>::yes) { arma_applier_3_mp(-=, -); }
|
||||
@@ -1061,12 +1069,13 @@ eglue_core<eglue_type>::apply_inplace_schur(Cube<typename T1::elem_type>& out, c
|
||||
|
||||
constexpr bool use_at = (ProxyCube<T1>::use_at || ProxyCube<T2>::use_at);
|
||||
constexpr bool use_mp = (ProxyCube<T1>::use_mp || ProxyCube<T2>::use_mp) && (arma_config::openmp);
|
||||
constexpr bool use_ht = (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp);
|
||||
|
||||
if(use_at == false)
|
||||
{
|
||||
const uword n_elem = out.n_elem;
|
||||
|
||||
if(use_mp && mp_gate<eT, (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp)>::eval(n_elem))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(n_elem))
|
||||
{
|
||||
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
|
||||
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
|
||||
@@ -1120,7 +1129,7 @@ eglue_core<eglue_type>::apply_inplace_schur(Cube<typename T1::elem_type>& out, c
|
||||
const ProxyCube<T1>& P1 = x.P1;
|
||||
const ProxyCube<T2>& P2 = x.P2;
|
||||
|
||||
if(use_mp && mp_gate<eT, (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp)>::eval(x.get_n_elem()))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(x.get_n_elem()))
|
||||
{
|
||||
if(is_same_type<eglue_type, eglue_plus >::yes) { arma_applier_3_mp(*=, +); }
|
||||
else if(is_same_type<eglue_type, eglue_minus>::yes) { arma_applier_3_mp(*=, -); }
|
||||
@@ -1159,12 +1168,13 @@ eglue_core<eglue_type>::apply_inplace_div(Cube<typename T1::elem_type>& out, con
|
||||
|
||||
constexpr bool use_at = (ProxyCube<T1>::use_at || ProxyCube<T2>::use_at);
|
||||
constexpr bool use_mp = (ProxyCube<T1>::use_mp || ProxyCube<T2>::use_mp) && (arma_config::openmp);
|
||||
constexpr bool use_ht = (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp);
|
||||
|
||||
if(use_at == false)
|
||||
{
|
||||
const uword n_elem = out.n_elem;
|
||||
|
||||
if(use_mp && mp_gate<eT, (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp)>::eval(n_elem))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(n_elem))
|
||||
{
|
||||
typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
|
||||
typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
|
||||
@@ -1218,7 +1228,7 @@ eglue_core<eglue_type>::apply_inplace_div(Cube<typename T1::elem_type>& out, con
|
||||
const ProxyCube<T1>& P1 = x.P1;
|
||||
const ProxyCube<T2>& P2 = x.P2;
|
||||
|
||||
if(use_mp && mp_gate<eT, (ProxyCube<T1>::use_mp && ProxyCube<T2>::use_mp)>::eval(x.get_n_elem()))
|
||||
if(use_mp && mp_gate<eT, use_ht>::eval(x.get_n_elem()))
|
||||
{
|
||||
if(is_same_type<eglue_type, eglue_plus >::yes) { arma_applier_3_mp(/=, +); }
|
||||
else if(is_same_type<eglue_type, eglue_minus>::yes) { arma_applier_3_mp(/=, -); }
|
||||
|
||||
@@ -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;
|
||||
|
||||
//
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -281,8 +281,8 @@ as_scalar_diag(const Base<typename T1::elem_type,T1>& X)
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
const unwrap<T1> tmp(X.get_ref());
|
||||
const Mat<eT>& A = tmp.M;
|
||||
const plain_unwrap<T1> tmp(X.get_ref());
|
||||
const Mat<eT>& A = tmp.M;
|
||||
|
||||
arma_conform_check_bounds( (A.n_elem != 1), "as_scalar(): expected 1x1 matrix" );
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -21,6 +21,276 @@
|
||||
|
||||
|
||||
|
||||
template<typename in_eT>
|
||||
struct conv_to_helper_Mat_same_type
|
||||
{
|
||||
template<typename T1>
|
||||
inline
|
||||
static
|
||||
Mat<in_eT>
|
||||
apply(const Base<in_eT, T1>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
return Mat<in_eT>(in.get_ref());
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Mat<in_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
const in_eT* in_memptr = (N > 0) ? &(in[0]) : nullptr;
|
||||
|
||||
return Mat<in_eT>(in_memptr, N, 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename out_eT, typename in_eT>
|
||||
struct conv_to_helper_Mat_diff_type
|
||||
{
|
||||
template<typename T1>
|
||||
inline
|
||||
static
|
||||
Mat<out_eT>
|
||||
apply(const Base<in_eT, T1>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const quasi_unwrap<T1> tmp(in.get_ref());
|
||||
const Mat<in_eT>& X = tmp.M;
|
||||
|
||||
Mat<out_eT> out(X.n_rows, X.n_cols, arma_nozeros_indicator());
|
||||
|
||||
arrayops::convert( out.memptr(), X.memptr(), X.n_elem );
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Mat<out_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
Mat<out_eT> out(N, 1, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0) { arrayops::convert( out.memptr(), &(in[0]), N ); }
|
||||
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename out_eT, typename in_eT, bool condition>
|
||||
struct conv_to_helper_Mat_redirect {};
|
||||
|
||||
template<typename out_eT, typename in_eT>
|
||||
struct conv_to_helper_Mat_redirect<out_eT, in_eT, true > { typedef conv_to_helper_Mat_same_type<in_eT> result; };
|
||||
|
||||
template<typename out_eT, typename in_eT>
|
||||
struct conv_to_helper_Mat_redirect<out_eT, in_eT, false> { typedef conv_to_helper_Mat_diff_type<out_eT, in_eT> result; };
|
||||
|
||||
|
||||
|
||||
template<typename in_eT>
|
||||
struct conv_to_helper_Row_same_type
|
||||
{
|
||||
template<typename T1>
|
||||
inline
|
||||
static
|
||||
Row<in_eT>
|
||||
apply(const Base<in_eT, T1>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<in_eT> X(in.get_ref());
|
||||
|
||||
arma_conform_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object cannot be interpreted as a vector" );
|
||||
|
||||
access::rw(X.n_rows ) = uword(1);
|
||||
access::rw(X.n_cols ) = X.n_elem;
|
||||
access::rw(X.vec_state) = uword(2);
|
||||
|
||||
Row<in_eT> out; out.steal_mem(X);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Row<in_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
const in_eT* in_memptr = (N > 0) ? &(in[0]) : nullptr;
|
||||
|
||||
return Row<in_eT>(in_memptr, N);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename out_eT, typename in_eT>
|
||||
struct conv_to_helper_Row_diff_type
|
||||
{
|
||||
template<typename T1>
|
||||
inline
|
||||
static
|
||||
Row<out_eT>
|
||||
apply(const Base<in_eT, T1>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const quasi_unwrap<T1> tmp(in.get_ref());
|
||||
const Mat<in_eT>& X = tmp.M;
|
||||
|
||||
arma_conform_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object cannot be interpreted as a vector" );
|
||||
|
||||
Row<out_eT> out(X.n_elem, arma_nozeros_indicator());
|
||||
|
||||
arrayops::convert( out.memptr(), X.memptr(), X.n_elem );
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Row<out_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
Row<out_eT> out(N, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0) { arrayops::convert( out.memptr(), &(in[0]), N ); }
|
||||
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename out_eT, typename in_eT, bool condition>
|
||||
struct conv_to_helper_Row_redirect {};
|
||||
|
||||
template<typename out_eT, typename in_eT>
|
||||
struct conv_to_helper_Row_redirect<out_eT, in_eT, true > { typedef conv_to_helper_Row_same_type<in_eT> result; };
|
||||
|
||||
template<typename out_eT, typename in_eT>
|
||||
struct conv_to_helper_Row_redirect<out_eT, in_eT, false> { typedef conv_to_helper_Row_diff_type<out_eT, in_eT> result; };
|
||||
|
||||
|
||||
|
||||
template<typename in_eT>
|
||||
struct conv_to_helper_Col_same_type
|
||||
{
|
||||
template<typename T1>
|
||||
inline
|
||||
static
|
||||
Col<in_eT>
|
||||
apply(const Base<in_eT, T1>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
Mat<in_eT> X(in.get_ref());
|
||||
|
||||
arma_conform_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object cannot be interpreted as a vector" );
|
||||
|
||||
access::rw(X.n_rows ) = X.n_elem;
|
||||
access::rw(X.n_cols ) = uword(1);
|
||||
access::rw(X.vec_state) = uword(1);
|
||||
|
||||
Col<in_eT> out; out.steal_mem(X);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Col<in_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
const in_eT* in_memptr = (N > 0) ? &(in[0]) : nullptr;
|
||||
|
||||
return Col<in_eT>(in_memptr, N);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename out_eT, typename in_eT>
|
||||
struct conv_to_helper_Col_diff_type
|
||||
{
|
||||
template<typename T1>
|
||||
inline
|
||||
static
|
||||
Col<out_eT>
|
||||
apply(const Base<in_eT, T1>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const quasi_unwrap<T1> tmp(in.get_ref());
|
||||
const Mat<in_eT>& X = tmp.M;
|
||||
|
||||
arma_conform_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object cannot be interpreted as a vector" );
|
||||
|
||||
Col<out_eT> out(X.n_elem, arma_nozeros_indicator());
|
||||
|
||||
arrayops::convert( out.memptr(), X.memptr(), X.n_elem );
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Col<out_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
Col<out_eT> out(N, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0) { arrayops::convert( out.memptr(), &(in[0]), N ); }
|
||||
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename out_eT, typename in_eT, bool condition>
|
||||
struct conv_to_helper_Col_redirect {};
|
||||
|
||||
template<typename out_eT, typename in_eT>
|
||||
struct conv_to_helper_Col_redirect<out_eT, in_eT, true > { typedef conv_to_helper_Col_same_type<in_eT> result; };
|
||||
|
||||
template<typename out_eT, typename in_eT>
|
||||
struct conv_to_helper_Col_redirect<out_eT, in_eT, false> { typedef conv_to_helper_Col_diff_type<out_eT, in_eT> result; };
|
||||
|
||||
|
||||
|
||||
//! conversion from Armadillo Base and BaseCube objects to scalars
|
||||
//! NOTE: use as_scalar() instead; this functionality is kept only for compatibility with old user code
|
||||
template<typename out_eT>
|
||||
@@ -195,14 +465,9 @@ conv_to< Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_not_
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
const quasi_unwrap<T1> tmp(in.get_ref());
|
||||
const Mat<in_eT>& X = tmp.M;
|
||||
typedef typename conv_to_helper_Mat_redirect<out_eT, in_eT, is_same_type<out_eT, in_eT>::value>::result helper_type;
|
||||
|
||||
Mat<out_eT> out(X.n_rows, X.n_cols, arma_nozeros_indicator());
|
||||
|
||||
arrayops::convert( out.memptr(), X.memptr(), X.n_elem );
|
||||
|
||||
return out;
|
||||
return helper_type::apply(in.get_ref());
|
||||
}
|
||||
|
||||
|
||||
@@ -297,16 +562,9 @@ conv_to< Mat<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_n
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
typedef typename conv_to_helper_Mat_redirect<out_eT, in_eT, is_same_type<out_eT, in_eT>::value>::result helper_type;
|
||||
|
||||
Mat<out_eT> out(N, 1, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0)
|
||||
{
|
||||
arrayops::convert( out.memptr(), &(in[0]), N );
|
||||
}
|
||||
|
||||
return out;
|
||||
return helper_type::apply(in);
|
||||
}
|
||||
|
||||
|
||||
@@ -366,16 +624,9 @@ conv_to< Row<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_not_
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
const quasi_unwrap<T1> tmp(in.get_ref());
|
||||
const Mat<in_eT>& X = tmp.M;
|
||||
typedef typename conv_to_helper_Row_redirect<out_eT, in_eT, is_same_type<out_eT, in_eT>::value>::result helper_type;
|
||||
|
||||
arma_conform_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object cannot be interpreted as a vector" );
|
||||
|
||||
Row<out_eT> out(X.n_elem, arma_nozeros_indicator());
|
||||
|
||||
arrayops::convert( out.memptr(), X.memptr(), X.n_elem );
|
||||
|
||||
return out;
|
||||
return helper_type::apply(in.get_ref());
|
||||
}
|
||||
|
||||
|
||||
@@ -414,16 +665,9 @@ conv_to< Row<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_n
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
typedef typename conv_to_helper_Row_redirect<out_eT, in_eT, is_same_type<out_eT, in_eT>::value>::result helper_type;
|
||||
|
||||
Row<out_eT> out(N, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0)
|
||||
{
|
||||
arrayops::convert( out.memptr(), &(in[0]), N );
|
||||
}
|
||||
|
||||
return out;
|
||||
return helper_type::apply(in);
|
||||
}
|
||||
|
||||
|
||||
@@ -483,16 +727,9 @@ conv_to< Col<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma_not_
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
const quasi_unwrap<T1> tmp(in.get_ref());
|
||||
const Mat<in_eT>& X = tmp.M;
|
||||
typedef typename conv_to_helper_Col_redirect<out_eT, in_eT, is_same_type<out_eT, in_eT>::value>::result helper_type;
|
||||
|
||||
arma_conform_check( ( (X.is_vec() == false) && (X.is_empty() == false) ), "conv_to(): given object cannot be interpreted as a vector" );
|
||||
|
||||
Col<out_eT> out(X.n_elem, arma_nozeros_indicator());
|
||||
|
||||
arrayops::convert( out.memptr(), X.memptr(), X.n_elem );
|
||||
|
||||
return out;
|
||||
return helper_type::apply(in.get_ref());
|
||||
}
|
||||
|
||||
|
||||
@@ -531,16 +768,9 @@ conv_to< Col<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_n
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
typedef typename conv_to_helper_Col_redirect<out_eT, in_eT, is_same_type<out_eT, in_eT>::value>::result helper_type;
|
||||
|
||||
Col<out_eT> out(N, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0)
|
||||
{
|
||||
arrayops::convert( out.memptr(), &(in[0]), N );
|
||||
}
|
||||
|
||||
return out;
|
||||
return helper_type::apply(in);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ typename
|
||||
enable_if2
|
||||
<
|
||||
is_arma_type<T1>::value,
|
||||
const mtOp<uword, T1, op_find_simple>
|
||||
const mtOp<uword, T1, op_find_default>
|
||||
>::result
|
||||
find(const T1& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
return mtOp<uword, T1, op_find_simple>(X);
|
||||
return mtOp<uword, T1, op_find_default>(X);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ find(const T1& X)
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
inline
|
||||
const mtOp<uword, T1, op_find>
|
||||
const mtOp<uword, T1, op_find_generic>
|
||||
find(const Base<typename T1::elem_type,T1>& X, const uword k, const char* direction = "first")
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
@@ -57,7 +57,7 @@ find(const Base<typename T1::elem_type,T1>& X, const uword k, const char* direct
|
||||
|
||||
const uword type = ( (sig == 'f') || (sig == 'F') ) ? 0 : 1;
|
||||
|
||||
return mtOp<uword, T1, op_find>(X.get_ref(), k, type);
|
||||
return mtOp<uword, T1, op_find_generic>(X.get_ref(), k, type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ inv
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv_gen_full> >::result
|
||||
inv
|
||||
(
|
||||
|
||||
@@ -63,7 +63,7 @@ inv_sympd
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
typename enable_if2< is_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv_spd_full> >::result
|
||||
inv_sympd
|
||||
(
|
||||
|
||||
@@ -78,7 +78,7 @@ pow
|
||||
|
||||
|
||||
template<typename eT, typename T2>
|
||||
[[deprecated]]
|
||||
[[deprecated("refactor your code to use pow() in conjunction with repcube()")]]
|
||||
inline
|
||||
Cube<eT>
|
||||
pow
|
||||
@@ -160,7 +160,7 @@ pow
|
||||
|
||||
|
||||
template<typename T, typename T2>
|
||||
[[deprecated]]
|
||||
[[deprecated("refactor your code to use pow() in conjunction with repcube()")]]
|
||||
inline
|
||||
Cube< std::complex<T> >
|
||||
pow
|
||||
|
||||
@@ -47,7 +47,7 @@ rande(const uword n_rows, const uword n_cols, const distr_param& param = distr_p
|
||||
|
||||
param.get_double_vals(lambda, unused);
|
||||
|
||||
arma_conform_check( (lambda <= double(0)), "rande(): incorrect distribution parameters; lambda must be greater than zero" );
|
||||
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());
|
||||
|
||||
@@ -138,7 +138,7 @@ rande(const distr_param& param = distr_param())
|
||||
|
||||
param.get_double_vals(lambda, unused);
|
||||
|
||||
arma_conform_check( (lambda <= double(0)), "rande(): incorrect distribution parameters; lambda must be greater than zero" );
|
||||
arma_conform_check( ((lambda > double(0)) == false), "rande(): incorrect distribution parameters; lambda must be greater than zero" );
|
||||
|
||||
double out_val = double(0);
|
||||
|
||||
@@ -162,7 +162,7 @@ rande(const distr_param& param = distr_param())
|
||||
|
||||
param.get_double_vals(lambda, unused);
|
||||
|
||||
arma_conform_check( (lambda <= double(0)), "rande(): incorrect distribution parameters; lambda must be greater than zero" );
|
||||
arma_conform_check( ((lambda > double(0)) == false), "rande(): incorrect distribution parameters; lambda must be greater than zero" );
|
||||
|
||||
eT out_val = eT(0);
|
||||
|
||||
@@ -189,7 +189,7 @@ rande(const uword n_rows, const uword n_cols, const uword n_slices, const distr_
|
||||
|
||||
param.get_double_vals(lambda, unused);
|
||||
|
||||
arma_conform_check( (lambda <= double(0)), "rande(): incorrect distribution parameters; lambda must be greater than zero" );
|
||||
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());
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -97,9 +97,9 @@ sylvester
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
const unwrap<T1> tmp_A( in_A.get_ref() );
|
||||
const unwrap<T2> tmp_B( in_B.get_ref() );
|
||||
const unwrap<T3> tmp_C( in_C.get_ref() );
|
||||
const plain_unwrap<T1> tmp_A( in_A.get_ref() );
|
||||
const plain_unwrap<T2> tmp_B( in_B.get_ref() );
|
||||
const plain_unwrap<T3> tmp_C( in_C.get_ref() );
|
||||
|
||||
const Mat<eT>& A = tmp_A.M;
|
||||
const Mat<eT>& B = tmp_B.M;
|
||||
|
||||
@@ -48,7 +48,7 @@ trimatl(const Base<typename T1::elem_type,T1>& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const SpOp<T1, spop_trimat>
|
||||
trimatu(const SpBase<typename T1::elem_type,T1>& X)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ trimatu(const SpBase<typename T1::elem_type,T1>& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const SpOp<T1, spop_trimat>
|
||||
trimatl(const SpBase<typename T1::elem_type,T1>& X)
|
||||
{
|
||||
@@ -78,7 +78,7 @@ trimatl(const SpBase<typename T1::elem_type,T1>& X)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const Op<T1, op_trimatl_ext>
|
||||
trimatl(const Base<typename T1::elem_type,T1>& X, const sword k)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ trimatl(const Base<typename T1::elem_type,T1>& X, const sword k)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const Op<T1, op_trimatu_ext>
|
||||
trimatu(const Base<typename T1::elem_type,T1>& X, const sword k)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ trimatu(const Base<typename T1::elem_type,T1>& X, const sword k)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const SpOp<T1, spop_trimatu_ext>
|
||||
trimatu(const SpBase<typename T1::elem_type,T1>& X, const sword k)
|
||||
{
|
||||
@@ -126,7 +126,7 @@ trimatu(const SpBase<typename T1::elem_type,T1>& X, const sword k)
|
||||
|
||||
template<typename T1>
|
||||
arma_warn_unused
|
||||
arma_inline
|
||||
inline
|
||||
const SpOp<T1, spop_trimatl_ext>
|
||||
trimatl(const SpBase<typename T1::elem_type,T1>& X, const sword k)
|
||||
{
|
||||
|
||||
@@ -103,8 +103,8 @@ glue_atan2::apply_noalias(Mat<typename T1::elem_type>& out, const Proxy<T1>& P1,
|
||||
{
|
||||
if(use_mp)
|
||||
{
|
||||
const unwrap<typename Proxy<T1>::stored_type> U1(P1.Q);
|
||||
const unwrap<typename Proxy<T2>::stored_type> U2(P2.Q);
|
||||
const plain_unwrap<typename Proxy<T1>::stored_type> U1(P1.Q);
|
||||
const plain_unwrap<typename Proxy<T2>::stored_type> U2(P2.Q);
|
||||
|
||||
out = arma::atan2(U1.M, U2.M);
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ glue_cor::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_cor>& X)
|
||||
|
||||
const uword norm_type = X.aux_uword;
|
||||
|
||||
const unwrap<T1> UA(X.A);
|
||||
const unwrap<T2> UB(X.B);
|
||||
const plain_unwrap<T1> UA(X.A);
|
||||
const plain_unwrap<T2> UB(X.B);
|
||||
|
||||
const Mat<eT>& A = UA.M;
|
||||
const Mat<eT>& B = UB.M;
|
||||
|
||||
@@ -32,8 +32,8 @@ glue_cov::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_cov>& X)
|
||||
|
||||
const uword norm_type = X.aux_uword;
|
||||
|
||||
const unwrap<T1> UA(X.A);
|
||||
const unwrap<T2> UB(X.B);
|
||||
const plain_unwrap<T1> UA(X.A);
|
||||
const plain_unwrap<T2> UB(X.B);
|
||||
|
||||
const Mat<eT>& A = UA.M;
|
||||
const Mat<eT>& B = UB.M;
|
||||
|
||||
@@ -75,13 +75,41 @@ glue_max::apply(Mat<eT>& out, const Proxy<T1>& PA, const Proxy<T2>& PB)
|
||||
|
||||
const uword N = PA.get_n_elem();
|
||||
|
||||
for(uword i=0; i<N; ++i)
|
||||
#if defined(ARMA_SIMPLE_LOOPS)
|
||||
{
|
||||
const eT Ai = A[i];
|
||||
const eT Bi = B[i];
|
||||
|
||||
out_mem[i] = comparator(Ai,Bi) ? Ai : Bi;
|
||||
for(uword i=0; i<N; ++i)
|
||||
{
|
||||
const eT Ai = A[i];
|
||||
const eT Bi = B[i];
|
||||
|
||||
out_mem[i] = comparator(Ai,Bi) ? Ai : Bi;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
uword i,j;
|
||||
|
||||
for(i=0, j=1; j < N; i+=2, j+=2)
|
||||
{
|
||||
const eT Ai = A[i];
|
||||
const eT Aj = A[j];
|
||||
|
||||
const eT Bi = B[i];
|
||||
const eT Bj = B[j];
|
||||
|
||||
(*out_mem) = comparator(Ai,Bi) ? Ai : Bi; ++out_mem;
|
||||
(*out_mem) = comparator(Aj,Bj) ? Aj : Bj; ++out_mem;
|
||||
}
|
||||
|
||||
if(i < N)
|
||||
{
|
||||
const eT Ai = A[i];
|
||||
const eT Bi = B[i];
|
||||
|
||||
(*out_mem) = comparator(Ai,Bi) ? Ai : Bi;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -75,13 +75,41 @@ glue_min::apply(Mat<eT>& out, const Proxy<T1>& PA, const Proxy<T2>& PB)
|
||||
|
||||
const uword N = PA.get_n_elem();
|
||||
|
||||
for(uword i=0; i<N; ++i)
|
||||
#if defined(ARMA_SIMPLE_LOOPS)
|
||||
{
|
||||
const eT Ai = A[i];
|
||||
const eT Bi = B[i];
|
||||
|
||||
out_mem[i] = comparator(Ai,Bi) ? Ai : Bi;
|
||||
for(uword i=0; i<N; ++i)
|
||||
{
|
||||
const eT Ai = A[i];
|
||||
const eT Bi = B[i];
|
||||
|
||||
out_mem[i] = comparator(Ai,Bi) ? Ai : Bi;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
uword i,j;
|
||||
|
||||
for(i=0, j=1; j < N; i+=2, j+=2)
|
||||
{
|
||||
const eT Ai = A[i];
|
||||
const eT Aj = A[j];
|
||||
|
||||
const eT Bi = B[i];
|
||||
const eT Bj = B[j];
|
||||
|
||||
(*out_mem) = comparator(Ai,Bi) ? Ai : Bi; ++out_mem;
|
||||
(*out_mem) = comparator(Aj,Bj) ? Aj : Bj; ++out_mem;
|
||||
}
|
||||
|
||||
if(i < N)
|
||||
{
|
||||
const eT Ai = A[i];
|
||||
const eT Bi = B[i];
|
||||
|
||||
(*out_mem) = comparator(Ai,Bi) ? Ai : Bi;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ struct glue_powext
|
||||
|
||||
template<typename eT> inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B);
|
||||
|
||||
// TODO: deprecated; remove in next major version
|
||||
template<typename parent, unsigned int mode, typename T2> inline static Mat<typename parent::elem_type> apply(const subview_each1<parent,mode>& X, const Base<typename parent::elem_type,T2>& Y);
|
||||
|
||||
//
|
||||
@@ -38,6 +39,7 @@ struct glue_powext
|
||||
|
||||
template<typename eT> inline static void apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B);
|
||||
|
||||
// TODO: deprecated; remove in next major version
|
||||
template<typename eT, typename T2> inline static Cube<eT> apply(const subview_cube_each1<eT>& X, const Base<eT,T2>& Y);
|
||||
};
|
||||
|
||||
@@ -50,6 +52,7 @@ struct glue_powext_cx
|
||||
|
||||
template<typename T> inline static void apply(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const Mat<T>& B);
|
||||
|
||||
// TODO: deprecated; remove in next major version
|
||||
template<typename parent, unsigned int mode, typename T2> inline static Mat<typename parent::elem_type> apply(const subview_each1<parent,mode>& X, const Base<typename T2::elem_type,T2>& Y);
|
||||
|
||||
//
|
||||
@@ -58,6 +61,7 @@ struct glue_powext_cx
|
||||
|
||||
template<typename T> inline static void apply(Cube< std::complex<T> >& out, const Cube< std::complex<T> >& A, const Cube<T>& B);
|
||||
|
||||
// TODO: deprecated; remove in next major version
|
||||
template<typename T, typename T2> inline static Cube< std::complex<T> > apply(const subview_cube_each1< std::complex<T> >& X, const Base<T,T2>& Y);
|
||||
};
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ glue_powext::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
|
||||
|
||||
|
||||
|
||||
// TODO: deprecated; remove in next major version
|
||||
template<typename parent, unsigned int mode, typename T2>
|
||||
inline
|
||||
Mat<typename parent::elem_type>
|
||||
@@ -280,6 +281,7 @@ glue_powext::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B)
|
||||
|
||||
|
||||
|
||||
// TODO: deprecated; remove in next major version
|
||||
template<typename eT, typename T2>
|
||||
inline
|
||||
Cube<eT>
|
||||
@@ -426,6 +428,7 @@ glue_powext_cx::apply(Mat< std::complex<T> >& out, const Mat< std::complex<T> >&
|
||||
|
||||
|
||||
|
||||
// TODO: deprecated; remove in next major version
|
||||
template<typename parent, unsigned int mode, typename T2>
|
||||
inline
|
||||
Mat<typename parent::elem_type>
|
||||
@@ -603,6 +606,7 @@ glue_powext_cx::apply(Cube< std::complex<T> >& out, const Cube< std::complex<T>
|
||||
|
||||
|
||||
|
||||
// TODO: deprecated; remove in next major version
|
||||
template<typename T, typename T2>
|
||||
inline
|
||||
Cube< std::complex<T> >
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -109,11 +109,11 @@ glue_times_redirect2_helper<true, check_alias>::apply(Mat<typename T1::elem_type
|
||||
|
||||
if( (is_cx<eT>::no) && (strip_inv<T1>::do_inv_gen) && (is_Mat<T1_stripped>::value) && (is_Mat<T2>::value) )
|
||||
{
|
||||
const unwrap<T1_stripped> UA(A_strip.M);
|
||||
const unwrap<T2 > UB(X.B);
|
||||
const plain_unwrap<T1_stripped> UA(A_strip.M);
|
||||
const plain_unwrap<T2 > UB(X.B);
|
||||
|
||||
const typename unwrap<T1_stripped>::stored_type& A = UA.M;
|
||||
const typename unwrap<T2 >::stored_type& B = UB.M;
|
||||
const typename plain_unwrap<T1_stripped>::stored_type& A = UA.M;
|
||||
const typename plain_unwrap<T2 >::stored_type& B = UB.M;
|
||||
|
||||
const uword N = A.n_rows;
|
||||
|
||||
|
||||
@@ -137,9 +137,9 @@ gmm_diag<eT>::set_params(const Base<eT,T1>& in_means_expr, const Base<eT,T2>& in
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp1(in_means_expr.get_ref());
|
||||
const unwrap<T2> tmp2(in_dcovs_expr.get_ref());
|
||||
const unwrap<T3> tmp3(in_hefts_expr.get_ref());
|
||||
const plain_unwrap<T1> tmp1(in_means_expr.get_ref());
|
||||
const plain_unwrap<T2> tmp2(in_dcovs_expr.get_ref());
|
||||
const plain_unwrap<T3> tmp3(in_hefts_expr.get_ref());
|
||||
|
||||
const Mat<eT>& in_means = tmp1.M;
|
||||
const Mat<eT>& in_dcovs = tmp2.M;
|
||||
@@ -179,7 +179,7 @@ gmm_diag<eT>::set_means(const Base<eT,T1>& in_means_expr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(in_means_expr.get_ref());
|
||||
const plain_unwrap<T1> tmp(in_means_expr.get_ref());
|
||||
|
||||
const Mat<eT>& in_means = tmp.M;
|
||||
|
||||
@@ -199,7 +199,7 @@ gmm_diag<eT>::set_dcovs(const Base<eT,T1>& in_dcovs_expr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(in_dcovs_expr.get_ref());
|
||||
const plain_unwrap<T1> tmp(in_dcovs_expr.get_ref());
|
||||
|
||||
const Mat<eT>& in_dcovs = tmp.M;
|
||||
|
||||
@@ -222,7 +222,7 @@ gmm_diag<eT>::set_hefts(const Base<eT,T1>& in_hefts_expr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(in_hefts_expr.get_ref());
|
||||
const plain_unwrap<T1> tmp(in_hefts_expr.get_ref());
|
||||
|
||||
const Mat<eT>& in_hefts = tmp.M;
|
||||
|
||||
@@ -602,8 +602,8 @@ gmm_diag<eT>::raw_hist(const Base<eT,T1>& expr, const gmm_dist_mode& dist_mode)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(expr.get_ref());
|
||||
const Mat<eT>& X = tmp.M;
|
||||
const plain_unwrap<T1> tmp(expr.get_ref());
|
||||
const Mat<eT>& X = tmp.M;
|
||||
|
||||
arma_conform_check( (X.n_rows != means.n_rows), "gmm_diag::raw_hist(): incompatible dimensions" );
|
||||
|
||||
@@ -626,8 +626,8 @@ gmm_diag<eT>::norm_hist(const Base<eT,T1>& expr, const gmm_dist_mode& dist_mode)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(expr.get_ref());
|
||||
const Mat<eT>& X = tmp.M;
|
||||
const plain_unwrap<T1> tmp(expr.get_ref());
|
||||
const Mat<eT>& X = tmp.M;
|
||||
|
||||
arma_conform_check( (X.n_rows != means.n_rows), "gmm_diag::norm_hist(): incompatible dimensions" );
|
||||
|
||||
@@ -683,12 +683,12 @@ 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;
|
||||
const plain_unwrap<T1> tmp_X(data.get_ref());
|
||||
const Mat<eT>& X = tmp_X.M;
|
||||
|
||||
if(X.is_empty() ) { arma_warn(3, "gmm_diag::learn(): given matrix is empty" ); return false; }
|
||||
if(X.internal_has_nonfinite()) { arma_warn(3, "gmm_diag::learn(): given matrix has non-finite values"); return false; }
|
||||
@@ -815,8 +815,8 @@ gmm_diag<eT>::kmeans_wrapper
|
||||
|
||||
arma_conform_check( (seed_mode_ok == false), "kmeans(): unknown seed_mode" );
|
||||
|
||||
const unwrap<T1> tmp_X(data.get_ref());
|
||||
const Mat<eT>& X = tmp_X.M;
|
||||
const plain_unwrap<T1> tmp_X(data.get_ref());
|
||||
const Mat<eT>& X = tmp_X.M;
|
||||
|
||||
if(X.is_empty() ) { arma_warn(3, "kmeans(): given matrix is empty" ); return false; }
|
||||
if(X.internal_has_nonfinite()) { arma_warn(3, "kmeans(): given matrix has non-finite values"); return false; }
|
||||
|
||||
@@ -137,9 +137,9 @@ gmm_full<eT>::set_params(const Base<eT,T1>& in_means_expr, const BaseCube<eT,T2>
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap <T1> tmp1(in_means_expr.get_ref());
|
||||
const unwrap_cube<T2> tmp2(in_fcovs_expr.get_ref());
|
||||
const unwrap <T3> tmp3(in_hefts_expr.get_ref());
|
||||
const plain_unwrap <T1> tmp1(in_means_expr.get_ref());
|
||||
const unwrap_cube<T2> tmp2(in_fcovs_expr.get_ref());
|
||||
const plain_unwrap <T3> tmp3(in_hefts_expr.get_ref());
|
||||
|
||||
const Mat <eT>& in_means = tmp1.M;
|
||||
const Cube<eT>& in_fcovs = tmp2.M;
|
||||
@@ -183,7 +183,7 @@ gmm_full<eT>::set_means(const Base<eT,T1>& in_means_expr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(in_means_expr.get_ref());
|
||||
const plain_unwrap<T1> tmp(in_means_expr.get_ref());
|
||||
|
||||
const Mat<eT>& in_means = tmp.M;
|
||||
|
||||
@@ -230,7 +230,7 @@ gmm_full<eT>::set_hefts(const Base<eT,T1>& in_hefts_expr)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(in_hefts_expr.get_ref());
|
||||
const plain_unwrap<T1> tmp(in_hefts_expr.get_ref());
|
||||
|
||||
const Mat<eT>& in_hefts = tmp.M;
|
||||
|
||||
@@ -641,8 +641,8 @@ gmm_full<eT>::raw_hist(const Base<eT,T1>& expr, const gmm_dist_mode& dist_mode)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(expr.get_ref());
|
||||
const Mat<eT>& X = tmp.M;
|
||||
const plain_unwrap<T1> tmp(expr.get_ref());
|
||||
const Mat<eT>& X = tmp.M;
|
||||
|
||||
arma_conform_check( (X.n_rows != means.n_rows), "gmm_full::raw_hist(): incompatible dimensions" );
|
||||
|
||||
@@ -665,8 +665,8 @@ gmm_full<eT>::norm_hist(const Base<eT,T1>& expr, const gmm_dist_mode& dist_mode)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const unwrap<T1> tmp(expr.get_ref());
|
||||
const Mat<eT>& X = tmp.M;
|
||||
const plain_unwrap<T1> tmp(expr.get_ref());
|
||||
const Mat<eT>& X = tmp.M;
|
||||
|
||||
arma_conform_check( (X.n_rows != means.n_rows), "gmm_full::norm_hist(): incompatible dimensions" );
|
||||
|
||||
@@ -722,12 +722,12 @@ gmm_full<eT>::learn
|
||||
|| (seed_mode == random_subset)
|
||||
|| (seed_mode == random_spread);
|
||||
|
||||
arma_conform_check( (dist_mode_ok == false), "gmm_full::learn(): dist_mode must be eucl_dist or maha_dist" );
|
||||
arma_conform_check( (seed_mode_ok == false), "gmm_full::learn(): unknown seed_mode" );
|
||||
arma_conform_check( (var_floor < eT(0) ), "gmm_full::learn(): variance floor is negative" );
|
||||
arma_conform_check( (dist_mode_ok == false), "gmm_full::learn(): dist_mode must be eucl_dist or maha_dist" );
|
||||
arma_conform_check( (seed_mode_ok == false), "gmm_full::learn(): unknown seed_mode" );
|
||||
arma_conform_check( ((var_floor >= eT(0)) == false), "gmm_full::learn(): variance floor must be > 0" );
|
||||
|
||||
const unwrap<T1> tmp_X(data.get_ref());
|
||||
const Mat<eT>& X = tmp_X.M;
|
||||
const plain_unwrap<T1> tmp_X(data.get_ref());
|
||||
const Mat<eT>& X = tmp_X.M;
|
||||
|
||||
if(X.is_empty() ) { arma_warn(3, "gmm_full::learn(): given matrix is empty" ); return false; }
|
||||
if(X.internal_has_nonfinite()) { arma_warn(3, "gmm_full::learn(): given matrix has non-finite values"); return false; }
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
|
||||
struct memory
|
||||
{
|
||||
template<typename eT> arma_malloc inline static eT* acquire(const uword n_elem);
|
||||
|
||||
template<typename eT> arma_inline static void release(eT* mem);
|
||||
template<typename eT> arma_inline static eT* acquire(const uword n_elem);
|
||||
template<typename eT> arma_inline static void release( eT* mem );
|
||||
|
||||
template<typename eT> arma_inline static bool is_aligned(const eT* mem);
|
||||
template<typename eT> arma_inline static void mark_as_aligned( eT*& mem);
|
||||
@@ -33,9 +32,10 @@ struct memory
|
||||
|
||||
|
||||
|
||||
// NOTE: arma_inline is used as a partial workaround for bugs in GCC 15:
|
||||
// NOTE: false positive warnings from -Wmismatched-new-delete and -Wmaybe-uninitialized
|
||||
template<typename eT>
|
||||
arma_malloc
|
||||
inline
|
||||
arma_inline
|
||||
eT*
|
||||
memory::acquire(const uword n_elem)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
|
||||
template<typename eT, const bool use_smaller_thresh = false>
|
||||
template<typename eT, const bool use_half_threshold = false>
|
||||
struct mp_gate
|
||||
{
|
||||
arma_inline
|
||||
@@ -32,7 +32,7 @@ struct mp_gate
|
||||
{
|
||||
#if defined(ARMA_USE_OPENMP)
|
||||
{
|
||||
const bool length_ok = (is_cx<eT>::yes || use_smaller_thresh) ? (n_elem >= (arma_config::mp_threshold/uword(2))) : (n_elem >= arma_config::mp_threshold);
|
||||
const bool length_ok = (is_cx<eT>::yes || use_half_threshold) ? (n_elem >= (arma_config::mp_threshold/uword(2))) : (n_elem >= arma_config::mp_threshold);
|
||||
|
||||
return (length_ok) ? (bool(omp_in_parallel()) == false) : false;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ struct mtGlueCube : public BaseCube< out_eT, mtGlueCube<out_eT, T1, T2, glue_typ
|
||||
typedef out_eT elem_type;
|
||||
typedef typename get_pod_type<out_eT>::result pod_type;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview || T2::has_subview;
|
||||
|
||||
arma_inline mtGlueCube(const T1& in_A, const T2& in_B);
|
||||
arma_inline mtGlueCube(const T1& in_A, const T2& in_B, const uword in_aux_uword);
|
||||
arma_inline ~mtGlueCube();
|
||||
|
||||
@@ -31,6 +31,8 @@ struct mtGlue : public Base< out_eT, mtGlue<out_eT, T1, T2, glue_type> >
|
||||
static constexpr bool is_col = glue_type::template traits<T1,T2>::is_col;
|
||||
static constexpr bool is_xvec = glue_type::template traits<T1,T2>::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview || T2::has_subview;
|
||||
|
||||
arma_inline mtGlue(const T1& in_A, const T2& in_B);
|
||||
arma_inline mtGlue(const T1& in_A, const T2& in_B, const uword in_aux_uword);
|
||||
arma_inline ~mtGlue();
|
||||
|
||||
@@ -32,6 +32,8 @@ struct mtOpCube : public BaseCube< out_eT, mtOpCube<out_eT, T1, op_type> >
|
||||
|
||||
typedef typename T1::elem_type in_eT;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview;
|
||||
|
||||
inline explicit mtOpCube(const T1& in_m);
|
||||
inline mtOpCube(const T1& in_m, const in_eT in_aux);
|
||||
inline mtOpCube(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux_uword_c);
|
||||
|
||||
@@ -35,6 +35,8 @@ struct mtOp : public Base< out_eT, mtOp<out_eT, T1, op_type> >
|
||||
static constexpr bool is_col = op_type::template traits<T1>::is_col;
|
||||
static constexpr bool is_xvec = op_type::template traits<T1>::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview;
|
||||
|
||||
inline explicit mtOp(const T1& in_m);
|
||||
inline mtOp(const T1& in_m, const in_eT in_aux);
|
||||
inline mtOp(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b);
|
||||
|
||||
@@ -31,6 +31,8 @@ struct mtSpGlue : public SpBase< out_eT, mtSpGlue<out_eT, T1, T2, spglue_type> >
|
||||
static constexpr bool is_col = spglue_type::template traits<T1,T2>::is_col;
|
||||
static constexpr bool is_xvec = spglue_type::template traits<T1,T2>::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview || T2::has_subview;
|
||||
|
||||
inline mtSpGlue(const T1& in_A, const T2& in_B);
|
||||
inline ~mtSpGlue();
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ struct mtSpOp : public SpBase< out_eT, mtSpOp<out_eT, T1, spop_type> >
|
||||
static constexpr bool is_col = spop_type::template traits<T1>::is_col;
|
||||
static constexpr bool is_xvec = spop_type::template traits<T1>::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview;
|
||||
|
||||
inline explicit mtSpOp(const T1& in_m);
|
||||
inline mtSpOp(const T1& in_m, const in_eT in_aux);
|
||||
inline mtSpOp(const T1& in_m, const uword aux_uword_a, const uword aux_uword_b);
|
||||
|
||||
@@ -94,7 +94,7 @@ arma_inline
|
||||
bool
|
||||
mtSpOp<out_eT, T1, op_type>::is_alias(const SpMat<eT2>& X) const
|
||||
{
|
||||
return (void_ptr(&X) == void_ptr(&m));
|
||||
return m.is_alias(X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,10 +46,15 @@ struct mtSpReduceOp : public SpBase< out_eT, mtSpReduceOp<out_eT, T1, op_type> >
|
||||
static constexpr bool is_col = op_type::template traits<T1>::is_col;
|
||||
static constexpr bool is_xvec = op_type::template traits<T1>::is_xvec;
|
||||
|
||||
static constexpr bool has_subview = T1::has_subview;
|
||||
|
||||
inline explicit mtSpReduceOp(const T1& in_m);
|
||||
inline mtSpReduceOp(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b);
|
||||
inline ~mtSpReduceOp();
|
||||
|
||||
template<typename eT2>
|
||||
arma_inline bool is_alias(const SpMat<eT2>& X) const;
|
||||
|
||||
const T1& m; //!< the operand; must be derived from SpBase
|
||||
uword aux_uword_a; //!< auxiliary data, uword format
|
||||
uword aux_uword_b; //!< auxiliary data, uword format
|
||||
|
||||
@@ -52,4 +52,15 @@ mtSpReduceOp<out_eT, T1, op_type>::~mtSpReduceOp()
|
||||
|
||||
|
||||
|
||||
template<typename out_eT, typename T1, typename op_type>
|
||||
template<typename eT2>
|
||||
arma_inline
|
||||
bool
|
||||
mtSpReduceOp<out_eT, T1, op_type>::is_alias(const SpMat<eT2>& X) const
|
||||
{
|
||||
return m.is_alias(X);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
@@ -77,8 +77,8 @@ SparseGenRealShiftSolve<eT>::SparseGenRealShiftSolve(const SpMat<eT>& mat_obj, c
|
||||
|
||||
if( (x_rcond < std::numeric_limits<eT>::epsilon()) || arma_isnan(x_rcond) )
|
||||
{
|
||||
if(x_rcond == eT(0)) { arma_warn(2, "matrix is singular to working precision"); }
|
||||
else { arma_warn(2, "matrix is singular to working precision (rcond: ", x_rcond, ")"); }
|
||||
if(x_rcond == eT(0)) { arma_warn(2, "matrix is singular to working precision"); }
|
||||
else { arma_warn(2, "matrix is singular to working precision; rcond: ", x_rcond); }
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ op_accu_mat::apply_proxy_at(const Proxy<T1>& P)
|
||||
const uword n_rows = P.get_n_rows();
|
||||
const uword n_cols = P.get_n_cols();
|
||||
|
||||
if(n_rows == 0) { return eT(0); }
|
||||
|
||||
eT val = eT(0);
|
||||
|
||||
if(n_rows != 1)
|
||||
@@ -146,6 +148,8 @@ op_accu_mat::apply_omit_helper(const Proxy<T1>& P, functor is_omitted)
|
||||
const uword n_rows = P.get_n_rows();
|
||||
const uword n_cols = P.get_n_cols();
|
||||
|
||||
if(n_rows == 0) { return eT_zero; }
|
||||
|
||||
for(uword c=0; c < n_cols; ++c)
|
||||
for(uword r=0; r < n_rows; ++r)
|
||||
{
|
||||
@@ -602,7 +606,32 @@ op_accu_mat::apply(const subview<eT>& X)
|
||||
const uword X_n_rows = X.n_rows;
|
||||
const uword X_n_cols = X.n_cols;
|
||||
|
||||
if(X_n_rows == 1) { return op_accu_mat::apply( static_cast< const subview_row<eT>& >(X) ); }
|
||||
if( (X_n_rows == 0) || (X_n_cols == 0) ) { return eT(0); }
|
||||
|
||||
if(X_n_rows == 1)
|
||||
{
|
||||
const uword X_m_n_rows = X.m.n_rows;
|
||||
|
||||
const eT* mem_ptr = X.colptr(0);
|
||||
|
||||
eT val1 = eT(0);
|
||||
eT val2 = eT(0);
|
||||
|
||||
uword j;
|
||||
|
||||
for(j=1; j < X_n_cols; j+=2)
|
||||
{
|
||||
val1 += (*mem_ptr); mem_ptr += X_m_n_rows;
|
||||
val2 += (*mem_ptr); mem_ptr += X_m_n_rows;
|
||||
}
|
||||
|
||||
if((j-1) < X_n_cols)
|
||||
{
|
||||
val1 += (*mem_ptr);
|
||||
}
|
||||
|
||||
return val1 + val2;
|
||||
}
|
||||
|
||||
if(X_n_cols == 1) { return arrayops::accumulate( X.colptr(0), X_n_rows ); }
|
||||
|
||||
@@ -640,7 +669,7 @@ op_accu_mat::apply(const subview_row<eT>& X)
|
||||
const uword X_m_n_rows = X.m.n_rows;
|
||||
const uword X_n_cols = X.n_cols;
|
||||
|
||||
const eT* row_mem = &(X.m.at(X.aux_row1,X.aux_col1));
|
||||
const eT* mem_ptr = X.rowmem;
|
||||
|
||||
eT val1 = eT(0);
|
||||
eT val2 = eT(0);
|
||||
@@ -649,13 +678,13 @@ op_accu_mat::apply(const subview_row<eT>& X)
|
||||
|
||||
for(j=1; j < X_n_cols; j+=2)
|
||||
{
|
||||
val1 += (*row_mem); row_mem += X_m_n_rows;
|
||||
val2 += (*row_mem); row_mem += X_m_n_rows;
|
||||
val1 += (*mem_ptr); mem_ptr += X_m_n_rows;
|
||||
val2 += (*mem_ptr); mem_ptr += X_m_n_rows;
|
||||
}
|
||||
|
||||
if((j-1) < X_n_cols)
|
||||
{
|
||||
val1 += (*row_mem);
|
||||
val1 += (*mem_ptr);
|
||||
}
|
||||
|
||||
return val1 + val2;
|
||||
@@ -727,6 +756,8 @@ op_accu_cube::apply_proxy_at(const ProxyCube<T1>& P)
|
||||
const uword n_cols = P.get_n_cols();
|
||||
const uword n_slices = P.get_n_slices();
|
||||
|
||||
if( (n_rows == 0) || (n_cols == 0) ) { return eT(0); }
|
||||
|
||||
eT val1 = eT(0);
|
||||
eT val2 = eT(0);
|
||||
|
||||
|
||||
@@ -34,11 +34,11 @@ op_clamp::apply(Mat<typename T1::elem_type>& out, const mtOp<typename T1::elem_t
|
||||
const eT min_val = in.aux;
|
||||
const eT max_val = in.aux_out_eT;
|
||||
|
||||
arma_conform_check( (min_val > max_val), "clamp(): min_val must be less than max_val" );
|
||||
arma_conform_check( ((min_val <= max_val) == false), "clamp(): min_val must be less than max_val" );
|
||||
|
||||
if(is_Mat<T1>::value)
|
||||
{
|
||||
const unwrap<T1> U(in.m);
|
||||
const plain_unwrap<T1> U(in.m);
|
||||
|
||||
// detect in-place operation
|
||||
if(&out == &(U.M))
|
||||
@@ -83,7 +83,7 @@ op_clamp::apply(Mat_noalias<typename T1::elem_type>& out, const mtOp<typename T1
|
||||
const eT min_val = in.aux;
|
||||
const eT max_val = in.aux_out_eT;
|
||||
|
||||
arma_conform_check( (min_val > max_val), "clamp(): min_val must be less than max_val" );
|
||||
arma_conform_check( ((min_val <= max_val) == false), "clamp(): min_val must be less than max_val" );
|
||||
|
||||
if((quasi_unwrap<T1>::has_orig_mem) || (is_Mat<typename Proxy<T1>::stored_type>::value) || (arma_config::openmp && Proxy<T1>::use_mp))
|
||||
{
|
||||
@@ -186,7 +186,7 @@ op_clamp::apply(Cube<typename T1::elem_type>& out, const mtOpCube<typename T1::e
|
||||
const eT min_val = in.aux;
|
||||
const eT max_val = in.aux_out_eT;
|
||||
|
||||
arma_conform_check( (min_val > max_val), "clamp(): min_val must be less than max_val" );
|
||||
arma_conform_check( ((min_val <= max_val) == false), "clamp(): min_val must be less than max_val" );
|
||||
|
||||
if(is_Cube<T1>::value)
|
||||
{
|
||||
@@ -310,7 +310,7 @@ op_clamp_cx::apply(Mat<typename T1::elem_type>& out, const mtOp<typename T1::ele
|
||||
|
||||
if(is_Mat<T1>::value)
|
||||
{
|
||||
const unwrap<T1> U(in.m);
|
||||
const plain_unwrap<T1> U(in.m);
|
||||
|
||||
op_clamp_cx::apply_direct(out, U.M, in.aux, in.aux_out_eT);
|
||||
}
|
||||
@@ -350,8 +350,8 @@ op_clamp_cx::apply_direct(Mat<eT>& out, const Mat<eT>& X, const eT min_val, cons
|
||||
const T max_val_real = std::real(max_val);
|
||||
const T max_val_imag = std::imag(max_val);
|
||||
|
||||
arma_conform_check( (min_val_real > max_val_real), "clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( (min_val_imag > max_val_imag), "clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
arma_conform_check( ((min_val_real <= max_val_real) == false), "clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( ((min_val_imag <= max_val_imag) == false), "clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
|
||||
if(&out != &X)
|
||||
{
|
||||
@@ -401,8 +401,8 @@ op_clamp_cx::apply_proxy_noalias(Mat<typename T1::elem_type>& out, const Proxy<T
|
||||
const T max_val_real = std::real(max_val);
|
||||
const T max_val_imag = std::imag(max_val);
|
||||
|
||||
arma_conform_check( (min_val_real > max_val_real), "clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( (min_val_imag > max_val_imag), "clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
arma_conform_check( ((min_val_real <= max_val_real) == false), "clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( ((min_val_imag <= max_val_imag) == false), "clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
|
||||
const uword n_rows = P.get_n_rows();
|
||||
const uword n_cols = P.get_n_cols();
|
||||
@@ -503,8 +503,8 @@ op_clamp_cx::apply_direct(Cube<eT>& out, const Cube<eT>& X, const eT min_val, co
|
||||
const T max_val_real = std::real(max_val);
|
||||
const T max_val_imag = std::imag(max_val);
|
||||
|
||||
arma_conform_check( (min_val_real > max_val_real), "clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( (min_val_imag > max_val_imag), "clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
arma_conform_check( ((min_val_real <= max_val_real) == false), "clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( ((min_val_imag <= max_val_imag) == false), "clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
|
||||
if(&out != &X)
|
||||
{
|
||||
@@ -554,8 +554,8 @@ op_clamp_cx::apply_proxy_noalias(Cube<typename T1::elem_type>& out, const ProxyC
|
||||
const T max_val_real = std::real(max_val);
|
||||
const T max_val_imag = std::imag(max_val);
|
||||
|
||||
arma_conform_check( (min_val_real > max_val_real), "clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( (min_val_imag > max_val_imag), "clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
arma_conform_check( ((min_val_real <= max_val_real) == false), "clamp(): real(min_val) must be less than real(max_val)" );
|
||||
arma_conform_check( ((min_val_imag <= max_val_imag) == false), "clamp(): imag(min_val) must be less than imag(max_val)" );
|
||||
|
||||
const uword n_rows = P.get_n_rows();
|
||||
const uword n_cols = P.get_n_cols();
|
||||
|
||||
@@ -33,8 +33,8 @@ op_cor::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cor>& in)
|
||||
|
||||
const uword norm_type = in.aux_uword_a;
|
||||
|
||||
const unwrap<T1> U(in.m);
|
||||
const Mat<eT>& A = U.M;
|
||||
const plain_unwrap<T1> U(in.m);
|
||||
const Mat<eT>& A = U.M;
|
||||
|
||||
if(A.n_elem == 0)
|
||||
{
|
||||
@@ -87,8 +87,8 @@ op_cor::apply(Mat<typename T1::elem_type>& out, const Op< Op<T1,op_htrans>, op_c
|
||||
}
|
||||
else
|
||||
{
|
||||
const unwrap<T1> U(in.m.m);
|
||||
const Mat<eT>& A = U.M;
|
||||
const plain_unwrap<T1> U(in.m.m);
|
||||
const Mat<eT>& A = U.M;
|
||||
|
||||
if(A.n_elem == 0)
|
||||
{
|
||||
|
||||
@@ -33,8 +33,8 @@ op_cov::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cov>& in)
|
||||
|
||||
const uword norm_type = in.aux_uword_a;
|
||||
|
||||
const unwrap<T1> U(in.m);
|
||||
const Mat<eT>& A = U.M;
|
||||
const plain_unwrap<T1> U(in.m);
|
||||
const Mat<eT>& A = U.M;
|
||||
|
||||
if(A.n_elem == 0)
|
||||
{
|
||||
@@ -76,8 +76,8 @@ op_cov::apply(Mat<typename T1::elem_type>& out, const Op< Op<T1,op_htrans>, op_c
|
||||
}
|
||||
else
|
||||
{
|
||||
const unwrap<T1> U(in.m.m);
|
||||
const Mat<eT>& A = U.M;
|
||||
const plain_unwrap<T1> U(in.m.m);
|
||||
const Mat<eT>& A = U.M;
|
||||
|
||||
if(A.n_elem == 0)
|
||||
{
|
||||
|
||||
@@ -27,12 +27,20 @@ struct op_diagmat
|
||||
template<typename T1>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_diagmat>& X);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_diagmat>& X);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Proxy<T1>& P);
|
||||
|
||||
//
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagmat>& X);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagmat>& X);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply_times(Mat<typename T1::elem_type>& out, const T1& X, const T2& Y, const typename arma_not_cx<typename T1::elem_type>::result* junk = nullptr);
|
||||
|
||||
@@ -48,6 +56,9 @@ struct op_diagmat2
|
||||
template<typename T1>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_diagmat2>& X);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_diagmat2>& X);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Proxy<T1>& P, const uword row_offset, const uword col_offset);
|
||||
};
|
||||
|
||||
@@ -34,8 +34,8 @@ op_diagmat::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagmat>& X)
|
||||
{
|
||||
// allow detection of in-place operation
|
||||
|
||||
const unwrap<T1> U(X.m);
|
||||
const Mat<eT>& A = U.M;
|
||||
const plain_unwrap<T1> U(X.m);
|
||||
const Mat<eT>& A = U.M;
|
||||
|
||||
if(&out != &A) // no aliasing
|
||||
{
|
||||
@@ -104,6 +104,20 @@ op_diagmat::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagmat>& X)
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
op_diagmat::apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1, op_diagmat>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const Proxy<T1> P(X.m);
|
||||
|
||||
op_diagmat::apply(out, P);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
@@ -160,6 +174,31 @@ op_diagmat::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_ti
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
if(X.m.is_alias(out))
|
||||
{
|
||||
Mat<eT> tmp;
|
||||
|
||||
op_diagmat::apply_times(tmp, X.m.A, X.m.B);
|
||||
|
||||
out.steal_mem(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
op_diagmat::apply_times(out, X.m.A, X.m.B);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
op_diagmat::apply(Mat_noalias<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagmat>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
op_diagmat::apply_times(out, X.m.A, X.m.B);
|
||||
}
|
||||
|
||||
@@ -168,7 +207,7 @@ op_diagmat::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_ti
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, const T2& Y, const typename arma_not_cx<typename T1::elem_type>::result* junk)
|
||||
op_diagmat::apply_times(Mat<typename T1::elem_type>& out, const T1& X, const T2& Y, const typename arma_not_cx<typename T1::elem_type>::result* junk)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
@@ -204,9 +243,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
const eT* C_mem = C.memptr();
|
||||
const uword N = C.n_elem;
|
||||
|
||||
actual_out.zeros(N,N);
|
||||
out.zeros(N,N);
|
||||
|
||||
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -222,9 +261,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
const eT* C_mem = C.memptr();
|
||||
const uword N = C.n_elem;
|
||||
|
||||
actual_out.zeros(N,N);
|
||||
out.zeros(N,N);
|
||||
|
||||
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -240,9 +279,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
const eT* C_mem = C.memptr();
|
||||
const uword N = C.n_elem;
|
||||
|
||||
actual_out.zeros(N,N);
|
||||
out.zeros(N,N);
|
||||
|
||||
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -258,20 +297,15 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
const eT* C_mem = C.memptr();
|
||||
const uword N = C.n_elem;
|
||||
|
||||
actual_out.zeros(N,N);
|
||||
out.zeros(N,N);
|
||||
|
||||
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if we got to this point, the multiplication results in a matrix
|
||||
|
||||
const bool is_alias = (UA.is_alias(actual_out) || UB.is_alias(actual_out));
|
||||
|
||||
Mat<eT> tmp;
|
||||
Mat<eT>& out = (is_alias) ? tmp : actual_out;
|
||||
|
||||
if( (partial_unwrap<T1>::do_trans == false) && (partial_unwrap<T2>::do_trans == false) )
|
||||
{
|
||||
@@ -384,8 +418,6 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
out.at(k,k) = (use_alpha) ? eT(alpha * acc) : eT(acc);
|
||||
}
|
||||
}
|
||||
|
||||
if(is_alias) { actual_out.steal_mem(tmp); }
|
||||
}
|
||||
|
||||
|
||||
@@ -393,7 +425,7 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, const T2& Y, const typename arma_cx_only<typename T1::elem_type>::result* junk)
|
||||
op_diagmat::apply_times(Mat<typename T1::elem_type>& out, const T1& X, const T2& Y, const typename arma_cx_only<typename T1::elem_type>::result* junk)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
@@ -430,9 +462,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
const eT* C_mem = C.memptr();
|
||||
const uword N = C.n_elem;
|
||||
|
||||
actual_out.zeros(N,N);
|
||||
out.zeros(N,N);
|
||||
|
||||
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -448,9 +480,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
const eT* C_mem = C.memptr();
|
||||
const uword N = C.n_elem;
|
||||
|
||||
actual_out.zeros(N,N);
|
||||
out.zeros(N,N);
|
||||
|
||||
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -466,9 +498,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
const eT* C_mem = C.memptr();
|
||||
const uword N = C.n_elem;
|
||||
|
||||
actual_out.zeros(N,N);
|
||||
out.zeros(N,N);
|
||||
|
||||
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -484,20 +516,15 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
const eT* C_mem = C.memptr();
|
||||
const uword N = C.n_elem;
|
||||
|
||||
actual_out.zeros(N,N);
|
||||
out.zeros(N,N);
|
||||
|
||||
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if we got to this point, the multiplication results in a matrix
|
||||
|
||||
const bool is_alias = (UA.is_alias(actual_out) || UB.is_alias(actual_out));
|
||||
|
||||
Mat<eT> tmp;
|
||||
Mat<eT>& out = (is_alias) ? tmp : actual_out;
|
||||
|
||||
if( (partial_unwrap<T1>::do_trans == false) && (partial_unwrap<T2>::do_trans == false) )
|
||||
{
|
||||
@@ -659,8 +686,6 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
|
||||
out.at(k,k) = (use_alpha) ? eT(alpha * acc) : eT(acc);
|
||||
}
|
||||
}
|
||||
|
||||
if(is_alias) { actual_out.steal_mem(tmp); }
|
||||
}
|
||||
|
||||
|
||||
@@ -701,6 +726,23 @@ op_diagmat2::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagmat2>&
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
op_diagmat2::apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1, op_diagmat2>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword row_offset = X.aux_uword_a;
|
||||
const uword col_offset = X.aux_uword_b;
|
||||
|
||||
const Proxy<T1> P(X.m);
|
||||
|
||||
op_diagmat2::apply(out, P, row_offset, col_offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
|
||||
@@ -27,14 +27,25 @@ struct op_diagvec
|
||||
template<typename T1>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_diagvec>& X);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_diagvec>& X);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply_proxy(Mat<typename T1::elem_type>& out, const Proxy<T1>& P);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X, const typename arma_not_cx<typename T1::elem_type>::result* junk = nullptr);
|
||||
//
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X, const typename arma_cx_only<typename T1::elem_type>::result* junk = nullptr);
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply_glue_times(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X, const typename arma_not_cx<typename T1::elem_type>::result* junk = nullptr);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline static void apply_glue_times(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X, const typename arma_cx_only<typename T1::elem_type>::result* junk = nullptr);
|
||||
};
|
||||
|
||||
|
||||
@@ -45,6 +56,9 @@ struct op_diagvec2
|
||||
template<typename T1>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_diagvec2>& X);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_diagvec2>& X);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply_proxy(Mat<typename T1::elem_type>& out, const Proxy<T1>& P, const uword row_offset, const uword col_offset);
|
||||
};
|
||||
|
||||
@@ -48,6 +48,20 @@ op_diagvec::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagvec>& X)
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
op_diagvec::apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1, op_diagvec>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const Proxy<T1> P(X.m);
|
||||
|
||||
op_diagvec::apply_proxy(out, P);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
@@ -87,31 +101,63 @@ op_diagvec::apply_proxy(Mat<typename T1::elem_type>& out, const Proxy<T1>& P)
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
op_diagvec::apply(Mat<typename T1::elem_type>& actual_out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X, const typename arma_not_cx<typename T1::elem_type>::result* junk)
|
||||
op_diagvec::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
if(X.m.is_alias(out))
|
||||
{
|
||||
Mat<eT> tmp;
|
||||
|
||||
op_diagvec::apply_glue_times(tmp, X.m);
|
||||
|
||||
out.steal_mem(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
op_diagvec::apply_glue_times(out, X.m);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
op_diagvec::apply(Mat_noalias<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
op_diagvec::apply_glue_times(out, X.m);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
op_diagvec::apply_glue_times(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X, const typename arma_not_cx<typename T1::elem_type>::result* junk)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
const partial_unwrap<T1> UA(X.m.A);
|
||||
const partial_unwrap<T2> UB(X.m.B);
|
||||
const partial_unwrap<T1> UA(X.A);
|
||||
const partial_unwrap<T2> UB(X.B);
|
||||
|
||||
const typename partial_unwrap<T1>::stored_type& A = UA.M;
|
||||
const typename partial_unwrap<T2>::stored_type& B = UB.M;
|
||||
|
||||
arma_conform_assert_trans_mul_size< partial_unwrap<T1>::do_trans, partial_unwrap<T2>::do_trans >(A.n_rows, A.n_cols, B.n_rows, B.n_cols, "matrix multiplication");
|
||||
|
||||
if( (A.n_elem == 0) || (B.n_elem == 0) ) { actual_out.reset(); return; }
|
||||
if( (A.n_elem == 0) || (B.n_elem == 0) ) { out.reset(); return; }
|
||||
|
||||
constexpr bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times;
|
||||
const eT alpha = use_alpha ? (UA.get_val() * UB.get_val()) : eT(0);
|
||||
|
||||
const bool is_alias = (UA.is_alias(actual_out) || UB.is_alias(actual_out));
|
||||
|
||||
Mat<eT> tmp;
|
||||
Mat<eT>& out = (is_alias) ? tmp : actual_out;
|
||||
|
||||
const uword A_n_rows = A.n_rows;
|
||||
const uword A_n_cols = A.n_cols;
|
||||
|
||||
@@ -237,8 +283,6 @@ op_diagvec::apply(Mat<typename T1::elem_type>& actual_out, const Op< Glue<T1,T2,
|
||||
out_mem[k] = (use_alpha) ? eT(alpha * acc) : eT(acc);
|
||||
}
|
||||
}
|
||||
|
||||
if(is_alias) { actual_out.steal_mem(tmp); }
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +290,7 @@ op_diagvec::apply(Mat<typename T1::elem_type>& actual_out, const Op< Glue<T1,T2,
|
||||
template<typename T1, typename T2>
|
||||
inline
|
||||
void
|
||||
op_diagvec::apply(Mat<typename T1::elem_type>& actual_out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X, const typename arma_cx_only<typename T1::elem_type>::result* junk)
|
||||
op_diagvec::apply_glue_times(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X, const typename arma_cx_only<typename T1::elem_type>::result* junk)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
@@ -254,24 +298,19 @@ op_diagvec::apply(Mat<typename T1::elem_type>& actual_out, const Op< Glue<T1,T2,
|
||||
typedef typename T1::pod_type T;
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
const partial_unwrap<T1> UA(X.m.A);
|
||||
const partial_unwrap<T2> UB(X.m.B);
|
||||
const partial_unwrap<T1> UA(X.A);
|
||||
const partial_unwrap<T2> UB(X.B);
|
||||
|
||||
const typename partial_unwrap<T1>::stored_type& A = UA.M;
|
||||
const typename partial_unwrap<T2>::stored_type& B = UB.M;
|
||||
|
||||
arma_conform_assert_trans_mul_size< partial_unwrap<T1>::do_trans, partial_unwrap<T2>::do_trans >(A.n_rows, A.n_cols, B.n_rows, B.n_cols, "matrix multiplication");
|
||||
|
||||
if( (A.n_elem == 0) || (B.n_elem == 0) ) { actual_out.reset(); return; }
|
||||
if( (A.n_elem == 0) || (B.n_elem == 0) ) { out.reset(); return; }
|
||||
|
||||
constexpr bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times;
|
||||
const eT alpha = use_alpha ? (UA.get_val() * UB.get_val()) : eT(0);
|
||||
|
||||
const bool is_alias = (UA.is_alias(actual_out) || UB.is_alias(actual_out));
|
||||
|
||||
Mat<eT> tmp;
|
||||
Mat<eT>& out = (is_alias) ? tmp : actual_out;
|
||||
|
||||
const uword A_n_rows = A.n_rows;
|
||||
const uword A_n_cols = A.n_cols;
|
||||
|
||||
@@ -446,8 +485,6 @@ op_diagvec::apply(Mat<typename T1::elem_type>& actual_out, const Op< Glue<T1,T2,
|
||||
out_mem[k] = (use_alpha) ? eT(alpha * acc) : eT(acc);
|
||||
}
|
||||
}
|
||||
|
||||
if(is_alias) { actual_out.steal_mem(tmp); }
|
||||
}
|
||||
|
||||
|
||||
@@ -491,6 +528,26 @@ op_diagvec2::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagvec2>&
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
op_diagvec2::apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1, op_diagvec2>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword a = X.aux_uword_a;
|
||||
const uword b = X.aux_uword_b;
|
||||
|
||||
const uword row_offset = (b > 0) ? a : 0;
|
||||
const uword col_offset = (b == 0) ? a : 0;
|
||||
|
||||
const Proxy<T1> P(X.m);
|
||||
|
||||
op_diagvec2::apply_proxy(out, P, row_offset, col_offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user