Skip to content

Commit 0d7537e

Browse files
committed
RcppArmadillo 14.3.92-1 with RC-2 of Armadillo 14.4
1 parent 1dde933 commit 0d7537e

File tree

9 files changed

+122
-55
lines changed

9 files changed

+122
-55
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2025-02-15 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/armadillo_bits/: Sync again with updated sources for
4+
Armadillo 14.3.92 as an RC for 14.4.*
5+
16
2025-02-13 Dirk Eddelbuettel <[email protected]>
27

38
* inst/include/armadillo_bits/: Sync again with updated sources for

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: RcppArmadillo
22
Type: Package
33
Title: 'Rcpp' Integration for the 'Armadillo' Templated Linear Algebra Library
4-
Version: 14.3.91-1
5-
Date: 2025-02-13
4+
Version: 14.3.92-1
5+
Date: 2025-02-15
66
Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "[email protected]",
77
comment = c(ORCID = "0000-0001-6419-907X")),
88
person("Romain", "Francois", role = "aut",

inst/include/armadillo_bits/arma_forward.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class spop_strans;
130130
class spop_htrans;
131131
class spop_vectorise_row;
132132
class spop_vectorise_col;
133+
class spop_square;
133134

134135
class spop_rel_lt_pre;
135136
class spop_rel_lt_post;

inst/include/armadillo_bits/arma_version.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
#define ARMA_VERSION_MAJOR 14
2525
#define ARMA_VERSION_MINOR 3
26-
#define ARMA_VERSION_PATCH 91
27-
#define ARMA_VERSION_NAME "14.4-RC1"
26+
#define ARMA_VERSION_PATCH 92
27+
#define ARMA_VERSION_NAME "14.4-RC2"
2828

2929

3030

inst/include/armadillo_bits/fn_accu.hpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,22 @@ accu(const SpGlue<T1,T2,spglue_schur>& expr)
11191119
const SpProxy<T1> px(expr.A);
11201120
const SpProxy<T2> py(expr.B);
11211121

1122+
arma_conform_assert_same_size(px.get_n_rows(), px.get_n_cols(), py.get_n_rows(), py.get_n_cols(), "element-wise multiplication");
1123+
1124+
typedef typename SpProxy<T1>::stored_type px_Q_type;
1125+
typedef typename SpProxy<T2>::stored_type py_Q_type;
1126+
1127+
if(is_SpMat<px_Q_type>::value && is_SpMat<py_Q_type>::value)
1128+
{
1129+
const unwrap_spmat<px_Q_type> UX(px.Q);
1130+
const unwrap_spmat<py_Q_type> UY(py.Q);
1131+
1132+
const SpMat<eT>& X = UX.M;
1133+
const SpMat<eT>& Y = UY.M;
1134+
1135+
if(&X == &Y) { return op_dot::direct_dot(X.n_nonzero, X.values, X.values); }
1136+
}
1137+
11221138
typename SpProxy<T1>::const_iterator_type x_it = px.begin();
11231139
typename SpProxy<T1>::const_iterator_type x_it_end = px.end();
11241140

@@ -1195,7 +1211,7 @@ accu(const SpOp<T1, spop_type>& expr)
11951211

11961212
eT val = eT(0);
11971213

1198-
for(uword i=0; i < N; ++i) { const eT tmp = (*it); ++it; val += tmp*tmp; }
1214+
for(uword i=0; i < N; ++i) { const eT tmp = (*it); val += (tmp*tmp); ++it; }
11991215

12001216
return val;
12011217
}

inst/include/armadillo_bits/fn_dot.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ dot
256256
if( &A == &B )
257257
{
258258
// We can do it directly!
259-
return op_dot::direct_dot_arma(A.n_nonzero, A.values, A.values);
259+
return op_dot::direct_dot(A.n_nonzero, A.values, A.values);
260260
}
261261
else
262262
{

inst/include/armadillo_bits/fn_elem.hpp

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -603,20 +603,6 @@ sqrt(const T1& A)
603603

604604

605605

606-
// workaround for old user code
607-
template<typename eT>
608-
arma_frown("use std::sqrt(arma::as_scalar(X)) instead")
609-
inline
610-
typename arma_scalar_only<eT>::result
611-
sqrt(const eT& A)
612-
{
613-
arma_debug_sigprint();
614-
615-
return eop_aux::sqrt(A);
616-
}
617-
618-
619-
620606
template<typename T1>
621607
arma_warn_unused
622608
arma_inline
@@ -781,17 +767,17 @@ pow(const T1& A, const typename T1::elem_type exponent)
781767

782768

783769

784-
// workaround for old user code
785-
template<typename eT>
786-
arma_frown("use std::pow(arma::as_scalar(X),Y) instead")
787-
inline
788-
typename arma_scalar_only<eT>::result
789-
pow(const eT& A, const eT exponent)
790-
{
791-
arma_debug_sigprint();
792-
793-
return eop_aux::pow(A, exponent);
794-
}
770+
// // workaround for old user code
771+
// template<typename eT>
772+
// arma_frown("use std::pow(arma::as_scalar(X),Y) instead")
773+
// inline
774+
// typename arma_scalar_only<eT>::result
775+
// pow(const eT& A, const eT exponent)
776+
// {
777+
// arma_debug_sigprint();
778+
//
779+
// return eop_aux::pow(A, exponent);
780+
// }
795781

796782

797783

@@ -825,17 +811,17 @@ pow(const T1& A, const typename T1::elem_type::value_type exponent)
825811

826812

827813

828-
// workaround for old user code
829-
template<typename eT>
830-
arma_frown("use std::pow(arma::as_scalar(X),Y) instead")
831-
inline
832-
typename enable_if2< is_cx<eT>::yes, eT >::result
833-
pow(const eT& A, const typename eT::value_type exponent)
834-
{
835-
arma_debug_sigprint();
836-
837-
return eop_aux::pow(A, eT(exponent));
838-
}
814+
// // workaround for old user code
815+
// template<typename eT>
816+
// arma_frown("use std::pow(arma::as_scalar(X),Y) instead")
817+
// inline
818+
// typename enable_if2< is_cx<eT>::yes, eT >::result
819+
// pow(const eT& A, const typename eT::value_type exponent)
820+
// {
821+
// arma_debug_sigprint();
822+
//
823+
// return eop_aux::pow(A, eT(exponent));
824+
// }
839825

840826

841827

inst/include/armadillo_bits/op_sp_sum_bones.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class op_sp_sum
2727

2828
template<typename T1>
2929
inline static void apply(Mat<typename T1::elem_type>& out, const mtSpReduceOp<typename T1::elem_type, T1, op_sp_sum>& in);
30+
31+
template<typename T1>
32+
inline static void apply(Mat<typename T1::elem_type>& out, const mtSpReduceOp<typename T1::elem_type, SpOp<T1, spop_square>, op_sp_sum>& in);
3033
};
3134

