Compare commits

...
38 Commits
Author SHA1 Message Date
conrad 07414596d4 version bump 2026-06-18 13:21:37 +10:00
conrad 585b369988 fix layout 2026-06-18 12:56:19 +10:00
conrad a957b25a29 explicitly ignore unused value 2026-06-17 12:18:45 +10:00
conrad 61bb3e0ae8 change fill::pos_inf to shorter fill::inf 2026-06-17 11:36:30 +10:00
conrad d5f00fd4a8 mark as RC1 2026-06-16 14:42:41 +10:00
conrad 4dc011f5d3 keep requested mem_state even if n_elem is zero 2026-06-16 14:12:08 +10:00
conrad 922ccf9154 rearrange 2026-06-16 13:24:10 +10:00
conrad ba33c24e8a simpler conversion of std::vector 2026-06-16 13:19:00 +10:00
conrad fea46c6f84 more robust handling of aux_mem 2026-06-16 13:02:05 +10:00
conrad 033c93196c more robust handling of aux_mem 2026-06-16 12:33:54 +10:00
conrad 453bef9283 update list of changes 2026-06-15 15:37:28 +10:00
conrad 598df0100e minor cleanup 2026-06-15 15:35:38 +10:00
conrad 45347ce825 avoid copying when element types are the same 2026-06-15 15:12:11 +10:00
conrad 3318e018d0 faster initial vector growth 2026-06-15 12:07:45 +10:00
conrad 8d350a1534 remove unused code 2026-06-15 11:52:45 +10:00
conrad 11b885085a update list of changes 2026-06-13 00:56:07 +10:00
conrad 724dc98eb8 speedp for contiguous subcubes 2026-06-13 00:51:39 +10:00
conrad 452a6c1b49 use partially unrolled loops 2026-06-13 00:29:21 +10:00
conrad 5c2892a2b5 add specialised handling of find() within .elem() 2026-06-13 00:26:17 +10:00
conrad 88003f8ab8 obtain memory pointers earlier 2026-06-13 00:20:14 +10:00
conrad 248ce5fe7f use same variable name for definition and implementation 2026-06-13 00:14:14 +10:00
conrad e493eb3b34 simplify bounds checks 2026-06-13 00:11:16 +10:00
conrad 03411c40a6 add stored_type typedef to quasi_unwrap<> 2026-06-13 00:06:27 +10:00
conrad 3c6c443be6 more precise alias check 2026-06-12 23:54:07 +10:00
conrad a638683e6f remove unnecessary alignment attribute 2026-06-12 22:02:22 +10:00
conrad e299f5e189 simplify by reusing extract_noalias() 2026-06-12 21:59:36 +10:00
conrad 053de98101 rename unwrap objects 2026-06-12 21:56:57 +10:00
conrad 6b1ce2116b remove rarely used specialisations 2026-06-12 21:48:17 +10:00
conrad b7afc7e5fb add has_subview trait 2026-06-12 20:25:01 +10:00
conrad 1e61d46e5b rename op_find to op_find_generic; rename op_find_simple to op_find_default 2026-06-12 20:13:50 +10:00
conrad 139d9f4d62 user better name and constexpr variable to indicate half threshold 2026-06-12 20:09:12 +10:00
conrad f123904e82 add docs for .push_back() 2026-06-12 20:04:24 +10:00
conrad 6e224f38bd add .push_back() 2026-06-12 20:02:11 +10:00
conrad c088151876 remove unnecessary forced inlines 2026-06-12 19:52:15 +10:00
conrad a839bc49d3 expand deprecation notices 2026-06-12 19:45:34 +10:00
conrad c13b71fc69 rename unwrap<> to plain_unwrap<> for consistency with bandicoot 2026-06-12 19:08:54 +10:00
conrad 69fc9f29a0 mark as experimental 2026-06-12 16:17:33 +10:00
conrad 730594f6da mark as experimental 2026-06-12 16:17:20 +10:00
97 changed files with 1899 additions and 1199 deletions
+67 -7
View File
@@ -159,7 +159,7 @@ hr.greyline
<a class="noprint" style="display:scroll; position:fixed; bottom:5px; right:5px;" href="#top"><font size=-1>[top]</font></a>
<a name="top"></a>
<big><b>API Documentation for Armadillo 15.2</b></big>
<big><b>API Documentation for Armadillo 15.4</b></big>
<br>
<br>
<br>
@@ -271,6 +271,7 @@ Conrad Sanderson and Ryan Curtin.
<table>
<tbody>
<tr><td><a href="#attributes">attributes</a></td><td>&nbsp;</td><td>.n_rows, .n_cols, .n_elem, .n_slices, ...</td></tr>
<tr><td><small><small>&nbsp;</small></small></td><td><small><small>&nbsp;</small></small></td><td><small><small>&nbsp;</small></small></td></tr>
<tr><td><a href="#element_access">element&nbsp;access</a></td><td>&nbsp;</td><td>element/object access via (), [] and .at()</td></tr>
<tr><td><a href="#element_initialisation">element&nbsp;initialisation</a></td><td>&nbsp;</td><td>set elements via initialiser lists</td></tr>
<tr><td><small><small>&nbsp;</small></small></td><td><small><small>&nbsp;</small></small></td><td><small><small>&nbsp;</small></small></td></tr>
@@ -281,6 +282,7 @@ Conrad Sanderson and Ryan Curtin.
<tr><td><small><small>&nbsp;</small></small></td><td><small><small>&nbsp;</small></small></td><td><small><small>&nbsp;</small></small></td></tr>
<tr><td><a href="#fill">.fill</a></td><td>&nbsp;</td><td>set all elements to specified value</td></tr>
<tr><td><a href="#imbue">.imbue</a></td><td>&nbsp;</td><td>imbue (fill) with values provided by functor or lambda function</td></tr>
<tr><td><a href="#push_back">.push_back</a></td><td>&nbsp;</td><td>append elements to vectors</td></tr>
<tr><td><small><small>&nbsp;</small></small></td><td><small><small>&nbsp;</small></small></td><td><small><small>&nbsp;</small></small></td></tr>
<tr><td><a href="#clean">.clean</a></td><td>&nbsp;</td><td>replace elements below a threshold with zeros</td></tr>
<tr><td><a href="#replace_member">.replace</a></td><td>&nbsp;</td><td>replace specific elements with a new value</td></tr>
@@ -793,9 +795,9 @@ which is one of:
<tr><td><code>fill::none</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>do not initialise the elements &nbsp; (matrix may have garbage values)</td></tr>
<tr><td><code>fill::zeros</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to 0 &nbsp; (default operation)</td></tr>
<tr><td><code>fill::ones</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to 1</td></tr>
<!-- <tr><td><code>fill::nan</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to NaN</td></tr> -->
<!-- <tr><td><code>fill::pos_inf</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to +infinity</td></tr> -->
<!-- <tr><td><code>fill::neg_inf</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to -infinity</td></tr> -->
<tr><td><code>fill::nan</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to NaN</td></tr>
<tr><td><code>fill::inf</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to +infinity</td></tr>
<tr><td><code>fill::neg_inf</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to -infinity</td></tr>
<tr><td><code>fill::value(scalar)</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to the specified scalar</td></tr>
<tr><td><code>fill::eye</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set elements on the main diagonal to 1 and off-diagonal elements to 0</td></tr>
<tr><td><code>fill::randu</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set elements to random values from a uniform distribution in the [0,1] interval</td></tr>
@@ -1752,9 +1754,9 @@ which is one of:
<tr><td><code>fill::none</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>do not initialise the elements &nbsp; (cube may have garbage values)</td></tr>
<tr><td><code>fill::zeros</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to 0 &nbsp; (default operation)</td></tr>
<tr><td><code>fill::ones</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to 1</td></tr>
<!-- <tr><td><code>fill::nan</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to NaN</td></tr> -->
<!-- <tr><td><code>fill::pos_inf</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to +infinity</td></tr> -->
<!-- <tr><td><code>fill::neg_inf</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to -infinity</td></tr> -->
<tr><td><code>fill::nan</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to NaN</td></tr>
<tr><td><code>fill::inf</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to +infinity</td></tr>
<tr><td><code>fill::neg_inf</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to -infinity</td></tr>
<tr><td><code>fill::value(scalar)</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to the specified scalar</td></tr>
<tr><td><code>fill::randu</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set elements to random values from a uniform distribution in the [0,1] interval</td></tr>
<tr><td><code>fill::randn</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set elements to random values from a normal/Gaussian distribution with mean&thinsp;=&thinsp;0 and variance&thinsp;=&thinsp;1</td></tr>
@@ -2716,6 +2718,7 @@ double y = v(0);
<ul>
<li><a href="#in_range">.in_range()</a></li>
<li><a href="#element_initialisation">element initialisation</a></li>
<li><a href="#push_back">.push_back()</a></li>
<li><a href="#ind2sub">ind2sub()</a></li>
<li><a href="#sub2ind">sub2ind()</a></li>
<li><a href="#index_min_and_index_max_member">.index_min()&nbsp;/&nbsp;.index_max()</a></li>
@@ -2755,6 +2758,7 @@ mat A = { {1, 3, 5},
See also:
<ul>
<li><a href="#element_access">element access</a></li>
<li><a href="#push_back">.push_back()</a></li>
<li><a href="#reshape_member">.reshape()</a></li>
<li><a href="#print">.print()</a></li>
<li><a href="#save_load_mat">saving &amp; loading matrices</a></li>
@@ -3168,6 +3172,7 @@ mat C(5, 6, fill::value(123.0));
See also:
<ul>
<li><a href="#imbue">.imbue()</a></li>
<li><a href="#push_back">.push_back()</a></li>
<li><a href="#zeros_member">.zeros()</a></li>
<li><a href="#ones_member">.ones()</a></li>
<li><a href="#eye_member">.eye()</a></li>
@@ -3222,6 +3227,7 @@ A.imbue( [&amp;]() { return distr(engine); } );
See also:
<ul>
<li><a href="#fill">.fill()</a></li>
<li><a href="#push_back">.push_back()</a></li>
<li><a href="#transform">.transform()</a></li>
<li><a href="#element_access">element access</a></li>
<li><a href="https://en.wikipedia.org/wiki/Function_object">function object</a> at Wikipedia</li>
@@ -3232,6 +3238,48 @@ See also:
<br>
</ul>
<div class="pagebreak"></div><div class="noprint"><hr class="greyline"><br></div>
<a name="push_back"></a>
<b>.push_back(&nbsp;value&nbsp;)</b>
<ul>
<li>
Member function of <i>Mat</i>, <i>Col</i>, <i>Row</i>
</li>
<br>
<li>
Append the given <i>value</i> to the end of the object,
under the assumption of a column or row vector layout
</li>
<br>
<li>
<b>Caveat:</b> it is faster to directly set the elements via <a href="#element_access">element accessors</a>
or <a href="#element_initialisation">braced initialiser lists</a>
</li>
<br>
<li>
Examples:
<ul>
<pre>
vec v;
v.push_back(1.23);
v.push_back(4.56);
v.push_back(7.89);
</pre>
</ul>
</li>
<br>
<li>See also:
<ul>
<li><a href="#element_access">element accessors</a></li>
<li><a href="#element_initialisation">element initialisation</a></li>
<li><a href="#fill">.fill()</a></li>
<li><a href="#imbue">.imbue()</a></li>
</ul>
</li>
<br>
</ul>
<div class="pagebreak"></div><div class="noprint"><hr class="greyline"><br></div>
<a name="clean"></a>
<b>.clean(&nbsp;</b>threshold<b>&nbsp;)</b>
@@ -5825,6 +5873,7 @@ See also:
<li><a href="#iterators_cube">iterators (cubes)</a></li>
<li><a href="#iterators_spmat">iterators (sparse matrices)</a></li>
<li><a href="#attributes">matrix and vector attributes</a></li>
<li><a href="#push_back">.push_back()</a></li>
<li><a href="#is_empty">.is_empty()</a></li>
<li><a href="#reset">.reset()</a></li>
</ul>
@@ -20720,6 +20769,17 @@ List of additions and changes for each version:
<a name="version_154"></a>
<li>Version 15.4:
<ul>
<li>added <i>fill::nan</i>, <i>fill::inf</i>, <i>fill::neg_inf</i> as optional fill forms for the <a href="#Mat">Mat</a> class</li>
<li>added <a href="#push_back">.push_back()</a> for appending elements to vectors</li>
<li>faster handling of <a href="#find">find()</a> within <a href="#submat">.elem()</a></li>
<li>faster element-wise <a href="#min_and_max">min()</a> and <a href="#min_and_max">max()</a></li>
<li>faster <a href="#conv_to">conv_to</a> when element types of input and output objects are the same</li>
</ul>
</li>
<br>
<a name="version_152"></a>
<li>Version 15.2:
<ul>
+2
View File
@@ -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"
+7 -3
View File
@@ -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;
+19 -58
View File
@@ -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
@@ -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;
};
+2
View File
@@ -82,6 +82,8 @@ class Cube : public BaseCube< eT, Cube<eT> >
public:
static constexpr bool has_subview = false;
inline ~Cube();
inline Cube();
+28 -3
View File
@@ -807,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();
}
}
}
@@ -835,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 );
}
}
+3 -2
View File
@@ -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;
+2
View File
@@ -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();
+2
View File
@@ -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();
+11 -1
View File
@@ -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,6 +930,8 @@ 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;
+189 -28
View File
@@ -1369,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);
}
}
@@ -1392,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 );
}
}
@@ -2591,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);
}
@@ -2606,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);
}
@@ -2621,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);
}
@@ -2636,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);
}
@@ -2651,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);
}
@@ -2719,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);
}
@@ -2734,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);
}
@@ -2749,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);
}
@@ -2764,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);
}
@@ -2779,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);
}
@@ -4980,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;
@@ -5056,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;
@@ -7037,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
@@ -10047,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
@@ -10798,8 +10959,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()" );
+2
View File
@@ -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);
+2
View File
@@ -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);
+4 -4
View File
@@ -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)
@@ -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)
@@ -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)
+7 -3
View File
@@ -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;
+19 -58
View File
@@ -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
+2
View File
@@ -31,6 +31,8 @@ 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();
+2
View File
@@ -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)
+2
View File
@@ -31,6 +31,8 @@ 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);
@@ -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;
@@ -351,6 +353,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 +395,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;
@@ -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();
+2
View File
@@ -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);
+8 -1
View File
@@ -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
//! @{
+3 -3
View File
@@ -22,9 +22,9 @@
#define ARMA_VERSION_MAJOR 15
#define ARMA_VERSION_MINOR 2
#define ARMA_VERSION_PATCH 7
#define ARMA_VERSION_NAME "Medium Roast Deluxe"
#define ARMA_VERSION_MINOR 4
#define ARMA_VERSION_PATCH 0
#define ARMA_VERSION_NAME "Medium Roast Agave"
+10 -10
View File
@@ -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" );
@@ -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;
+3 -2
View File
@@ -399,9 +399,10 @@ diskio::gen_tmp_name(const std::string& x)
for(std::size_t i=0; i < suffix1_length; ++i, ++count) { out[count] = suffix1[i]; }
local_distr(local_engine); // ignore first random number
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)]; }
for(std::size_t i=0; i < suffix2_length; ++i, ++count) { out[count] = charlist[ local_distr(local_engine) ]; }
return out;
}
+30 -20
View File
@@ -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(/=, -); }
+2 -2
View File
@@ -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" );
+282 -52
View File
@@ -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);
}
+4 -4
View File
@@ -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);
}
+1 -1
View File
@@ -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
(
+1 -1
View File
@@ -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
(
+2 -2
View File
@@ -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
+3 -3
View File
@@ -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;
+6 -6
View File
@@ -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)
{
+2 -2
View File
@@ -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);
}
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -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;
+33 -5
View File
@@ -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
{
+33 -5
View File
@@ -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> >
+4 -4
View File
@@ -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;
+14 -14
View File
@@ -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" );
@@ -687,8 +687,8 @@ gmm_diag<eT>::learn
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; }
+11 -11
View File
@@ -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" );
@@ -726,8 +726,8 @@ gmm_full<eT>::learn
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; }
+2 -2
View File
@@ -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();
+2
View File
@@ -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);
+2
View File
@@ -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();
+2
View File
@@ -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);
@@ -46,6 +46,8 @@ 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();
+2 -2
View File
@@ -38,7 +38,7 @@ op_clamp::apply(Mat<typename T1::elem_type>& out, const mtOp<typename T1::elem_t
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))
@@ -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);
}
+4 -4
View File
@@ -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)
{
+4 -4
View File
@@ -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)
{
+2 -2
View File
@@ -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
{
+2 -2
View File
@@ -601,8 +601,8 @@ op_cdot::apply_unwrap(const T1& X, const T2& Y)
typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(X);
const unwrap<T2> tmp2(Y);
const plain_unwrap<T1> tmp1(X);
const plain_unwrap<T2> tmp2(Y);
const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M;
+2 -2
View File
@@ -200,8 +200,8 @@ op_expmat_sym::apply_direct(Mat<typename T1::elem_type>& out, const Base<typenam
typedef typename T1::elem_type eT;
typedef typename T1::pod_type T;
const unwrap<T1> U(expr.get_ref());
const Mat<eT>& X = U.M;
const plain_unwrap<T1> U(expr.get_ref());
const Mat<eT>& X = U.M;
arma_conform_check( (X.is_square() == false), "expmat_sym(): given matrix must be square sized" );
@@ -0,0 +1,81 @@
// SPDX-License-Identifier: Apache-2.0
//
// Copyright 2008-2016 Conrad Sanderson (https://conradsanderson.id.au)
// Copyright 2008-2016 National ICT Australia (NICTA)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------
//! \addtogroup op_find_aux
//! @{
struct op_find_aux
: public traits_op_default
{
template<typename functor, typename T1>
inline static void
apply
(
functor element_processor,
const Base<typename T1::elem_type, T1>& X
);
template<typename functor, typename T1, typename op_type>
inline static void
apply
(
functor element_processor,
const mtOp<uword, T1, op_type>& X,
const typename arma_op_rel_only<op_type>::result* junk1 = nullptr,
const typename arma_not_cx<typename T1::elem_type>::result* junk2 = nullptr
);
template<typename functor, typename T1, typename op_type>
inline static void
apply
(
functor element_processor,
const mtOp<uword, T1, op_type>& X,
const typename arma_op_rel_only<op_type>::result* junk1 = nullptr,
const typename arma_cx_only<typename T1::elem_type>::result* junk2 = nullptr
);
template<typename functor, typename T1, typename T2, typename glue_type>
inline static void
apply
(
functor element_processor,
const mtGlue<uword, T1, T2, glue_type>& X,
const typename arma_glue_rel_only<glue_type>::result* junk1 = nullptr,
const typename arma_not_cx<typename T1::elem_type>::result* junk2 = nullptr,
const typename arma_not_cx<typename T2::elem_type>::result* junk3 = nullptr
);
template<typename functor, typename T1, typename T2, typename glue_type>
inline static void
apply
(
functor element_processor,
const mtGlue<uword, T1, T2, glue_type>& X,
const typename arma_glue_rel_only<glue_type>::result* junk1 = nullptr,
const typename arma_cx_only<typename T1::elem_type>::result* junk2 = nullptr,
const typename arma_cx_only<typename T2::elem_type>::result* junk3 = nullptr
);
};
//! @}
+425
View File
@@ -0,0 +1,425 @@
// SPDX-License-Identifier: Apache-2.0
//
// Copyright 2008-2016 Conrad Sanderson (https://conradsanderson.id.au)
// Copyright 2008-2016 National ICT Australia (NICTA)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------
//! \addtogroup op_find_aux
//! @{
template<typename functor, typename T1>
inline
void
op_find_aux::apply
(
functor element_processor,
const Base<typename T1::elem_type, T1>& X
)
{
arma_debug_sigprint();
typedef typename T1::elem_type eT;
const Proxy<T1> A(X.get_ref());
const uword n_elem = A.get_n_elem();
if(Proxy<T1>::use_at == false)
{
typename Proxy<T1>::ea_type PA = A.get_ea();
for(uword i=0; i<n_elem; ++i)
{
if(PA[i] != eT(0)) { element_processor(i); }
}
}
else
{
const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
uword i = 0;
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
if(A.at(row,col) != eT(0)) { element_processor(i); }
++i;
}
}
}
template<typename functor, typename T1, typename op_type>
inline
void
op_find_aux::apply
(
functor element_processor,
const mtOp<uword, T1, op_type>& X,
const typename arma_op_rel_only<op_type>::result* junk1,
const typename arma_not_cx<typename T1::elem_type>::result* junk2
)
{
arma_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
typedef typename T1::elem_type eT;
const eT val = X.aux;
if((is_same_type<op_type, op_rel_eq>::yes || is_same_type<op_type, op_rel_noteq>::yes) && arma_config::check_conform && arma_isnan(val))
{
arma_warn(1, "find(): NaN is not equal to anything; suggest to use find_nonfinite() instead");
}
const Proxy<T1> A(X.m);
const uword n_elem = A.get_n_elem();
if(Proxy<T1>::use_at == false)
{
typename Proxy<T1>::ea_type PA = A.get_ea();
uword i,j;
for(i=0, j=1; j < n_elem; i+=2, j+=2)
{
const eT tpi = PA[i];
const eT tpj = PA[j];
bool not_zero_i;
bool not_zero_j;
if(is_same_type<op_type, op_rel_lt_pre >::yes) { not_zero_i = (val < tpi); }
else if(is_same_type<op_type, op_rel_lt_post >::yes) { not_zero_i = (tpi < val); }
else if(is_same_type<op_type, op_rel_gt_pre >::yes) { not_zero_i = (val > tpi); }
else if(is_same_type<op_type, op_rel_gt_post >::yes) { not_zero_i = (tpi > val); }
else if(is_same_type<op_type, op_rel_lteq_pre >::yes) { not_zero_i = (val <= tpi); }
else if(is_same_type<op_type, op_rel_lteq_post>::yes) { not_zero_i = (tpi <= val); }
else if(is_same_type<op_type, op_rel_gteq_pre >::yes) { not_zero_i = (val >= tpi); }
else if(is_same_type<op_type, op_rel_gteq_post>::yes) { not_zero_i = (tpi >= val); }
else if(is_same_type<op_type, op_rel_eq >::yes) { not_zero_i = (tpi == val); }
else if(is_same_type<op_type, op_rel_noteq >::yes) { not_zero_i = (tpi != val); }
else { not_zero_i = false; }
if(is_same_type<op_type, op_rel_lt_pre >::yes) { not_zero_j = (val < tpj); }
else if(is_same_type<op_type, op_rel_lt_post >::yes) { not_zero_j = (tpj < val); }
else if(is_same_type<op_type, op_rel_gt_pre >::yes) { not_zero_j = (val > tpj); }
else if(is_same_type<op_type, op_rel_gt_post >::yes) { not_zero_j = (tpj > val); }
else if(is_same_type<op_type, op_rel_lteq_pre >::yes) { not_zero_j = (val <= tpj); }
else if(is_same_type<op_type, op_rel_lteq_post>::yes) { not_zero_j = (tpj <= val); }
else if(is_same_type<op_type, op_rel_gteq_pre >::yes) { not_zero_j = (val >= tpj); }
else if(is_same_type<op_type, op_rel_gteq_post>::yes) { not_zero_j = (tpj >= val); }
else if(is_same_type<op_type, op_rel_eq >::yes) { not_zero_j = (tpj == val); }
else if(is_same_type<op_type, op_rel_noteq >::yes) { not_zero_j = (tpj != val); }
else { not_zero_j = false; }
if(not_zero_i) { element_processor(i); }
if(not_zero_j) { element_processor(j); }
}
if(i < n_elem)
{
bool not_zero;
const eT tmp = PA[i];
if(is_same_type<op_type, op_rel_lt_pre >::yes) { not_zero = (val < tmp); }
else if(is_same_type<op_type, op_rel_lt_post >::yes) { not_zero = (tmp < val); }
else if(is_same_type<op_type, op_rel_gt_pre >::yes) { not_zero = (val > tmp); }
else if(is_same_type<op_type, op_rel_gt_post >::yes) { not_zero = (tmp > val); }
else if(is_same_type<op_type, op_rel_lteq_pre >::yes) { not_zero = (val <= tmp); }
else if(is_same_type<op_type, op_rel_lteq_post>::yes) { not_zero = (tmp <= val); }
else if(is_same_type<op_type, op_rel_gteq_pre >::yes) { not_zero = (val >= tmp); }
else if(is_same_type<op_type, op_rel_gteq_post>::yes) { not_zero = (tmp >= val); }
else if(is_same_type<op_type, op_rel_eq >::yes) { not_zero = (tmp == val); }
else if(is_same_type<op_type, op_rel_noteq >::yes) { not_zero = (tmp != val); }
else { not_zero = false; }
if(not_zero) { element_processor(i); }
}
}
else
{
const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
uword i = 0;
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
const eT tmp = A.at(row,col);
bool not_zero;
if(is_same_type<op_type, op_rel_lt_pre >::yes) { not_zero = (val < tmp); }
else if(is_same_type<op_type, op_rel_lt_post >::yes) { not_zero = (tmp < val); }
else if(is_same_type<op_type, op_rel_gt_pre >::yes) { not_zero = (val > tmp); }
else if(is_same_type<op_type, op_rel_gt_post >::yes) { not_zero = (tmp > val); }
else if(is_same_type<op_type, op_rel_lteq_pre >::yes) { not_zero = (val <= tmp); }
else if(is_same_type<op_type, op_rel_lteq_post>::yes) { not_zero = (tmp <= val); }
else if(is_same_type<op_type, op_rel_gteq_pre >::yes) { not_zero = (val >= tmp); }
else if(is_same_type<op_type, op_rel_gteq_post>::yes) { not_zero = (tmp >= val); }
else if(is_same_type<op_type, op_rel_eq >::yes) { not_zero = (tmp == val); }
else if(is_same_type<op_type, op_rel_noteq >::yes) { not_zero = (tmp != val); }
else { not_zero = false; }
if(not_zero) { element_processor(i); }
++i;
}
}
}
template<typename functor, typename T1, typename op_type>
inline
void
op_find_aux::apply
(
functor element_processor,
const mtOp<uword, T1, op_type>& X,
const typename arma_op_rel_only<op_type>::result* junk1,
const typename arma_cx_only<typename T1::elem_type>::result* junk2
)
{
arma_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type;
const eT val = X.aux;
if((is_same_type<op_type, op_rel_eq>::yes || is_same_type<op_type, op_rel_noteq>::yes) && arma_config::check_conform && arma_isnan(val))
{
arma_warn(1, "find(): NaN is not equal to anything; suggest to use find_nonfinite() instead");
}
const Proxy<T1> A(X.m);
const uword n_elem = A.get_n_elem();
if(Proxy<T1>::use_at == false)
{
ea_type PA = A.get_ea();
for(uword i=0; i<n_elem; ++i)
{
const eT tmp = PA[i];
bool not_zero;
if(is_same_type<op_type, op_rel_eq >::yes) { not_zero = (tmp == val); }
else if(is_same_type<op_type, op_rel_noteq>::yes) { not_zero = (tmp != val); }
else { not_zero = false; }
if(not_zero) { element_processor(i); }
}
}
else
{
const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
uword i = 0;
for(uword col=0; col<n_cols; ++col)
for(uword row=0; row<n_rows; ++row)
{
const eT tmp = A.at(row,col);
bool not_zero;
if(is_same_type<op_type, op_rel_eq >::yes) { not_zero = (tmp == val); }
else if(is_same_type<op_type, op_rel_noteq>::yes) { not_zero = (tmp != val); }
else { not_zero = false; }
if(not_zero) { element_processor(i); }
i++;
}
}
}
template<typename functor, typename T1, typename T2, typename glue_type>
inline
void
op_find_aux::apply
(
functor element_processor,
const mtGlue<uword, T1, T2, glue_type>& X,
const typename arma_glue_rel_only<glue_type>::result* junk1,
const typename arma_not_cx<typename T1::elem_type>::result* junk2,
const typename arma_not_cx<typename T2::elem_type>::result* junk3
)
{
arma_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
arma_ignore(junk3);
typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2;
typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2;
const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B);
arma_conform_assert_same_size(A, B, "relational operator");
const uword n_elem = A.get_n_elem();
if((Proxy<T1>::use_at == false) && (Proxy<T2>::use_at == false))
{
ea_type1 PA = A.get_ea();
ea_type2 PB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
const eT1 tmp1 = PA[i];
const eT2 tmp2 = PB[i];
bool not_zero;
if(is_same_type<glue_type, glue_rel_lt >::yes) { not_zero = (tmp1 < tmp2); }
else if(is_same_type<glue_type, glue_rel_gt >::yes) { not_zero = (tmp1 > tmp2); }
else if(is_same_type<glue_type, glue_rel_lteq >::yes) { not_zero = (tmp1 <= tmp2); }
else if(is_same_type<glue_type, glue_rel_gteq >::yes) { not_zero = (tmp1 >= tmp2); }
else if(is_same_type<glue_type, glue_rel_eq >::yes) { not_zero = (tmp1 == tmp2); }
else if(is_same_type<glue_type, glue_rel_noteq >::yes) { not_zero = (tmp1 != tmp2); }
else if(is_same_type<glue_type, glue_rel_and >::yes) { not_zero = (tmp1 && tmp2); }
else if(is_same_type<glue_type, glue_rel_or >::yes) { not_zero = (tmp1 || tmp2); }
else { not_zero = false; }
if(not_zero) { element_processor(i); }
}
}
else
{
const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
uword i = 0;
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
const eT1 tmp1 = A.at(row,col);
const eT2 tmp2 = B.at(row,col);
bool not_zero;
if(is_same_type<glue_type, glue_rel_lt >::yes) { not_zero = (tmp1 < tmp2); }
else if(is_same_type<glue_type, glue_rel_gt >::yes) { not_zero = (tmp1 > tmp2); }
else if(is_same_type<glue_type, glue_rel_lteq >::yes) { not_zero = (tmp1 <= tmp2); }
else if(is_same_type<glue_type, glue_rel_gteq >::yes) { not_zero = (tmp1 >= tmp2); }
else if(is_same_type<glue_type, glue_rel_eq >::yes) { not_zero = (tmp1 == tmp2); }
else if(is_same_type<glue_type, glue_rel_noteq >::yes) { not_zero = (tmp1 != tmp2); }
else if(is_same_type<glue_type, glue_rel_and >::yes) { not_zero = (tmp1 && tmp2); }
else if(is_same_type<glue_type, glue_rel_or >::yes) { not_zero = (tmp1 || tmp2); }
else { not_zero = false; }
if(not_zero) { element_processor(i); }
i++;
}
}
}
template<typename functor, typename T1, typename T2, typename glue_type>
inline
void
op_find_aux::apply
(
functor element_processor,
const mtGlue<uword, T1, T2, glue_type>& X,
const typename arma_glue_rel_only<glue_type>::result* junk1,
const typename arma_cx_only<typename T1::elem_type>::result* junk2,
const typename arma_cx_only<typename T2::elem_type>::result* junk3
)
{
arma_debug_sigprint();
arma_ignore(junk1);
arma_ignore(junk2);
arma_ignore(junk3);
typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2;
const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B);
arma_conform_assert_same_size(A, B, "relational operator");
const uword n_elem = A.get_n_elem();
if((Proxy<T1>::use_at == false) && (Proxy<T2>::use_at == false))
{
ea_type1 PA = A.get_ea();
ea_type2 PB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
bool not_zero;
if(is_same_type<glue_type, glue_rel_eq >::yes) { not_zero = (PA[i] == PB[i]); }
else if(is_same_type<glue_type, glue_rel_noteq >::yes) { not_zero = (PA[i] != PB[i]); }
else { not_zero = false; }
if(not_zero) { element_processor(i); }
}
}
else
{
const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
uword i = 0;
for(uword col=0; col<n_cols; ++col)
for(uword row=0; row<n_rows; ++row)
{
bool not_zero;
if(is_same_type<glue_type, glue_rel_eq >::yes) { not_zero = (A.at(row,col) == B.at(row,col)); }
else if(is_same_type<glue_type, glue_rel_noteq >::yes) { not_zero = (A.at(row,col) != B.at(row,col)); }
else { not_zero = false; }
if(not_zero) { element_processor(i); }
i++;
}
}
}
//! @}
+4 -4
View File
@@ -22,7 +22,7 @@
struct op_find
struct op_find_generic
: public traits_op_col
{
template<typename T1>
@@ -76,16 +76,16 @@ struct op_find
);
template<typename T1>
inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_find>& X);
inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_find_generic>& X);
};
struct op_find_simple
struct op_find_default
: public traits_op_col
{
template<typename T1>
inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_find_simple>& X);
inline static void apply(Mat<uword>& out, const mtOp<uword, T1, op_find_default>& X);
};
+9 -9
View File
@@ -25,7 +25,7 @@
template<typename T1>
inline
uword
op_find::helper
op_find_generic::helper
(
Mat<uword>& indices,
const Base<typename T1::elem_type, T1>& X
@@ -77,7 +77,7 @@ op_find::helper
template<typename T1, typename op_type>
inline
uword
op_find::helper
op_find_generic::helper
(
Mat<uword>& indices,
const mtOp<uword, T1, op_type>& X,
@@ -209,7 +209,7 @@ op_find::helper
template<typename T1, typename op_type>
inline
uword
op_find::helper
op_find_generic::helper
(
Mat<uword>& indices,
const mtOp<uword, T1, op_type>& X,
@@ -290,7 +290,7 @@ op_find::helper
template<typename T1, typename T2, typename glue_type>
inline
uword
op_find::helper
op_find_generic::helper
(
Mat<uword>& indices,
const mtGlue<uword, T1, T2, glue_type>& X,
@@ -386,7 +386,7 @@ op_find::helper
template<typename T1, typename T2, typename glue_type>
inline
uword
op_find::helper
op_find_generic::helper
(
Mat<uword>& indices,
const mtGlue<uword, T1, T2, glue_type>& X,
@@ -461,7 +461,7 @@ op_find::helper
template<typename T1>
inline
void
op_find::apply(Mat<uword>& out, const mtOp<uword, T1, op_find>& X)
op_find_generic::apply(Mat<uword>& out, const mtOp<uword, T1, op_find_generic>& X)
{
arma_debug_sigprint();
@@ -469,7 +469,7 @@ op_find::apply(Mat<uword>& out, const mtOp<uword, T1, op_find>& X)
const uword type = X.aux_uword_b;
Mat<uword> indices;
const uword n_nz = op_find::helper(indices, X.m);
const uword n_nz = op_find_generic::helper(indices, X.m);
if(n_nz > 0)
{
@@ -497,12 +497,12 @@ op_find::apply(Mat<uword>& out, const mtOp<uword, T1, op_find>& X)
template<typename T1>
inline
void
op_find_simple::apply(Mat<uword>& out, const mtOp<uword, T1, op_find_simple>& X)
op_find_default::apply(Mat<uword>& out, const mtOp<uword, T1, op_find_default>& X)
{
arma_debug_sigprint();
Mat<uword> indices;
const uword n_nz = op_find::helper(indices, X.m);
const uword n_nz = op_find_generic::helper(indices, X.m);
out.steal_mem_col(indices, n_nz);
}
+2 -2
View File
@@ -32,7 +32,7 @@ op_flipud::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_flipud>& in)
if(is_Mat<T1>::value)
{
const unwrap<T1> U(in.m);
const plain_unwrap<T1> U(in.m);
if(&out == &(U.M)) { op_flipud::apply_mat_inplace(out); return; }
@@ -166,7 +166,7 @@ op_fliplr::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_fliplr>& in)
if(is_Mat<T1>::value)
{
const unwrap<T1> U(in.m);
const plain_unwrap<T1> U(in.m);
if(&out == &(U.M)) { op_fliplr::apply_mat_inplace(out); return; }
+1 -1
View File
@@ -309,7 +309,7 @@ op_htrans::apply_direct(Mat<typename T1::elem_type>& out, const T1& X)
// allow detection of in-place transpose
if(is_Mat<T1>::value)
{
const unwrap<T1> U(X);
const plain_unwrap<T1> U(X);
op_htrans::apply_mat(out, U.M);
}
+2 -2
View File
@@ -500,8 +500,8 @@ op_logmat_sympd::apply_direct(Mat<typename T1::elem_type>& out, const Base<typen
typedef typename T1::pod_type T;
typedef typename T1::elem_type eT;
const unwrap<T1> U(expr.get_ref());
const Mat<eT>& X = U.M;
const plain_unwrap<T1> U(expr.get_ref());
const Mat<eT>& X = U.M;
arma_conform_check( (X.is_square() == false), "logmat_sympd(): given matrix must be square sized" );
+2 -2
View File
@@ -268,8 +268,8 @@ op_princomp::direct_princomp
typedef typename T1::elem_type eT;
typedef typename T1::pod_type T;
const unwrap<T1> Y( X.get_ref() );
const Mat<eT>& in = Y.M;
const plain_unwrap<T1> Y( X.get_ref() );
const Mat<eT>& in = Y.M;
if(in.n_elem != 0)
{
+2 -2
View File
@@ -36,8 +36,8 @@ op_reshape::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_reshape>& in)
if(is_Mat<T1>::value)
{
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(&out == &A)
{
+2 -2
View File
@@ -36,8 +36,8 @@ op_resize::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_resize>& in)
if(is_Mat<T1>::value)
{
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(&out == &A)
{
+2 -2
View File
@@ -36,7 +36,7 @@ op_reverse::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_reverse>& in)
if(is_Mat<T1>::value)
{
const unwrap<T1> U(in.m);
const plain_unwrap<T1> U(in.m);
if(&out == &(U.M))
{
@@ -101,7 +101,7 @@ op_reverse_vec::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_reverse_v
if(is_Mat<T1>::value)
{
const unwrap<T1> U(in.m);
const plain_unwrap<T1> U(in.m);
if(&out == &(U.M))
{
+2 -2
View File
@@ -213,7 +213,7 @@ op_shuffle::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_shuffle>& in)
{
arma_debug_sigprint();
const unwrap<T1> U(in.m);
const plain_unwrap<T1> U(in.m);
const uword dim = in.aux_uword_a;
@@ -231,7 +231,7 @@ op_shuffle_vec::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_shuffle_v
{
arma_debug_sigprint();
const unwrap<T1> U(in.m);
const plain_unwrap<T1> U(in.m);
const uword dim = (T1::is_xvec) ? uword(U.M.is_rowvec() ? 1 : 0) : uword((T1::is_row) ? 1 : 0);
+2 -2
View File
@@ -264,8 +264,8 @@ op_sort_vec::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sort_vec>& i
typedef typename T1::elem_type eT;
const unwrap<T1> U(in.m); // not using quasi_unwrap, to ensure there is no aliasing with subviews
const Mat<eT>& X = U.M;
const plain_unwrap<T1> U(in.m); // not using quasi_unwrap, to ensure there is no aliasing with subviews
const Mat<eT>& X = U.M;
const uword sort_mode = in.aux_uword_a;
+2 -2
View File
@@ -477,8 +477,8 @@ op_sqrtmat_sympd::apply_direct(Mat<typename T1::elem_type>& out, const Base<type
typedef typename T1::elem_type eT;
typedef typename T1::pod_type T;
const unwrap<T1> U(expr.get_ref());
const Mat<eT>& X = U.M;
const plain_unwrap<T1> U(expr.get_ref());
const Mat<eT>& X = U.M;
arma_conform_check( (X.is_square() == false), "sqrtmat_sympd(): given matrix must be square sized" );
+1 -1
View File
@@ -389,7 +389,7 @@ op_strans::apply_direct(Mat<typename T1::elem_type>& out, const T1& X)
// allow detection of in-place transpose
if(is_Mat<T1>::value)
{
const unwrap<T1> U(X);
const plain_unwrap<T1> U(X);
op_strans::apply_mat(out, U.M);
}
+8 -8
View File
@@ -30,8 +30,8 @@ op_symmatu::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_symmatu>& in)
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
arma_conform_check( (A.is_square() == false), "symmatu(): given matrix must be square sized" );
@@ -81,8 +81,8 @@ op_symmatl::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_symmatl>& in)
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
arma_conform_check( (A.is_square() == false), "symmatl(): given matrix must be square sized" );
@@ -136,8 +136,8 @@ op_symmatu_cx::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_symmatu_cx
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
arma_conform_check( (A.is_square() == false), "symmatu(): given matrix must be square sized" );
@@ -210,8 +210,8 @@ op_symmatl_cx::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_symmatl_cx
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
arma_conform_check( (A.is_square() == false), "symmatl(): given matrix must be square sized" );
+5 -5
View File
@@ -70,7 +70,7 @@ op_trimat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trimat>& in)
// allow detection of in-place operation
if(is_Mat<T1>::value)
{
const unwrap<T1> U(in.m);
const plain_unwrap<T1> U(in.m);
if(&out == &(U.M))
{
@@ -236,8 +236,8 @@ op_trimatu_ext::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trimatu_e
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
arma_conform_check( (A.is_square() == false), "trimatu(): given matrix must be square sized" );
@@ -327,8 +327,8 @@ op_trimatl_ext::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_trimatl_e
typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M;
arma_conform_check( (A.is_square() == false), "trimatl(): given matrix must be square sized" );
+2 -2
View File
@@ -46,7 +46,7 @@ op_vectorise_col::apply_direct(Mat<typename T1::elem_type>& out, const T1& expr)
// allow detection of in-place operation
if(is_Mat<T1>::value)
{
const unwrap<T1> U(expr);
const plain_unwrap<T1> U(expr);
if(&out == &(U.M))
{
@@ -317,7 +317,7 @@ op_vectorise_row::apply_proxy(Mat<typename T1::elem_type>& out, const Proxy<T1>&
{
if(is_Mat<typename Proxy<T1>::stored_type>::value)
{
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const plain_unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
arrayops::copy(out.memptr(), tmp.M.memptr(), n_elem);
}
+1 -1
View File
@@ -1303,7 +1303,7 @@ sp_auxlib::spsolve_refine(Mat<typename T1::elem_type>& X, typename T1::pod_type&
const unwrap_spmat<T1> tmp1(A_expr.get_ref());
const SpMat<eT>& A = tmp1.M;
const unwrap<T2> tmp2(B_expr.get_ref());
const plain_unwrap<T2> tmp2(B_expr.get_ref());
const Mat<eT>& B_unwrap = tmp2.M;
const bool B_is_modified = ( (user_opts.equilibrate) || (&B_unwrap == &X) );
@@ -35,6 +35,8 @@ class spdiagview : public SpBase< eT, spdiagview<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;
+4 -4
View File
@@ -283,7 +283,7 @@ spdiagview<eT>::operator+=(const Base<eT,T1>& o)
if( (is_Mat<typename Proxy<T1>::stored_type>::value) || (Proxy<T1>::use_at) )
{
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const plain_unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const Mat<eT>& x = tmp.M;
const eT* x_mem = x.memptr();
@@ -332,7 +332,7 @@ spdiagview<eT>::operator-=(const Base<eT,T1>& o)
if( (is_Mat<typename Proxy<T1>::stored_type>::value) || (Proxy<T1>::use_at) )
{
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const plain_unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const Mat<eT>& x = tmp.M;
const eT* x_mem = x.memptr();
@@ -381,7 +381,7 @@ spdiagview<eT>::operator%=(const Base<eT,T1>& o)
if( (is_Mat<typename Proxy<T1>::stored_type>::value) || (Proxy<T1>::use_at) )
{
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const plain_unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const Mat<eT>& x = tmp.M;
const eT* x_mem = x.memptr();
@@ -430,7 +430,7 @@ spdiagview<eT>::operator/=(const Base<eT,T1>& o)
if( (is_Mat<typename Proxy<T1>::stored_type>::value) || (Proxy<T1>::use_at) )
{
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const plain_unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
const Mat<eT>& x = tmp.M;
const eT* x_mem = x.memptr();
+42
View File
@@ -168,6 +168,48 @@ struct strip_trimat< Op<T1, op_trimat> >
template<typename T1>
struct strip_op_find_default
{
typedef T1 stored_type;
inline
strip_op_find_default(const T1& X)
: M(X)
{
arma_debug_sigprint();
}
static constexpr bool do_op_find_default = false;
const T1& M;
};
template<typename T1>
struct strip_op_find_default< mtOp<uword, T1, op_find_default> >
{
typedef T1 stored_type;
inline
strip_op_find_default(const mtOp<uword, T1, op_find_default>& X)
: M(X.m)
{
arma_debug_sigprint();
}
static constexpr bool do_op_find_default = true;
const T1& M;
};
//
template<typename T1>
struct sp_strip_trans
{
+12
View File
@@ -36,6 +36,8 @@ class subview : public Base< eT, subview<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;
@@ -376,6 +378,8 @@ class subview_col : public subview<eT>
static constexpr bool is_col = true;
static constexpr bool is_xvec = false;
static constexpr bool has_subview = true;
const eT* colmem;
inline void operator= (const subview<eT>& x);
@@ -480,6 +484,8 @@ class subview_cols : public subview<eT>
static constexpr bool is_col = false;
static constexpr bool is_xvec = false;
static constexpr bool has_subview = true;
inline subview_cols(const subview_cols& in);
inline subview_cols( subview_cols&& in);
@@ -541,6 +547,8 @@ class subview_row : public subview<eT>
static constexpr bool is_col = false;
static constexpr bool is_xvec = false;
static constexpr bool has_subview = true;
const eT* rowmem;
inline void operator= (const subview<eT>& x);
@@ -644,6 +652,8 @@ class subview_row_strans : public Base< eT, subview_row_strans<eT> >
static constexpr bool is_col = true;
static constexpr bool is_xvec = false;
static constexpr bool has_subview = true;
arma_aligned const subview_row<eT>& sv_row;
const uword n_rows; // equal to n_elem
@@ -679,6 +689,8 @@ class subview_row_htrans : public Base< eT, subview_row_htrans<eT> >
static constexpr bool is_col = true;
static constexpr bool is_xvec = false;
static constexpr bool has_subview = true;
arma_aligned const subview_row<eT>& sv_row;
const uword n_rows; // equal to n_elem
@@ -50,6 +50,8 @@ class subview_cube : public BaseCube< eT, subview_cube<eT> >
public:
static constexpr bool has_subview = true;
inline ~subview_cube();
inline subview_cube() = delete;
@@ -101,8 +101,8 @@ subview_cube_each1<eT>::operator= (const Base<eT,T1>& in)
Cube<eT>& p = access::rw(subview_cube_each_common<eT>::P);
const unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
subview_cube_each_common<eT>::check_size(A);
@@ -128,8 +128,8 @@ subview_cube_each1<eT>::operator+= (const Base<eT,T1>& in)
Cube<eT>& p = access::rw(subview_cube_each_common<eT>::P);
const unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
subview_cube_each_common<eT>::check_size(A);
@@ -155,8 +155,8 @@ subview_cube_each1<eT>::operator-= (const Base<eT,T1>& in)
Cube<eT>& p = access::rw(subview_cube_each_common<eT>::P);
const unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
subview_cube_each_common<eT>::check_size(A);
@@ -182,8 +182,8 @@ subview_cube_each1<eT>::operator%= (const Base<eT,T1>& in)
Cube<eT>& p = access::rw(subview_cube_each_common<eT>::P);
const unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
subview_cube_each_common<eT>::check_size(A);
@@ -209,8 +209,8 @@ subview_cube_each1<eT>::operator/= (const Base<eT,T1>& in)
Cube<eT>& p = access::rw(subview_cube_each_common<eT>::P);
const unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
subview_cube_each_common<eT>::check_size(A);
@@ -287,12 +287,12 @@ subview_cube_each2<eT,TB>::operator= (const Base<eT,T1>& in)
Cube<eT>& p = access::rw(subview_cube_each_common<eT>::P);
const unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
subview_cube_each_common<eT>::check_size(A);
const unwrap<TB> U( base_indices.get_ref() );
const plain_unwrap<TB> U( base_indices.get_ref() );
check_indices(U.M);
@@ -328,12 +328,12 @@ subview_cube_each2<eT,TB>::operator+= (const Base<eT,T1>& in)
Cube<eT>& p = access::rw(subview_cube_each_common<eT>::P);
const unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
subview_cube_each_common<eT>::check_size(A);
const unwrap<TB> U( base_indices.get_ref() );
const plain_unwrap<TB> U( base_indices.get_ref() );
check_indices(U.M);
@@ -369,12 +369,12 @@ subview_cube_each2<eT,TB>::operator-= (const Base<eT,T1>& in)
Cube<eT>& p = access::rw(subview_cube_each_common<eT>::P);
const unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
subview_cube_each_common<eT>::check_size(A);
const unwrap<TB> U( base_indices.get_ref() );
const plain_unwrap<TB> U( base_indices.get_ref() );
check_indices(U.M);
@@ -410,12 +410,12 @@ subview_cube_each2<eT,TB>::operator%= (const Base<eT,T1>& in)
Cube<eT>& p = access::rw(subview_cube_each_common<eT>::P);
const unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
subview_cube_each_common<eT>::check_size(A);
const unwrap<TB> U( base_indices.get_ref() );
const plain_unwrap<TB> U( base_indices.get_ref() );
check_indices(U.M);
@@ -451,12 +451,12 @@ subview_cube_each2<eT,TB>::operator/= (const Base<eT,T1>& in)
Cube<eT>& p = access::rw(subview_cube_each_common<eT>::P);
const unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
const plain_unwrap<T1> tmp( in.get_ref() );
const Mat<eT>& A = tmp.M;
subview_cube_each_common<eT>::check_size(A);
const unwrap<TB> U( base_indices.get_ref() );
const plain_unwrap<TB> U( base_indices.get_ref() );
check_indices(U.M);
@@ -507,8 +507,8 @@ subview_cube_each1_aux::operator_plus
Cube<eT> out(p_n_rows, p_n_cols, p_n_slices, arma_nozeros_indicator());
const unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const plain_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
X.check_size(A);
@@ -547,8 +547,8 @@ subview_cube_each1_aux::operator_minus
Cube<eT> out(p_n_rows, p_n_cols, p_n_slices, arma_nozeros_indicator());
const unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const plain_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
X.check_size(A);
@@ -587,8 +587,8 @@ subview_cube_each1_aux::operator_minus
Cube<eT> out(p_n_rows, p_n_cols, p_n_slices, arma_nozeros_indicator());
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;
Y.check_size(A);
@@ -627,8 +627,8 @@ subview_cube_each1_aux::operator_schur
Cube<eT> out(p_n_rows, p_n_cols, p_n_slices, arma_nozeros_indicator());
const unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const plain_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
X.check_size(A);
@@ -667,8 +667,8 @@ subview_cube_each1_aux::operator_div
Cube<eT> out(p_n_rows, p_n_cols, p_n_slices, arma_nozeros_indicator());
const unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const plain_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
X.check_size(A);
@@ -707,8 +707,8 @@ subview_cube_each1_aux::operator_div
Cube<eT> out(p_n_rows, p_n_cols, p_n_slices, arma_nozeros_indicator());
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;
Y.check_size(A);
@@ -741,8 +741,8 @@ subview_cube_each1_aux::operator_times
const Cube<eT>& C = X.P;
const unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& M = tmp.M;
const plain_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& M = tmp.M;
if(arma_config::check_conform)
{
@@ -782,8 +782,8 @@ subview_cube_each1_aux::operator_times
{
arma_debug_sigprint();
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;
const Cube<eT>& C = Y.P;
@@ -838,10 +838,10 @@ subview_cube_each2_aux::operator_plus
Cube<eT> out = p;
const unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const plain_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const unwrap<TB> U(X.base_indices.get_ref());
const plain_unwrap<TB> U(X.base_indices.get_ref());
X.check_size(A);
X.check_indices(U.M);
@@ -885,10 +885,10 @@ subview_cube_each2_aux::operator_minus
Cube<eT> out = p;
const unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const plain_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const unwrap<TB> U(X.base_indices.get_ref());
const plain_unwrap<TB> U(X.base_indices.get_ref());
X.check_size(A);
X.check_indices(U.M);
@@ -933,10 +933,10 @@ subview_cube_each2_aux::operator_minus
Cube<eT> out = p;
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;
const unwrap<TB> U(Y.base_indices.get_ref());
const plain_unwrap<TB> U(Y.base_indices.get_ref());
Y.check_size(A);
Y.check_indices(U.M);
@@ -981,10 +981,10 @@ subview_cube_each2_aux::operator_schur
Cube<eT> out = p;
const unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const plain_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const unwrap<TB> U(X.base_indices.get_ref());
const plain_unwrap<TB> U(X.base_indices.get_ref());
X.check_size(A);
X.check_indices(U.M);
@@ -1028,10 +1028,10 @@ subview_cube_each2_aux::operator_div
Cube<eT> out = p;
const unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const plain_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const unwrap<TB> U(X.base_indices.get_ref());
const plain_unwrap<TB> U(X.base_indices.get_ref());
X.check_size(A);
X.check_indices(U.M);
@@ -1076,10 +1076,10 @@ subview_cube_each2_aux::operator_div
Cube<eT> out = p;
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;
const unwrap<TB> U(Y.base_indices.get_ref());
const plain_unwrap<TB> U(Y.base_indices.get_ref());
Y.check_size(A);
Y.check_indices(U.M);
+8 -1
View File
@@ -1257,7 +1257,7 @@ void
subview_cube<eT>::fill(const eT val)
{
arma_debug_sigprint();
const uword local_n_rows = n_rows;
const uword local_n_cols = n_cols;
const uword local_n_slices = n_slices;
@@ -1288,6 +1288,13 @@ subview_cube<eT>::zeros()
if( (local_n_rows == 0) || (local_n_cols == 0) ) { return; }
if( (aux_row1 == 0) && (local_n_rows == m.n_rows) && (aux_col1 == 0) && (local_n_cols == m.n_cols) )
{
arrayops::fill_zeros( slice_colptr(0,0), n_elem );
return;
}
for(uword slice = 0; slice < local_n_slices; ++slice)
{
for(uword col = 0; col < local_n_cols; ++col)
@@ -40,6 +40,8 @@ class subview_cube_slices : public BaseCube< eT, subview_cube_slices<eT,T1> >
public:
static constexpr bool has_subview = true;
inline ~subview_cube_slices();
inline subview_cube_slices() = delete;
+6 -6
View File
@@ -1078,7 +1078,7 @@ subview_each2_aux::operator_plus
const quasi_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const unwrap<TB> U(X.base_indices.get_ref());
const plain_unwrap<TB> U(X.base_indices.get_ref());
X.check_size(A);
X.check_indices(U.M);
@@ -1142,7 +1142,7 @@ subview_each2_aux::operator_minus
const quasi_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const unwrap<TB> U(X.base_indices.get_ref());
const plain_unwrap<TB> U(X.base_indices.get_ref());
X.check_size(A);
X.check_indices(U.M);
@@ -1206,7 +1206,7 @@ subview_each2_aux::operator_minus
const quasi_unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M;
const unwrap<TB> U(Y.base_indices.get_ref());
const plain_unwrap<TB> U(Y.base_indices.get_ref());
Y.check_size(A);
Y.check_indices(U.M);
@@ -1276,7 +1276,7 @@ subview_each2_aux::operator_schur
const quasi_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const unwrap<TB> U(X.base_indices.get_ref());
const plain_unwrap<TB> U(X.base_indices.get_ref());
X.check_size(A);
X.check_indices(U.M);
@@ -1340,7 +1340,7 @@ subview_each2_aux::operator_div
const quasi_unwrap<T2> tmp(Y.get_ref());
const Mat<eT>& A = tmp.M;
const unwrap<TB> U(X.base_indices.get_ref());
const plain_unwrap<TB> U(X.base_indices.get_ref());
X.check_size(A);
X.check_indices(U.M);
@@ -1404,7 +1404,7 @@ subview_each2_aux::operator_div
const quasi_unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M;
const unwrap<TB> U(Y.base_indices.get_ref());
const plain_unwrap<TB> U(Y.base_indices.get_ref());
Y.check_size(A);
Y.check_indices(U.M);
+9 -20
View File
@@ -33,9 +33,11 @@ class subview_elem1 : public Base< eT, subview_elem1<eT,T1> >
static constexpr bool is_col = true;
static constexpr bool is_xvec = false;
arma_aligned const Mat<eT> fake_m;
arma_aligned const Mat<eT>& m;
arma_aligned const Base<uword,T1>& a;
static constexpr bool has_subview = true;
const Mat<eT> fake_m;
const Mat<eT>& m;
const Base<uword,T1>& a;
protected:
@@ -49,9 +51,8 @@ class subview_elem1 : public Base< eT, subview_elem1<eT,T1> >
inline ~subview_elem1();
inline subview_elem1() = delete;
template<typename op_type> inline void inplace_op(const eT val);
template<typename op_type, typename T2> inline void inplace_op(const subview_elem1<eT,T2>& x );
template<typename op_type, typename T2> inline void inplace_op(const Base<eT,T2>& x );
template<typename op_type> inline void inplace_op(const eT val );
template<typename op_type, typename T2> inline void inplace_op(const Base<eT,T2>& expr);
arma_inline const Op<subview_elem1<eT,T1>,op_htrans> t() const;
arma_inline const Op<subview_elem1<eT,T1>,op_htrans> ht() const;
@@ -76,13 +77,8 @@ class subview_elem1 : public Base< eT, subview_elem1<eT,T1> >
// deliberately returning void
template<typename T2> inline void operator_equ(const subview_elem1<eT,T2>& x);
template<typename T2> inline void operator= (const subview_elem1<eT,T2>& x);
inline void operator= (const subview_elem1<eT,T1>& x);
template<typename T2> inline void operator+= (const subview_elem1<eT,T2>& x);
template<typename T2> inline void operator-= (const subview_elem1<eT,T2>& x);
template<typename T2> inline void operator%= (const subview_elem1<eT,T2>& x);
template<typename T2> inline void operator/= (const subview_elem1<eT,T2>& x);
template<typename T2> inline void operator= (const subview_elem1<eT,T2>& x);
inline void operator= (const subview_elem1<eT,T1>& x);
template<typename T2> inline void operator= (const Base<eT,T2>& x);
template<typename T2> inline void operator+= (const Base<eT,T2>& x);
@@ -94,13 +90,6 @@ class subview_elem1 : public Base< eT, subview_elem1<eT,T1> >
inline static void extract(Mat<eT>& out, const subview_elem1& in);
template<typename op_type> inline static void mat_inplace_op(Mat<eT>& out, const subview_elem1& in);
inline static void plus_inplace(Mat<eT>& out, const subview_elem1& in);
inline static void minus_inplace(Mat<eT>& out, const subview_elem1& in);
inline static void schur_inplace(Mat<eT>& out, const subview_elem1& in);
inline static void div_inplace(Mat<eT>& out, const subview_elem1& in);
template<typename eT2>
inline bool is_alias(const Mat<eT2>& X) const;
+197 -406
View File
@@ -64,8 +64,33 @@ subview_elem1<eT,T1>::inplace_op(const eT val)
eT* m_mem = m_local.memptr();
const uword m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local);
const umat& aa = tmp.M;
if(strip_op_find_default<T1>::do_op_find_default)
{
const strip_op_find_default<T1> strip(a.get_ref());
constexpr bool has_sv = strip_op_find_default<T1>::stored_type::has_subview;
if( (has_sv == false) || ((has_sv == true) && (strip.M.is_alias(m_local) == false)) )
{
if(has_sv == false) { arma_debug_print("op_find_default optimisation; has_sv = false"); }
if(has_sv == true ) { arma_debug_print("op_find_default optimisation; has_sv = true" ); }
bool mi_bad = false;
if(is_same_type<op_type, op_internal_equ >::yes) { auto modifier = [&](const uword mi) { if(mi < m_n_elem) { m_mem[mi] = val; } else { mi_bad = true; } }; op_find_aux::apply(modifier, strip.M); }
if(is_same_type<op_type, op_internal_plus >::yes) { auto modifier = [&](const uword mi) { if(mi < m_n_elem) { m_mem[mi] += val; } else { mi_bad = true; } }; op_find_aux::apply(modifier, strip.M); }
if(is_same_type<op_type, op_internal_minus>::yes) { auto modifier = [&](const uword mi) { if(mi < m_n_elem) { m_mem[mi] -= val; } else { mi_bad = true; } }; op_find_aux::apply(modifier, strip.M); }
if(is_same_type<op_type, op_internal_schur>::yes) { auto modifier = [&](const uword mi) { if(mi < m_n_elem) { m_mem[mi] *= val; } else { mi_bad = true; } }; op_find_aux::apply(modifier, strip.M); }
if(is_same_type<op_type, op_internal_div >::yes) { auto modifier = [&](const uword mi) { if(mi < m_n_elem) { m_mem[mi] /= val; } else { mi_bad = true; } }; op_find_aux::apply(modifier, strip.M); }
arma_conform_check_bounds( mi_bad, "Mat::elem(): index out of bounds" );
return;
}
}
const unwrap_check_mixed<T1> U(a.get_ref(), m_local);
const umat& aa = U.M;
if(resolves_to_vector<T1>::no)
{
@@ -75,33 +100,47 @@ subview_elem1<eT,T1>::inplace_op(const eT val)
const uword* aa_mem = aa.memptr();
const uword aa_n_elem = aa.n_elem;
bool ii_jj_bad = false;
uword iq,jq;
for(iq=0, jq=1; jq < aa_n_elem; iq+=2, jq+=2)
{
const uword ii = aa_mem[iq];
const uword jj = aa_mem[jq];
arma_conform_check_bounds( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem(): index out of bounds" );
if(is_same_type<op_type, op_internal_equ >::yes) { m_mem[ii] = val; m_mem[jj] = val; }
if(is_same_type<op_type, op_internal_plus >::yes) { m_mem[ii] += val; m_mem[jj] += val; }
if(is_same_type<op_type, op_internal_minus>::yes) { m_mem[ii] -= val; m_mem[jj] -= val; }
if(is_same_type<op_type, op_internal_schur>::yes) { m_mem[ii] *= val; m_mem[jj] *= val; }
if(is_same_type<op_type, op_internal_div >::yes) { m_mem[ii] /= val; m_mem[jj] /= val; }
if( (ii < m_n_elem) && (jj < m_n_elem) )
{
if(is_same_type<op_type, op_internal_equ >::yes) { m_mem[ii] = val; m_mem[jj] = val; }
if(is_same_type<op_type, op_internal_plus >::yes) { m_mem[ii] += val; m_mem[jj] += val; }
if(is_same_type<op_type, op_internal_minus>::yes) { m_mem[ii] -= val; m_mem[jj] -= val; }
if(is_same_type<op_type, op_internal_schur>::yes) { m_mem[ii] *= val; m_mem[jj] *= val; }
if(is_same_type<op_type, op_internal_div >::yes) { m_mem[ii] /= val; m_mem[jj] /= val; }
}
else
{
ii_jj_bad = true;
}
}
if(iq < aa_n_elem)
{
const uword ii = aa_mem[iq];
arma_conform_check_bounds( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
if(is_same_type<op_type, op_internal_equ >::yes) { m_mem[ii] = val; }
if(is_same_type<op_type, op_internal_plus >::yes) { m_mem[ii] += val; }
if(is_same_type<op_type, op_internal_minus>::yes) { m_mem[ii] -= val; }
if(is_same_type<op_type, op_internal_schur>::yes) { m_mem[ii] *= val; }
if(is_same_type<op_type, op_internal_div >::yes) { m_mem[ii] /= val; }
if(ii < m_n_elem)
{
if(is_same_type<op_type, op_internal_equ >::yes) { m_mem[ii] = val; }
if(is_same_type<op_type, op_internal_plus >::yes) { m_mem[ii] += val; }
if(is_same_type<op_type, op_internal_minus>::yes) { m_mem[ii] -= val; }
if(is_same_type<op_type, op_internal_schur>::yes) { m_mem[ii] *= val; }
if(is_same_type<op_type, op_internal_div >::yes) { m_mem[ii] /= val; }
}
else
{
ii_jj_bad = true;
}
}
arma_conform_check_bounds( ii_jj_bad, "Mat::elem(): index out of bounds" );
}
@@ -110,104 +149,7 @@ template<typename eT, typename T1>
template<typename op_type, typename T2>
inline
void
subview_elem1<eT,T1>::inplace_op(const subview_elem1<eT,T2>& x)
{
arma_debug_sigprint();
subview_elem1<eT,T1>& s = *this;
if(&(s.m) == &(x.m))
{
arma_debug_print("subview_elem1::inplace_op(): aliasing detected");
const Mat<eT> tmp(x);
if(is_same_type<op_type, op_internal_equ >::yes) { s.operator= (tmp); }
if(is_same_type<op_type, op_internal_plus >::yes) { s.operator+=(tmp); }
if(is_same_type<op_type, op_internal_minus>::yes) { s.operator-=(tmp); }
if(is_same_type<op_type, op_internal_schur>::yes) { s.operator%=(tmp); }
if(is_same_type<op_type, op_internal_div >::yes) { s.operator/=(tmp); }
}
else
{
Mat<eT>& s_m_local = const_cast< Mat<eT>& >(s.m);
const Mat<eT>& x_m_local = x.m;
const unwrap_check_mixed<T1> s_tmp(s.a.get_ref(), s_m_local);
const unwrap_check_mixed<T2> x_tmp(x.a.get_ref(), s_m_local);
const umat& s_aa = s_tmp.M;
const umat& x_aa = x_tmp.M;
arma_conform_check
(
( ((s_aa.is_vec() == false) && (s_aa.is_empty() == false)) || ((x_aa.is_vec() == false) && (x_aa.is_empty() == false)) ),
"Mat::elem(): given object must be a vector"
);
const uword* s_aa_mem = s_aa.memptr();
const uword* x_aa_mem = x_aa.memptr();
const uword s_aa_n_elem = s_aa.n_elem;
arma_conform_check( (s_aa_n_elem != x_aa.n_elem), "Mat::elem(): size mismatch" );
eT* s_m_mem = s_m_local.memptr();
const uword s_m_n_elem = s_m_local.n_elem;
const eT* x_m_mem = x_m_local.memptr();
const uword x_m_n_elem = x_m_local.n_elem;
uword iq,jq;
for(iq=0, jq=1; jq < s_aa_n_elem; iq+=2, jq+=2)
{
const uword s_ii = s_aa_mem[iq];
const uword s_jj = s_aa_mem[jq];
const uword x_ii = x_aa_mem[iq];
const uword x_jj = x_aa_mem[jq];
arma_conform_check_bounds
(
(s_ii >= s_m_n_elem) || (s_jj >= s_m_n_elem) || (x_ii >= x_m_n_elem) || (x_jj >= x_m_n_elem),
"Mat::elem(): index out of bounds"
);
if(is_same_type<op_type, op_internal_equ >::yes) { s_m_mem[s_ii] = x_m_mem[x_ii]; s_m_mem[s_jj] = x_m_mem[x_jj]; }
if(is_same_type<op_type, op_internal_plus >::yes) { s_m_mem[s_ii] += x_m_mem[x_ii]; s_m_mem[s_jj] += x_m_mem[x_jj]; }
if(is_same_type<op_type, op_internal_minus>::yes) { s_m_mem[s_ii] -= x_m_mem[x_ii]; s_m_mem[s_jj] -= x_m_mem[x_jj]; }
if(is_same_type<op_type, op_internal_schur>::yes) { s_m_mem[s_ii] *= x_m_mem[x_ii]; s_m_mem[s_jj] *= x_m_mem[x_jj]; }
if(is_same_type<op_type, op_internal_div >::yes) { s_m_mem[s_ii] /= x_m_mem[x_ii]; s_m_mem[s_jj] /= x_m_mem[x_jj]; }
}
if(iq < s_aa_n_elem)
{
const uword s_ii = s_aa_mem[iq];
const uword x_ii = x_aa_mem[iq];
arma_conform_check_bounds
(
( (s_ii >= s_m_n_elem) || (x_ii >= x_m_n_elem) ),
"Mat::elem(): index out of bounds"
);
if(is_same_type<op_type, op_internal_equ >::yes) { s_m_mem[s_ii] = x_m_mem[x_ii]; }
if(is_same_type<op_type, op_internal_plus >::yes) { s_m_mem[s_ii] += x_m_mem[x_ii]; }
if(is_same_type<op_type, op_internal_minus>::yes) { s_m_mem[s_ii] -= x_m_mem[x_ii]; }
if(is_same_type<op_type, op_internal_schur>::yes) { s_m_mem[s_ii] *= x_m_mem[x_ii]; }
if(is_same_type<op_type, op_internal_div >::yes) { s_m_mem[s_ii] /= x_m_mem[x_ii]; }
}
}
}
template<typename eT, typename T1>
template<typename op_type, typename T2>
inline
void
subview_elem1<eT,T1>::inplace_op(const Base<eT,T2>& x)
subview_elem1<eT,T1>::inplace_op(const Base<eT,T2>& expr)
{
arma_debug_sigprint();
@@ -216,8 +158,45 @@ subview_elem1<eT,T1>::inplace_op(const Base<eT,T2>& x)
eT* m_mem = m_local.memptr();
const uword m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> aa_tmp(a.get_ref(), m_local);
const umat& aa = aa_tmp.M;
typedef typename quasi_unwrap<T2>::stored_type U1_M_type;
const quasi_unwrap<T2 > U1(expr.get_ref());
const unwrap_check<U1_M_type> U2(U1.M, U1.is_alias(m_local));
const eT* X_mem = U2.M.memptr();
const uword X_n_elem = U2.M.n_elem;
if(strip_op_find_default<T1>::do_op_find_default)
{
const strip_op_find_default<T1> strip(a.get_ref());
constexpr bool has_sv = strip_op_find_default<T1>::stored_type::has_subview;
if( (has_sv == false) || ((has_sv == true) && (strip.M.is_alias(m_local) == false)) )
{
if(has_sv == false) { arma_debug_print("op_find_default optimisation; has_sv = false"); }
if(has_sv == true ) { arma_debug_print("op_find_default optimisation; has_sv = true" ); }
bool mi_bad = false;
uword Xi = 0;
if(is_same_type<op_type, op_internal_equ >::yes) { auto modifier = [&](const uword mi) { if(mi < m_n_elem) { if(Xi < X_n_elem) { m_mem[mi] = X_mem[Xi]; } } else { mi_bad = true; } ++Xi; }; op_find_aux::apply(modifier, strip.M); }
if(is_same_type<op_type, op_internal_plus >::yes) { auto modifier = [&](const uword mi) { if(mi < m_n_elem) { if(Xi < X_n_elem) { m_mem[mi] += X_mem[Xi]; } } else { mi_bad = true; } ++Xi; }; op_find_aux::apply(modifier, strip.M); }
if(is_same_type<op_type, op_internal_minus>::yes) { auto modifier = [&](const uword mi) { if(mi < m_n_elem) { if(Xi < X_n_elem) { m_mem[mi] -= X_mem[Xi]; } } else { mi_bad = true; } ++Xi; }; op_find_aux::apply(modifier, strip.M); }
if(is_same_type<op_type, op_internal_schur>::yes) { auto modifier = [&](const uword mi) { if(mi < m_n_elem) { if(Xi < X_n_elem) { m_mem[mi] *= X_mem[Xi]; } } else { mi_bad = true; } ++Xi; }; op_find_aux::apply(modifier, strip.M); }
if(is_same_type<op_type, op_internal_div >::yes) { auto modifier = [&](const uword mi) { if(mi < m_n_elem) { if(Xi < X_n_elem) { m_mem[mi] /= X_mem[Xi]; } } else { mi_bad = true; } ++Xi; }; op_find_aux::apply(modifier, strip.M); }
arma_conform_check_bounds( mi_bad, "Mat::elem(): index out of bounds" );
arma_conform_check( (Xi != X_n_elem), "Mat::elem(): size mismatch" );
return;
}
}
const unwrap_check_mixed<T1> U(a.get_ref(), m_local);
const umat& aa = U.M;
if(resolves_to_vector<T1>::no)
{
@@ -227,81 +206,49 @@ subview_elem1<eT,T1>::inplace_op(const Base<eT,T2>& x)
const uword* aa_mem = aa.memptr();
const uword aa_n_elem = aa.n_elem;
const Proxy<T2> P(x.get_ref());
arma_conform_check( (aa_n_elem != X_n_elem), "Mat::elem(): size mismatch" );
arma_conform_check( (aa_n_elem != P.get_n_elem()), "Mat::elem(): size mismatch" );
bool ii_jj_bad = false;
const bool have_alias = P.is_alias(m);
if( (have_alias == false) && (Proxy<T2>::use_at == false) )
uword iq,jq;
for(iq=0, jq=1; jq < aa_n_elem; iq+=2, jq+=2)
{
typename Proxy<T2>::ea_type X = P.get_ea();
const uword ii = aa_mem[iq];
const uword jj = aa_mem[jq];
uword iq,jq;
for(iq=0, jq=1; jq < aa_n_elem; iq+=2, jq+=2)
if( (ii < m_n_elem) && (jj < m_n_elem) )
{
const uword ii = aa_mem[iq];
const uword jj = aa_mem[jq];
arma_conform_check_bounds( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem(): index out of bounds" );
if(is_same_type<op_type, op_internal_equ >::yes) { m_mem[ii] = X[iq]; m_mem[jj] = X[jq]; }
if(is_same_type<op_type, op_internal_plus >::yes) { m_mem[ii] += X[iq]; m_mem[jj] += X[jq]; }
if(is_same_type<op_type, op_internal_minus>::yes) { m_mem[ii] -= X[iq]; m_mem[jj] -= X[jq]; }
if(is_same_type<op_type, op_internal_schur>::yes) { m_mem[ii] *= X[iq]; m_mem[jj] *= X[jq]; }
if(is_same_type<op_type, op_internal_div >::yes) { m_mem[ii] /= X[iq]; m_mem[jj] /= X[jq]; }
if(is_same_type<op_type, op_internal_equ >::yes) { m_mem[ii] = X_mem[iq]; m_mem[jj] = X_mem[jq]; }
if(is_same_type<op_type, op_internal_plus >::yes) { m_mem[ii] += X_mem[iq]; m_mem[jj] += X_mem[jq]; }
if(is_same_type<op_type, op_internal_minus>::yes) { m_mem[ii] -= X_mem[iq]; m_mem[jj] -= X_mem[jq]; }
if(is_same_type<op_type, op_internal_schur>::yes) { m_mem[ii] *= X_mem[iq]; m_mem[jj] *= X_mem[jq]; }
if(is_same_type<op_type, op_internal_div >::yes) { m_mem[ii] /= X_mem[iq]; m_mem[jj] /= X_mem[jq]; }
}
if(iq < aa_n_elem)
else
{
const uword ii = aa_mem[iq];
arma_conform_check_bounds( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
if(is_same_type<op_type, op_internal_equ >::yes) { m_mem[ii] = X[iq]; }
if(is_same_type<op_type, op_internal_plus >::yes) { m_mem[ii] += X[iq]; }
if(is_same_type<op_type, op_internal_minus>::yes) { m_mem[ii] -= X[iq]; }
if(is_same_type<op_type, op_internal_schur>::yes) { m_mem[ii] *= X[iq]; }
if(is_same_type<op_type, op_internal_div >::yes) { m_mem[ii] /= X[iq]; }
ii_jj_bad = true;
}
}
else
if(iq < aa_n_elem)
{
arma_debug_print("subview_elem1::inplace_op(): aliasing or use_at detected");
const uword ii = aa_mem[iq];
const unwrap_check<typename Proxy<T2>::stored_type> tmp(P.Q, have_alias);
const Mat<eT>& M = tmp.M;
const eT* X = M.memptr();
uword iq,jq;
for(iq=0, jq=1; jq < aa_n_elem; iq+=2, jq+=2)
if(ii < m_n_elem)
{
const uword ii = aa_mem[iq];
const uword jj = aa_mem[jq];
arma_conform_check_bounds( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem(): index out of bounds" );
if(is_same_type<op_type, op_internal_equ >::yes) { m_mem[ii] = X[iq]; m_mem[jj] = X[jq]; }
if(is_same_type<op_type, op_internal_plus >::yes) { m_mem[ii] += X[iq]; m_mem[jj] += X[jq]; }
if(is_same_type<op_type, op_internal_minus>::yes) { m_mem[ii] -= X[iq]; m_mem[jj] -= X[jq]; }
if(is_same_type<op_type, op_internal_schur>::yes) { m_mem[ii] *= X[iq]; m_mem[jj] *= X[jq]; }
if(is_same_type<op_type, op_internal_div >::yes) { m_mem[ii] /= X[iq]; m_mem[jj] /= X[jq]; }
if(is_same_type<op_type, op_internal_equ >::yes) { m_mem[ii] = X_mem[iq]; }
if(is_same_type<op_type, op_internal_plus >::yes) { m_mem[ii] += X_mem[iq]; }
if(is_same_type<op_type, op_internal_minus>::yes) { m_mem[ii] -= X_mem[iq]; }
if(is_same_type<op_type, op_internal_schur>::yes) { m_mem[ii] *= X_mem[iq]; }
if(is_same_type<op_type, op_internal_div >::yes) { m_mem[ii] /= X_mem[iq]; }
}
if(iq < aa_n_elem)
else
{
const uword ii = aa_mem[iq];
arma_conform_check_bounds( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
if(is_same_type<op_type, op_internal_equ >::yes) { m_mem[ii] = X[iq]; }
if(is_same_type<op_type, op_internal_plus >::yes) { m_mem[ii] += X[iq]; }
if(is_same_type<op_type, op_internal_minus>::yes) { m_mem[ii] -= X[iq]; }
if(is_same_type<op_type, op_internal_schur>::yes) { m_mem[ii] *= X[iq]; }
if(is_same_type<op_type, op_internal_div >::yes) { m_mem[ii] /= X[iq]; }
ii_jj_bad = true;
}
}
arma_conform_check_bounds( ii_jj_bad, "Mat::elem(): index out of bounds" );
}
@@ -353,8 +300,8 @@ subview_elem1<eT,T1>::replace(const eT old_val, const eT new_val)
eT* m_mem = m_local.memptr();
const uword m_n_elem = m_local.n_elem;
const unwrap_check_mixed<T1> tmp(a.get_ref(), m_local);
const umat& aa = tmp.M;
const unwrap_check_mixed<T1> U(a.get_ref(), m_local);
const umat& aa = U.M;
if(resolves_to_vector<T1>::no)
{
@@ -597,20 +544,6 @@ subview_elem1<eT,T1>::operator/= (const eT val)
template<typename eT, typename T1>
template<typename T2>
inline
void
subview_elem1<eT,T1>::operator_equ(const subview_elem1<eT,T2>& x)
{
arma_debug_sigprint();
inplace_op<op_internal_equ>(x);
}
template<typename eT, typename T1>
template<typename T2>
inline
@@ -619,12 +552,13 @@ subview_elem1<eT,T1>::operator= (const subview_elem1<eT,T2>& x)
{
arma_debug_sigprint();
(*this).operator_equ(x);
const Mat<eT> tmp(x);
inplace_op<op_internal_equ>(tmp);
}
//! work around compiler bugs
template<typename eT, typename T1>
inline
void
@@ -632,59 +566,9 @@ subview_elem1<eT,T1>::operator= (const subview_elem1<eT,T1>& x)
{
arma_debug_sigprint();
(*this).operator_equ(x);
}
template<typename eT, typename T1>
template<typename T2>
inline
void
subview_elem1<eT,T1>::operator+= (const subview_elem1<eT,T2>& x)
{
arma_debug_sigprint();
const Mat<eT> tmp(x);
inplace_op<op_internal_plus>(x);
}
template<typename eT, typename T1>
template<typename T2>
inline
void
subview_elem1<eT,T1>::operator-= (const subview_elem1<eT,T2>& x)
{
arma_debug_sigprint();
inplace_op<op_internal_minus>(x);
}
template<typename eT, typename T1>
template<typename T2>
inline
void
subview_elem1<eT,T1>::operator%= (const subview_elem1<eT,T2>& x)
{
arma_debug_sigprint();
inplace_op<op_internal_schur>(x);
}
template<typename eT, typename T1>
template<typename T2>
inline
void
subview_elem1<eT,T1>::operator/= (const subview_elem1<eT,T2>& x)
{
arma_debug_sigprint();
inplace_op<op_internal_div>(x);
inplace_op<op_internal_equ>(tmp);
}
@@ -766,57 +650,36 @@ subview_elem1<eT,T1>::extract_noalias(Mat<eT>& out, const subview_elem1<eT,T1>&
{
arma_debug_sigprint();
const quasi_unwrap<T1> tmp1(in.a.get_ref());
const umat& aa = tmp1.M;
if(resolves_to_vector<T1>::no)
{
arma_conform_check( ( (aa.is_vec() == false) && (aa.is_empty() == false) ), "Mat::elem(): given object must be a vector" );
}
const uword* aa_mem = aa.memptr();
const uword aa_n_elem = aa.n_elem;
const eT* m_mem = in.m.memptr();
const uword m_n_elem = in.m.n_elem;
out.set_size(aa_n_elem, 1);
eT* out_mem = out.memptr();
uword i,j;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2)
if(strip_op_find_default<T1>::do_op_find_default)
{
const uword ii = aa_mem[i];
const uword jj = aa_mem[j];
arma_debug_print("op_find_default optimisation");
arma_conform_check_bounds( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem(): index out of bounds" );
const strip_op_find_default<T1> strip(in.a.get_ref());
out_mem[i] = m_mem[ii];
out_mem[j] = m_mem[jj];
Mat<eT> tmp(m_n_elem, 1, arma_nozeros_indicator()); // worst-case scenario
eT* tmp_mem = tmp.memptr();
uword count = 0;
bool mi_bad = false;
auto element_extractor = [&](const uword mi) { if((mi < m_n_elem) && (count < m_n_elem)) { tmp_mem[count] = m_mem[mi]; ++count; } else { mi_bad = true; } };
op_find_aux::apply(element_extractor, strip.M);
arma_conform_check_bounds( mi_bad, "Mat::elem(): index out of bounds" );
out.steal_mem_col(tmp, count);
return;
}
if(i < aa_n_elem)
{
const uword ii = aa_mem[i];
arma_conform_check_bounds( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
out_mem[i] = m_mem[ii];
}
}
template<typename eT, typename T1>
inline
void
subview_elem1<eT,T1>::extract(Mat<eT>& actual_out, const subview_elem1<eT,T1>& in)
{
arma_debug_sigprint();
const unwrap_check_mixed<T1> tmp1(in.a.get_ref(), actual_out);
const umat& aa = tmp1.M;
const quasi_unwrap<T1> U(in.a.get_ref());
const umat& aa = U.M;
if(resolves_to_vector<T1>::no)
{
@@ -826,80 +689,11 @@ subview_elem1<eT,T1>::extract(Mat<eT>& actual_out, const subview_elem1<eT,T1>& i
const uword* aa_mem = aa.memptr();
const uword aa_n_elem = aa.n_elem;
const Mat<eT>& m = in.m;
const eT* m_mem = m.memptr();
const uword m_n_elem = m.n_elem;
const bool alias = (&actual_out == &m);
if(alias) { arma_debug_print("subview_elem1::extract(): aliasing detected"); }
Mat<eT>* tmp_out = alias ? new Mat<eT>() : nullptr;
Mat<eT>& out = alias ? *tmp_out : actual_out;
out.set_size(aa_n_elem, 1);
eT* out_mem = out.memptr();
uword i,j;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2)
{
const uword ii = aa_mem[i];
const uword jj = aa_mem[j];
arma_conform_check_bounds( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem(): index out of bounds" );
out_mem[i] = m_mem[ii];
out_mem[j] = m_mem[jj];
}
if(i < aa_n_elem)
{
const uword ii = aa_mem[i];
arma_conform_check_bounds( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
out_mem[i] = m_mem[ii];
}
if(alias)
{
actual_out.steal_mem(out);
delete tmp_out;
}
}
template<typename eT, typename T1>
template<typename op_type>
inline
void
subview_elem1<eT,T1>::mat_inplace_op(Mat<eT>& out, const subview_elem1& in)
{
arma_debug_sigprint();
const unwrap<T1> tmp1(in.a.get_ref());
const umat& aa = tmp1.M;
if(resolves_to_vector<T1>::no)
{
arma_conform_check( ( (aa.is_vec() == false) && (aa.is_empty() == false) ), "Mat::elem(): given object must be a vector" );
}
const uword* aa_mem = aa.memptr();
const uword aa_n_elem = aa.n_elem;
const unwrap_check< Mat<eT> > tmp2(in.m, out);
const Mat<eT>& m_local = tmp2.M;
const eT* m_mem = m_local.memptr();
const uword m_n_elem = m_local.n_elem;
arma_conform_check( (out.n_elem != aa_n_elem), "Mat::elem(): size mismatch" );
eT* out_mem = out.memptr();
bool ii_jj_bad = false;
uword i,j;
for(i=0, j=1; j<aa_n_elem; i+=2, j+=2)
@@ -907,25 +701,47 @@ subview_elem1<eT,T1>::mat_inplace_op(Mat<eT>& out, const subview_elem1& in)
const uword ii = aa_mem[i];
const uword jj = aa_mem[j];
arma_conform_check_bounds( ( (ii >= m_n_elem) || (jj >= m_n_elem) ), "Mat::elem(): index out of bounds" );
eT m_ii_val;
eT m_jj_val;
if(is_same_type<op_type, op_internal_plus >::yes) { out_mem[i] += m_mem[ii]; out_mem[j] += m_mem[jj]; }
if(is_same_type<op_type, op_internal_minus>::yes) { out_mem[i] -= m_mem[ii]; out_mem[j] -= m_mem[jj]; }
if(is_same_type<op_type, op_internal_schur>::yes) { out_mem[i] *= m_mem[ii]; out_mem[j] *= m_mem[jj]; }
if(is_same_type<op_type, op_internal_div >::yes) { out_mem[i] /= m_mem[ii]; out_mem[j] /= m_mem[jj]; }
if( (ii < m_n_elem) && (jj < m_n_elem) )
{
m_ii_val = m_mem[ii];
m_jj_val = m_mem[jj];
}
else
{
ii_jj_bad = true;
m_ii_val = eT(0);
m_jj_val = eT(0);
}
out_mem[i] = m_ii_val;
out_mem[j] = m_jj_val;
}
if(i < aa_n_elem)
{
const uword ii = aa_mem[i];
arma_conform_check_bounds( (ii >= m_n_elem) , "Mat::elem(): index out of bounds" );
eT m_ii_val;
if(is_same_type<op_type, op_internal_plus >::yes) { out_mem[i] += m_mem[ii]; }
if(is_same_type<op_type, op_internal_minus>::yes) { out_mem[i] -= m_mem[ii]; }
if(is_same_type<op_type, op_internal_schur>::yes) { out_mem[i] *= m_mem[ii]; }
if(is_same_type<op_type, op_internal_div >::yes) { out_mem[i] /= m_mem[ii]; }
if(ii < m_n_elem)
{
m_ii_val = m_mem[ii];
}
else
{
ii_jj_bad = true;
m_ii_val = eT(0);
}
out_mem[i] = m_ii_val;
}
arma_conform_check_bounds( ii_jj_bad, "Mat::elem(): index out of bounds" );
}
@@ -933,47 +749,22 @@ subview_elem1<eT,T1>::mat_inplace_op(Mat<eT>& out, const subview_elem1& in)
template<typename eT, typename T1>
inline
void
subview_elem1<eT,T1>::plus_inplace(Mat<eT>& out, const subview_elem1& in)
subview_elem1<eT,T1>::extract(Mat<eT>& out, const subview_elem1<eT,T1>& in)
{
arma_debug_sigprint();
mat_inplace_op<op_internal_plus>(out, in);
}
template<typename eT, typename T1>
inline
void
subview_elem1<eT,T1>::minus_inplace(Mat<eT>& out, const subview_elem1& in)
{
arma_debug_sigprint();
mat_inplace_op<op_internal_minus>(out, in);
}
template<typename eT, typename T1>
inline
void
subview_elem1<eT,T1>::schur_inplace(Mat<eT>& out, const subview_elem1& in)
{
arma_debug_sigprint();
mat_inplace_op<op_internal_schur>(out, in);
}
template<typename eT, typename T1>
inline
void
subview_elem1<eT,T1>::div_inplace(Mat<eT>& out, const subview_elem1& in)
{
arma_debug_sigprint();
mat_inplace_op<op_internal_div>(out, in);
if(in.is_alias(out))
{
Mat<eT> tmp;
subview_elem1<eT,T1>::extract_noalias(tmp, in);
out.steal_mem(tmp);
}
else
{
subview_elem1<eT,T1>::extract_noalias(out, in);
}
}
+10 -22
View File
@@ -33,10 +33,12 @@ class subview_elem2 : public Base< eT, subview_elem2<eT,T1,T2> >
static constexpr bool is_col = false;
static constexpr bool is_xvec = false;
arma_aligned const Mat<eT>& m;
static constexpr bool has_subview = true;
arma_aligned const Base<uword,T1>& base_ri;
arma_aligned const Base<uword,T2>& base_ci;
const Mat<eT>& m;
const Base<uword,T1>& base_ri;
const Base<uword,T2>& base_ci;
const bool all_rows;
const bool all_cols;
@@ -44,7 +46,7 @@ class subview_elem2 : public Base< eT, subview_elem2<eT,T1,T2> >
protected:
arma_inline subview_elem2(const Mat<eT>& in_m, const Base<uword,T1>& in_ri, const Base<uword,T2>& in_ci, const bool in_all_rows, const bool in_all_cols);
inline subview_elem2(const Mat<eT>& in_m, const Base<uword,T1>& in_ri, const Base<uword,T2>& in_ci, const bool in_all_rows, const bool in_all_cols);
public:
@@ -52,11 +54,8 @@ class subview_elem2 : public Base< eT, subview_elem2<eT,T1,T2> >
inline ~subview_elem2();
inline subview_elem2() = delete;
template<typename op_type>
inline void inplace_op(const eT val);
template<typename op_type, typename expr>
inline void inplace_op(const Base<eT,expr>& x);
template<typename op_type> inline void inplace_op(const eT val);
template<typename op_type, typename expr> inline void inplace_op(const Base<eT,expr>& x );
inline void replace(const eT old_val, const eT new_val);
@@ -77,14 +76,8 @@ class subview_elem2 : public Base< eT, subview_elem2<eT,T1,T2> >
// deliberately returning void
template<typename T3, typename T4> inline void operator_equ(const subview_elem2<eT,T3,T4>& x);
template<typename T3, typename T4> inline void operator= (const subview_elem2<eT,T3,T4>& x);
inline void operator= (const subview_elem2<eT,T1,T2>& x);
template<typename T3, typename T4> inline void operator+= (const subview_elem2<eT,T3,T4>& x);
template<typename T3, typename T4> inline void operator-= (const subview_elem2<eT,T3,T4>& x);
template<typename T3, typename T4> inline void operator%= (const subview_elem2<eT,T3,T4>& x);
template<typename T3, typename T4> inline void operator/= (const subview_elem2<eT,T3,T4>& x);
template<typename T3, typename T4> inline void operator= (const subview_elem2<eT,T3,T4>& x);
inline void operator= (const subview_elem2<eT,T1,T2>& x);
template<typename expr> inline void operator= (const Base<eT,expr>& x);
template<typename expr> inline void operator+= (const Base<eT,expr>& x);
@@ -102,11 +95,6 @@ class subview_elem2 : public Base< eT, subview_elem2<eT,T1,T2> >
inline static void extract(Mat<eT>& out, const subview_elem2& in);
inline static void plus_inplace(Mat<eT>& out, const subview_elem2& in);
inline static void minus_inplace(Mat<eT>& out, const subview_elem2& in);
inline static void schur_inplace(Mat<eT>& out, const subview_elem2& in);
inline static void div_inplace(Mat<eT>& out, const subview_elem2& in);
template<typename eT2>
inline bool is_alias(const Mat<eT2>& X) const;
+38 -265
View File
@@ -29,7 +29,7 @@ subview_elem2<eT,T1,T2>::~subview_elem2()
template<typename eT, typename T1, typename T2>
arma_inline
inline
subview_elem2<eT,T1,T2>::subview_elem2
(
const Mat<eT>& in_m,
@@ -64,11 +64,11 @@ subview_elem2<eT,T1,T2>::inplace_op(const eT val)
if( (all_rows == false) && (all_cols == false) )
{
const unwrap_check_mixed<T1> tmp1(base_ri.get_ref(), m_local);
const unwrap_check_mixed<T2> tmp2(base_ci.get_ref(), m_local);
const unwrap_check_mixed<T1> U1(base_ri.get_ref(), m_local);
const unwrap_check_mixed<T2> U2(base_ci.get_ref(), m_local);
const umat& ri = tmp1.M;
const umat& ci = tmp2.M;
const umat& ri = U1.M;
const umat& ci = U2.M;
arma_conform_check
(
@@ -105,9 +105,9 @@ subview_elem2<eT,T1,T2>::inplace_op(const eT val)
else
if( (all_rows == true) && (all_cols == false) )
{
const unwrap_check_mixed<T2> tmp2(base_ci.get_ref(), m_local);
const unwrap_check_mixed<T2> U2(base_ci.get_ref(), m_local);
const umat& ci = tmp2.M;
const umat& ci = U2.M;
arma_conform_check
(
@@ -136,9 +136,9 @@ subview_elem2<eT,T1,T2>::inplace_op(const eT val)
else
if( (all_rows == false) && (all_cols == true) )
{
const unwrap_check_mixed<T1> tmp1(base_ri.get_ref(), m_local);
const unwrap_check_mixed<T1> U1(base_ri.get_ref(), m_local);
const umat& ri = tmp1.M;
const umat& ri = U1.M;
arma_conform_check
(
@@ -182,16 +182,16 @@ subview_elem2<eT,T1,T2>::inplace_op(const Base<eT,expr>& x)
const uword m_n_rows = m_local.n_rows;
const uword m_n_cols = m_local.n_cols;
const unwrap_check<expr> tmp(x.get_ref(), m_local);
const Mat<eT>& X = tmp.M;
const unwrap_check<expr> U(x.get_ref(), m_local);
const Mat<eT>& X = U.M;
if( (all_rows == false) && (all_cols == false) )
{
const unwrap_check_mixed<T1> tmp1(base_ri.get_ref(), m_local);
const unwrap_check_mixed<T2> tmp2(base_ci.get_ref(), m_local);
const unwrap_check_mixed<T1> U1(base_ri.get_ref(), m_local);
const unwrap_check_mixed<T2> U2(base_ci.get_ref(), m_local);
const umat& ri = tmp1.M;
const umat& ci = tmp2.M;
const umat& ri = U1.M;
const umat& ci = U2.M;
arma_conform_check
(
@@ -230,9 +230,9 @@ subview_elem2<eT,T1,T2>::inplace_op(const Base<eT,expr>& x)
else
if( (all_rows == true) && (all_cols == false) )
{
const unwrap_check_mixed<T2> tmp2(base_ci.get_ref(), m_local);
const unwrap_check_mixed<T2> U2(base_ci.get_ref(), m_local);
const umat& ci = tmp2.M;
const umat& ci = U2.M;
arma_conform_check
(
@@ -264,9 +264,9 @@ subview_elem2<eT,T1,T2>::inplace_op(const Base<eT,expr>& x)
else
if( (all_rows == false) && (all_cols == true) )
{
const unwrap_check_mixed<T1> tmp1(base_ri.get_ref(), m_local);
const unwrap_check_mixed<T1> U1(base_ri.get_ref(), m_local);
const umat& ri = tmp1.M;
const umat& ri = U1.M;
arma_conform_check
(
@@ -675,20 +675,6 @@ subview_elem2<eT,T1,T2>::operator/= (const eT val)
template<typename eT, typename T1, typename T2>
template<typename T3, typename T4>
inline
void
subview_elem2<eT,T1,T2>::operator_equ(const subview_elem2<eT,T3,T4>& x)
{
arma_debug_sigprint();
inplace_op<op_internal_equ>(x);
}
template<typename eT, typename T1, typename T2>
template<typename T3, typename T4>
inline
@@ -697,12 +683,13 @@ subview_elem2<eT,T1,T2>::operator= (const subview_elem2<eT,T3,T4>& x)
{
arma_debug_sigprint();
(*this).operator_equ(x);
const Mat<eT> tmp(x);
inplace_op<op_internal_equ>(tmp);
}
//! work around compiler bugs
template<typename eT, typename T1, typename T2>
inline
void
@@ -710,59 +697,9 @@ subview_elem2<eT,T1,T2>::operator= (const subview_elem2<eT,T1,T2>& x)
{
arma_debug_sigprint();
(*this).operator_equ(x);
}
template<typename eT, typename T1, typename T2>
template<typename T3, typename T4>
inline
void
subview_elem2<eT,T1,T2>::operator+= (const subview_elem2<eT,T3,T4>& x)
{
arma_debug_sigprint();
const Mat<eT> tmp(x);
inplace_op<op_internal_plus>(x);
}
template<typename eT, typename T1, typename T2>
template<typename T3, typename T4>
inline
void
subview_elem2<eT,T1,T2>::operator-= (const subview_elem2<eT,T3,T4>& x)
{
arma_debug_sigprint();
inplace_op<op_internal_minus>(x);
}
template<typename eT, typename T1, typename T2>
template<typename T3, typename T4>
inline
void
subview_elem2<eT,T1,T2>::operator%= (const subview_elem2<eT,T3,T4>& x)
{
arma_debug_sigprint();
inplace_op<op_internal_schur>(x);
}
template<typename eT, typename T1, typename T2>
template<typename T3, typename T4>
inline
void
subview_elem2<eT,T1,T2>::operator/= (const subview_elem2<eT,T3,T4>& x)
{
arma_debug_sigprint();
inplace_op<op_internal_div>(x);
inplace_op<op_internal_equ>(tmp);
}
@@ -931,11 +868,11 @@ subview_elem2<eT,T1,T2>::extract_noalias(Mat<eT>& out, const subview_elem2<eT,T1
if( (in.all_rows == false) && (in.all_cols == false) )
{
const quasi_unwrap<T1> tmp1(in.base_ri.get_ref());
const quasi_unwrap<T2> tmp2(in.base_ci.get_ref());
const quasi_unwrap<T1> U1(in.base_ri.get_ref());
const quasi_unwrap<T2> U2(in.base_ci.get_ref());
const umat& ri = tmp1.M;
const umat& ci = tmp2.M;
const umat& ri = U1.M;
const umat& ci = U2.M;
arma_conform_check
(
@@ -974,9 +911,9 @@ subview_elem2<eT,T1,T2>::extract_noalias(Mat<eT>& out, const subview_elem2<eT,T1
else
if( (in.all_rows == true) && (in.all_cols == false) )
{
const quasi_unwrap<T2> tmp2(in.base_ci.get_ref());
const quasi_unwrap<T2> U2(in.base_ci.get_ref());
const umat& ci = tmp2.M;
const umat& ci = U2.M;
arma_conform_check
(
@@ -1001,9 +938,9 @@ subview_elem2<eT,T1,T2>::extract_noalias(Mat<eT>& out, const subview_elem2<eT,T1
else
if( (in.all_rows == false) && (in.all_cols == true) )
{
const quasi_unwrap<T1> tmp1(in.base_ri.get_ref());
const quasi_unwrap<T1> U1(in.base_ri.get_ref());
const umat& ri = tmp1.M;
const umat& ri = U1.M;
arma_conform_check
(
@@ -1035,186 +972,22 @@ subview_elem2<eT,T1,T2>::extract_noalias(Mat<eT>& out, const subview_elem2<eT,T1
template<typename eT, typename T1, typename T2>
inline
void
subview_elem2<eT,T1,T2>::extract(Mat<eT>& actual_out, const subview_elem2<eT,T1,T2>& in)
subview_elem2<eT,T1,T2>::extract(Mat<eT>& out, const subview_elem2<eT,T1,T2>& in)
{
arma_debug_sigprint();
const Mat<eT>& m = in.m;
const uword m_n_rows = m.n_rows;
const uword m_n_cols = m.n_cols;
const bool alias = (&actual_out == &m);
if(alias) { arma_debug_print("subview_elem2::extract(): aliasing detected"); }
Mat<eT>* tmp_out = alias ? new Mat<eT>() : nullptr;
Mat<eT>& out = alias ? *tmp_out : actual_out;
if( (in.all_rows == false) && (in.all_cols == false) )
if(in.is_alias(out))
{
const unwrap_check_mixed<T1> tmp1(in.base_ri.get_ref(), actual_out);
const unwrap_check_mixed<T2> tmp2(in.base_ci.get_ref(), actual_out);
Mat<eT> tmp;
const umat& ri = tmp1.M;
const umat& ci = tmp2.M;
subview_elem2<eT,T1,T2>::extract_noalias(tmp, in);
arma_conform_check
(
( ((ri.is_vec() == false) && (ri.is_empty() == false)) || ((ci.is_vec() == false) && (ci.is_empty() == false)) ),
"Mat::elem(): given object must be a vector"
);
const uword* ri_mem = ri.memptr();
const uword ri_n_elem = ri.n_elem;
const uword* ci_mem = ci.memptr();
const uword ci_n_elem = ci.n_elem;
out.set_size(ri_n_elem, ci_n_elem);
eT* out_mem = out.memptr();
uword out_count = 0;
for(uword ci_count=0; ci_count < ci_n_elem; ++ci_count)
{
const uword col = ci_mem[ci_count];
arma_conform_check_bounds( (col >= m_n_cols), "Mat::elem(): index out of bounds" );
for(uword ri_count=0; ri_count < ri_n_elem; ++ri_count)
{
const uword row = ri_mem[ri_count];
arma_conform_check_bounds( (row >= m_n_rows), "Mat::elem(): index out of bounds" );
out_mem[out_count] = m.at(row,col);
++out_count;
}
}
out.steal_mem(tmp);
}
else
if( (in.all_rows == true) && (in.all_cols == false) )
{
const unwrap_check_mixed<T2> tmp2(in.base_ci.get_ref(), m);
const umat& ci = tmp2.M;
arma_conform_check
(
( (ci.is_vec() == false) && (ci.is_empty() == false) ),
"Mat::elem(): given object must be a vector"
);
const uword* ci_mem = ci.memptr();
const uword ci_n_elem = ci.n_elem;
out.set_size(m_n_rows, ci_n_elem);
for(uword ci_count=0; ci_count < ci_n_elem; ++ci_count)
{
const uword col = ci_mem[ci_count];
arma_conform_check_bounds( (col >= m_n_cols), "Mat::elem(): index out of bounds" );
arrayops::copy( out.colptr(ci_count), m.colptr(col), m_n_rows );
}
subview_elem2<eT,T1,T2>::extract_noalias(out, in);
}
else
if( (in.all_rows == false) && (in.all_cols == true) )
{
const unwrap_check_mixed<T1> tmp1(in.base_ri.get_ref(), m);
const umat& ri = tmp1.M;
arma_conform_check
(
( (ri.is_vec() == false) && (ri.is_empty() == false) ),
"Mat::elem(): given object must be a vector"
);
const uword* ri_mem = ri.memptr();
const uword ri_n_elem = ri.n_elem;
out.set_size(ri_n_elem, m_n_cols);
for(uword col=0; col < m_n_cols; ++col)
{
for(uword ri_count=0; ri_count < ri_n_elem; ++ri_count)
{
const uword row = ri_mem[ri_count];
arma_conform_check_bounds( (row >= m_n_rows), "Mat::elem(): index out of bounds" );
out.at(ri_count,col) = m.at(row,col);
}
}
}
if(alias)
{
actual_out.steal_mem(out);
delete tmp_out;
}
}
// TODO: implement a dedicated function instead of creating a temporary (but lots of potential aliasing issues)
template<typename eT, typename T1, typename T2>
inline
void
subview_elem2<eT,T1,T2>::plus_inplace(Mat<eT>& out, const subview_elem2& in)
{
arma_debug_sigprint();
const Mat<eT> tmp(in);
out += tmp;
}
template<typename eT, typename T1, typename T2>
inline
void
subview_elem2<eT,T1,T2>::minus_inplace(Mat<eT>& out, const subview_elem2& in)
{
arma_debug_sigprint();
const Mat<eT> tmp(in);
out -= tmp;
}
template<typename eT, typename T1, typename T2>
inline
void
subview_elem2<eT,T1,T2>::schur_inplace(Mat<eT>& out, const subview_elem2& in)
{
arma_debug_sigprint();
const Mat<eT> tmp(in);
out %= tmp;
}
template<typename eT, typename T1, typename T2>
inline
void
subview_elem2<eT,T1,T2>::div_inplace(Mat<eT>& out, const subview_elem2& in)
{
arma_debug_sigprint();
const Mat<eT> tmp(in);
out /= tmp;
}
+2 -2
View File
@@ -3449,7 +3449,7 @@ subview_col<eT>::operator=(const Base<eT,T1>& expr)
if(is_Mat<T1>::value)
{
const unwrap<T1> U(expr.get_ref()); // deliberately not using quasi_unwrap
const plain_unwrap<T1> U(expr.get_ref()); // deliberately not using quasi_unwrap
arma_conform_assert_same_size(subview<eT>::n_rows, uword(1), U.M.n_rows, U.M.n_cols, "copy into submatrix");
@@ -4511,7 +4511,7 @@ subview_row<eT>::operator=(const Base<eT,T1>& X)
if(is_Mat<T1>::value)
{
const unwrap<T1> U(X.get_ref()); // deliberately not using quasi_unwrap
const plain_unwrap<T1> U(X.get_ref()); // deliberately not using quasi_unwrap
arma_conform_assert_same_size(uword(1), subview<eT>::n_cols, U.M.n_rows, U.M.n_cols, "copy into submatrix");
+65 -28
View File
@@ -21,17 +21,17 @@
// TODO: document the conditions and restrictions for the use of each unwrap variant:
// TODO: unwrap, unwrap_check, quasi_unwrap, partial_unwrap
// TODO: plain_unwrap, quasi_unwrap, unwrap_check, partial_unwrap, ...
template<typename T1>
struct unwrap_default
struct plain_unwrap_default
{
typedef typename T1::elem_type eT;
typedef Mat<eT> stored_type;
inline
unwrap_default(const T1& A)
plain_unwrap_default(const T1& A)
: M(A)
{
arma_debug_sigprint();
@@ -46,12 +46,13 @@ struct unwrap_default
template<typename T1>
struct unwrap_fixed
struct plain_unwrap_fixed
{
typedef T1 stored_type;
typedef typename T1::elem_type eT;
typedef T1 stored_type;
inline explicit
unwrap_fixed(const T1& A)
plain_unwrap_fixed(const T1& A)
: M(A)
{
arma_debug_sigprint();
@@ -60,27 +61,27 @@ struct unwrap_fixed
const T1& M;
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); }
arma_inline bool is_alias(const Mat<eT2>& X) const { return (is_same_type<eT,eT2>::yes) && (void_ptr(&M) == void_ptr(&X)); }
};
template<typename T1, bool condition>
struct unwrap_redirect {};
struct plain_unwrap_redirect {};
template<typename T1>
struct unwrap_redirect<T1, false> { typedef unwrap_default<T1> result; };
struct plain_unwrap_redirect<T1, false> { typedef plain_unwrap_default<T1> result; };
template<typename T1>
struct unwrap_redirect<T1, true> { typedef unwrap_fixed<T1> result; };
struct plain_unwrap_redirect<T1, true> { typedef plain_unwrap_fixed<T1> result; };
template<typename T1>
struct unwrap : public unwrap_redirect<T1, is_Mat_fixed<T1>::value>::result
struct plain_unwrap : public plain_unwrap_redirect<T1, is_Mat_fixed<T1>::value>::result
{
inline
unwrap(const T1& A)
: unwrap_redirect<T1, is_Mat_fixed<T1>::value>::result(A)
plain_unwrap(const T1& A)
: plain_unwrap_redirect<T1, is_Mat_fixed<T1>::value>::result(A)
{
}
};
@@ -88,12 +89,12 @@ struct unwrap : public unwrap_redirect<T1, is_Mat_fixed<T1>::value>::result
template<typename eT>
struct unwrap< Mat<eT> >
struct plain_unwrap< Mat<eT> >
{
typedef Mat<eT> stored_type;
inline
unwrap(const Mat<eT>& A)
plain_unwrap(const Mat<eT>& A)
: M(A)
{
arma_debug_sigprint();
@@ -108,12 +109,12 @@ struct unwrap< Mat<eT> >
template<typename eT>
struct unwrap< Row<eT> >
struct plain_unwrap< Row<eT> >
{
typedef Row<eT> stored_type;
inline
unwrap(const Row<eT>& A)
plain_unwrap(const Row<eT>& A)
: M(A)
{
arma_debug_sigprint();
@@ -128,12 +129,12 @@ struct unwrap< Row<eT> >
template<typename eT>
struct unwrap< Col<eT> >
struct plain_unwrap< Col<eT> >
{
typedef Col<eT> stored_type;
inline
unwrap(const Col<eT>& A)
plain_unwrap(const Col<eT>& A)
: M(A)
{
arma_debug_sigprint();
@@ -148,12 +149,12 @@ struct unwrap< Col<eT> >
template<typename eT>
struct unwrap< subview_col<eT> >
struct plain_unwrap< subview_col<eT> >
{
typedef Col<eT> stored_type;
inline
unwrap(const subview_col<eT>& A)
plain_unwrap(const subview_col<eT>& A)
: M(A.colmem, A.n_rows)
{
arma_debug_sigprint();
@@ -168,12 +169,12 @@ struct unwrap< subview_col<eT> >
template<typename eT>
struct unwrap< subview_cols<eT> >
struct plain_unwrap< subview_cols<eT> >
{
typedef Mat<eT> stored_type;
inline
unwrap(const subview_cols<eT>& A)
plain_unwrap(const subview_cols<eT>& A)
: M(A.colptr(0), A.n_rows, A.n_cols)
{
arma_debug_sigprint();
@@ -188,12 +189,12 @@ struct unwrap< subview_cols<eT> >
template<typename out_eT, typename T1, typename T2, typename glue_type>
struct unwrap< mtGlue<out_eT, T1, T2, glue_type> >
struct plain_unwrap< mtGlue<out_eT, T1, T2, glue_type> >
{
typedef Mat<out_eT> stored_type;
inline
unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A)
plain_unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A)
: M(A)
{
arma_debug_sigprint();
@@ -208,12 +209,12 @@ struct unwrap< mtGlue<out_eT, T1, T2, glue_type> >
template<typename out_eT, typename T1, typename op_type>
struct unwrap< mtOp<out_eT, T1, op_type> >
struct plain_unwrap< mtOp<out_eT, T1, op_type> >
{
typedef Mat<out_eT> stored_type;
inline
unwrap(const mtOp<out_eT, T1, op_type>& A)
plain_unwrap(const mtOp<out_eT, T1, op_type>& A)
: M(A)
{
arma_debug_sigprint();
@@ -237,6 +238,7 @@ template<typename T1>
struct quasi_unwrap_default
{
typedef typename T1::elem_type eT;
typedef Mat<eT> stored_type;
inline
quasi_unwrap_default(const T1& A)
@@ -262,6 +264,7 @@ template<typename T1>
struct quasi_unwrap_fixed
{
typedef typename T1::elem_type eT;
typedef T1 stored_type;
inline explicit
quasi_unwrap_fixed(const T1& A)
@@ -277,7 +280,7 @@ struct quasi_unwrap_fixed
static constexpr bool has_orig_mem = true;
template<typename eT2>
arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); }
arma_inline bool is_alias(const Mat<eT2>& X) const { return (is_same_type<eT,eT2>::yes) && (void_ptr(&M) == void_ptr(&X)); }
};
@@ -316,6 +319,8 @@ struct quasi_unwrap : public quasi_unwrap_redirect<T1, is_Mat_fixed<T1>::value>:
template<typename eT>
struct quasi_unwrap< Mat<eT> >
{
typedef Mat<eT> stored_type;
inline
quasi_unwrap(const Mat<eT>& A)
: M(A)
@@ -338,6 +343,8 @@ struct quasi_unwrap< Mat<eT> >
template<typename eT>
struct quasi_unwrap< Row<eT> >
{
typedef Row<eT> stored_type;
inline
quasi_unwrap(const Row<eT>& A)
: M(A)
@@ -360,6 +367,8 @@ struct quasi_unwrap< Row<eT> >
template<typename eT>
struct quasi_unwrap< Col<eT> >
{
typedef Col<eT> stored_type;
inline
quasi_unwrap(const Col<eT>& A)
: M(A)
@@ -382,6 +391,8 @@ struct quasi_unwrap< Col<eT> >
template<typename eT>
struct quasi_unwrap< subview<eT> >
{
typedef Mat<eT> stored_type;
inline
quasi_unwrap(const subview<eT>& A)
: sv( A )
@@ -406,6 +417,8 @@ struct quasi_unwrap< subview<eT> >
template<typename eT>
struct quasi_unwrap< subview_row<eT> >
{
typedef Row<eT> stored_type;
inline
quasi_unwrap(const subview_row<eT>& A)
: sv( A )
@@ -430,6 +443,8 @@ struct quasi_unwrap< subview_row<eT> >
template<typename eT>
struct quasi_unwrap< subview_col<eT> >
{
typedef Col<eT> stored_type;
inline
quasi_unwrap(const subview_col<eT>& A)
: orig( A.m )
@@ -454,6 +469,8 @@ struct quasi_unwrap< subview_col<eT> >
template<typename eT>
struct quasi_unwrap< subview_cols<eT> >
{
typedef Mat<eT> stored_type;
inline
quasi_unwrap(const subview_cols<eT>& A)
: orig( A.m )
@@ -478,6 +495,8 @@ struct quasi_unwrap< subview_cols<eT> >
template<typename out_eT, typename T1, typename T2, typename glue_type>
struct quasi_unwrap< mtGlue<out_eT, T1, T2, glue_type> >
{
typedef Mat<out_eT> stored_type;
inline
quasi_unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A)
: M(A)
@@ -500,6 +519,8 @@ struct quasi_unwrap< mtGlue<out_eT, T1, T2, glue_type> >
template<typename out_eT, typename T1, typename op_type>
struct quasi_unwrap< mtOp<out_eT, T1, op_type> >
{
typedef Mat<out_eT> stored_type;
inline
quasi_unwrap(const mtOp<out_eT, T1, op_type>& A)
: M(A)
@@ -523,6 +544,7 @@ template<typename T1>
struct quasi_unwrap< Op<T1, op_vectorise_col> >
{
typedef typename T1::elem_type eT;
typedef Mat<eT> stored_type;
inline
quasi_unwrap(const Op<T1, op_vectorise_col>& A)
@@ -548,6 +570,8 @@ struct quasi_unwrap< Op<T1, op_vectorise_col> >
template<typename eT>
struct quasi_unwrap< Op<Col<eT>, op_strans> >
{
typedef Row<eT> stored_type;
inline
quasi_unwrap(const Op<Col<eT>, op_strans>& A)
: orig(A.m)
@@ -572,6 +596,8 @@ struct quasi_unwrap< Op<Col<eT>, op_strans> >
template<typename eT>
struct quasi_unwrap< Op<Row<eT>, op_strans> >
{
typedef Col<eT> stored_type;
inline
quasi_unwrap(const Op<Row<eT>, op_strans>& A)
: orig(A.m)
@@ -596,6 +622,8 @@ struct quasi_unwrap< Op<Row<eT>, op_strans> >
template<typename eT>
struct quasi_unwrap< Op<subview_col<eT>, op_strans> >
{
typedef Row<eT> stored_type;
inline
quasi_unwrap(const Op<subview_col<eT>, op_strans>& A)
: orig( A.m.m )
@@ -628,6 +656,8 @@ struct quasi_unwrap_Col_htrans
template<typename eT>
struct quasi_unwrap_Col_htrans< Op<Col<eT>, op_htrans> >
{
typedef Row<eT> stored_type;
inline
quasi_unwrap_Col_htrans(const Op<Col<eT>, op_htrans>& A)
: orig(A.m)
@@ -692,6 +722,8 @@ struct quasi_unwrap_Row_htrans
template<typename eT>
struct quasi_unwrap_Row_htrans< Op<Row<eT>, op_htrans> >
{
typedef Col<eT> stored_type;
inline
quasi_unwrap_Row_htrans(const Op<Row<eT>, op_htrans>& A)
: orig(A.m)
@@ -756,6 +788,8 @@ struct quasi_unwrap_subview_col_htrans
template<typename eT>
struct quasi_unwrap_subview_col_htrans< Op<subview_col<eT>, op_htrans> >
{
typedef Row<eT> stored_type;
inline
quasi_unwrap_subview_col_htrans(const Op<subview_col<eT>, op_htrans>& A)
: orig(A.m.m)
@@ -813,6 +847,7 @@ template<typename T1>
struct quasi_unwrap< CubeToMatOp<T1, op_vectorise_cube_col> >
{
typedef typename T1::elem_type eT;
typedef Mat<eT> stored_type;
inline
quasi_unwrap(const CubeToMatOp<T1, op_vectorise_cube_col>& A)
@@ -838,6 +873,8 @@ struct quasi_unwrap< CubeToMatOp<T1, op_vectorise_cube_col> >
template<typename eT>
struct quasi_unwrap< SpToDOp<SpMat<eT>, op_sp_nonzeros> >
{
typedef Mat<eT> stored_type;
inline
quasi_unwrap(const SpToDOp<SpMat<eT>, op_sp_nonzeros>& A)
: orig( A.m )