Skip to content

Commit 8feb411

Browse files
committed
Armadillo 12.8.4-rc1
1 parent de8f97b commit 8feb411

File tree

4 files changed

+42
-14
lines changed

4 files changed

+42
-14
lines changed

inst/include/armadillo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#ifndef ARMA_INCLUDES
2020
#define ARMA_INCLUDES
2121

22-
// NOTE: functions that are designed to be user accessible are described in the documentation (docs.html).
23-
// NOTE: all other functions and classes (ie. not explicitly described in the documentation)
24-
// NOTE: are considered as internal implementation details, and may be changed or removed without notice.
22+
// WARNING: the documentation (docs.html) describes the public API (functions, classes, constants);
23+
// WARNING: any functionality which is _not explicitly_ described in the documentation
24+
// WARNING: is considered as internal implementation detail, and may be changed or removed without notice.
2525

2626
#include "armadillo_bits/config.hpp"
2727
#include "armadillo_bits/compiler_check.hpp"

inst/include/armadillo_bits/SpSubview_meat.hpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,28 @@ SpSubview<eT>::SpSubview(const SpMat<eT>& in_m, const uword in_row1, const uword
4444

4545
m.sync_csc();
4646

47-
// There must be a O(1) way to do this
48-
uword lend = m.col_ptrs[in_col1 + in_n_cols];
49-
uword lend_row = in_row1 + in_n_rows;
50-
uword count = 0;
47+
// count the number of non-zeros in the subview
48+
uword count = 0;
5149

52-
for(uword i = m.col_ptrs[in_col1]; i < lend; ++i)
50+
if(n_rows == m.n_rows)
5351
{
54-
const uword m_row_indices_i = m.row_indices[i];
52+
count = m.col_ptrs[aux_col1 + n_cols] - m.col_ptrs[aux_col1];
53+
}
54+
else
55+
{
56+
arma_extra_debug_print("counting non-zeros in sparse subview");
5557

56-
const bool condition = (m_row_indices_i >= in_row1) && (m_row_indices_i < lend_row);
58+
uword lend = m.col_ptrs[in_col1 + in_n_cols];
59+
uword lend_row = in_row1 + in_n_rows;
5760

58-
count += condition ? uword(1) : uword(0);
61+
for(uword i = m.col_ptrs[in_col1]; i < lend; ++i)
62+
{
63+
const uword m_row_indices_i = m.row_indices[i];
64+
65+
const bool condition = (m_row_indices_i >= in_row1) && (m_row_indices_i < lend_row);
66+
67+
count += condition ? uword(1) : uword(0);
68+
}
5969
}
6070

6171
access::rw(n_nonzero) = count;

inst/include/armadillo_bits/fn_conv_to.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class conv_to
3030

3131
template<typename in_eT, typename T1>
3232
inline static out_eT from(const Base<in_eT, T1>& in, const typename arma_not_cx<in_eT>::result* junk = nullptr);
33-
33+
3434
template<typename in_eT, typename T1>
3535
inline static out_eT from(const Base<in_eT, T1>& in, const typename arma_cx_only<in_eT>::result* junk = nullptr);
3636

inst/include/armadillo_bits/fn_dot.hpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,31 @@ dot
289289
{
290290
arma_extra_debug_sigprint();
291291

292+
typedef typename T1::elem_type eT;
293+
294+
if(is_SpSubview_col<T2>::value)
295+
{
296+
// TODO: refactor to use C++17 "if constexpr" to avoid reinterpret_cast shenanigans
297+
298+
const SpSubview_col<eT>& yy = reinterpret_cast< const SpSubview_col<eT>& >(y);
299+
300+
if(yy.n_rows == yy.m.n_rows)
301+
{
302+
arma_extra_debug_print("using sparse column vector specialisation");
303+
304+
const quasi_unwrap<T1> U(x);
305+
306+
arma_debug_assert_same_size(U.M.n_elem, uword(1), yy.n_elem, uword(1), "dot()");
307+
308+
return dense_sparse_helper::dot(U.M.memptr(), yy.m, yy.aux_col1);
309+
}
310+
}
311+
292312
const Proxy<T1> pa(x);
293313
const SpProxy<T2> pb(y);
294314

295315
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_rows(), pb.get_n_cols(), "dot()");
296316

297-
typedef typename T1::elem_type eT;
298-
299317
eT result = eT(0);
300318

301319
typename SpProxy<T2>::const_iterator_type it = pb.begin();

0 commit comments

Comments
 (0)