3235

inst/include/armadillo_bits/op_sp_sum_meat.hpp

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,19 @@ op_sp_sum::apply(Mat<typename T1::elem_type>& out, const mtSpReduceOp<typename T
5454

5555
const uword N = p.get_n_nonzero();
5656

57-
for(uword i=0; i < N; ++i)
58-
{
59-
out_mem[it.col()] += (*it);
60-
++it;
61-
}
57+
for(uword i=0; i < N; ++i) { out_mem[it.col()] += (*it); ++it; }
6258
}
6359
else
6460
{
61+
const eT* values = p.get_values();
62+
const uword* colptrs = p.get_col_ptrs();
63+
6564
for(uword col = 0; col < p_n_cols; ++col)
6665
{
67-
out_mem[col] = arrayops::accumulate
68-
(
69-
&p.get_values()[p.get_col_ptrs()[col]],
70-
p.get_col_ptrs()[col + 1] - p.get_col_ptrs()[col]
71-
);
66+
const eT* coldata = &(values[ colptrs[col] ]);
67+
const uword N = colptrs[col + 1] - colptrs[col];
68+
69+
out_mem[col] = arrayops::accumulate(coldata, N);
7270
}
7371
}
7472
}
@@ -79,11 +77,69 @@ op_sp_sum::apply(Mat<typename T1::elem_type>& out, const mtSpReduceOp<typename T
7977

8078
const uword N = p.get_n_nonzero();
8179

82-
for(uword i=0; i < N; ++i)
80+
for(uword i=0; i < N; ++i) { out_mem[it.row()] += (*it); ++it; }
81+
}
82+
}
83+
84+
85+
86+
template<typename T1>
87+
inline
88+
void
89+
op_sp_sum::apply(Mat<typename T1::elem_type>& out, const mtSpReduceOp<typename T1::elem_type, SpOp<T1, spop_square>, op_sp_sum>& in)
90+
{
91+
arma_debug_sigprint();
92+
93+
typedef typename T1::elem_type eT;
94+
95+
const uword dim = in.aux_uword_a;
96+
97+
arma_conform_check( (dim > 1), "sum(): parameter 'dim' must be 0 or 1" );
98+
99+
const SpProxy<T1> p(in.m.m);
100+
101+
const uword p_n_rows = p.get_n_rows();
102+
const uword p_n_cols = p.get_n_cols();
103+
104+
if(dim == 0) { out.zeros(1, p_n_cols); }
105+
if(dim == 1) { out.zeros(p_n_rows, 1); }
106+
107+
if(p.get_n_nonzero() == 0) { return; }
108+
109+
eT* out_mem = out.memptr();
110+
111+
if(dim == 0) // find the sum of squares in each column
112+
{
113+
if(SpProxy<T1>::use_iterator)
83114
{
84-
out_mem[it.row()] += (*it);
85-
++it;
115+
typename SpProxy<T1>::const_iterator_type it = p.begin();
116+
117+
const uword N = p.get_n_nonzero();
118+
119+
for(uword i=0; i < N; ++i) { const eT val = (*it); out_mem[it.col()] += (val*val); ++it; }
86120
}
121+
else
122+
{
123+
const eT* values = p.get_values();
124+
const uword* colptrs = p.get_col_ptrs();
125+
126+
for(uword col = 0; col < p_n_cols; ++col)
127+
{
128+
const eT* coldata = &(values[ colptrs[col] ]);
129+
const uword N = colptrs[col + 1] - colptrs[col];
130+
131+
out_mem[col] = op_dot::direct_dot(N, coldata, coldata);
132+
}
133+
}
134+
}
135+
else
136+
if(dim == 1) // find the sum of squares in each row
137+
{
138+
typename SpProxy<T1>::const_iterator_type it = p.begin();
139+
140+
const uword N = p.get_n_nonzero();
141+
142+
for(uword i=0; i < N; ++i) { const eT val = (*it); out_mem[it.row()] += (val*val); ++it; }
87143
}
88144
}
89145

0 commit comments

Comments
 (0)