Skip to content

Commit e91873f

Browse files
committed
Armadillo 15.4.2
1 parent cc5901b commit e91873f

6 files changed

Lines changed: 108 additions & 57 deletions

File tree

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2026-07-23 Dirk Eddelbuettel <edd@debian.org>
2+
3+
* inst/include/armadillo_bits/: Armadillo 15.4.2
4+
15
2026-07-09 Dirk Eddelbuettel <edd@debian.org>
26

37
* DESCRIPTION (Version, Date): RcppArmadillo 15.4.1-1

inst/include/armadillo_bits/arma_version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#define ARMA_VERSION_MAJOR 15
2525
#define ARMA_VERSION_MINOR 4
26-
#define ARMA_VERSION_PATCH 1
26+
#define ARMA_VERSION_PATCH 2
2727
#define ARMA_VERSION_NAME "Medium Roast Agave"
2828

2929

inst/include/armadillo_bits/op_diagmat_bones.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ struct op_diagmat
3333
template<typename T1>
3434
inline static void apply(Mat<typename T1::elem_type>& out, const Proxy<T1>& P);
3535

36+
//
37+
3638
template<typename T1, typename T2>
3739
inline static void apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagmat>& X);
3840

41+
template<typename T1, typename T2>
42+
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagmat>& X);
43+
3944
template<typename T1, typename T2>
4045
inline static void apply_times(Mat<typename T1::elem_type>& out, const T1& X, const T2& Y, const typename arma_not_cx<typename T1::elem_type>::result* junk = nullptr);
4146

inst/include/armadillo_bits/op_diagmat_meat.hpp

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,31 @@ op_diagmat::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_ti
174174
{
175175
arma_debug_sigprint();
176176

177+
typedef typename T1::elem_type eT;
178+
179+
if(X.m.is_alias(out))
180+
{
181+
Mat<eT> tmp;
182+
183+
op_diagmat::apply_times(tmp, X.m.A, X.m.B);
184+
185+
out.steal_mem(tmp);
186+
}
187+
else
188+
{
189+
op_diagmat::apply_times(out, X.m.A, X.m.B);
190+
}
191+
}
192+
193+
194+
195+
template<typename T1, typename T2>
196+
inline
197+
void
198+
op_diagmat::apply(Mat_noalias<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagmat>& X)
199+
{
200+
arma_debug_sigprint();
201+
177202
op_diagmat::apply_times(out, X.m.A, X.m.B);
178203
}
179204

@@ -182,7 +207,7 @@ op_diagmat::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_ti
182207
template<typename T1, typename T2>
183208
inline
184209
void
185-
op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, const T2& Y, const typename arma_not_cx<typename T1::elem_type>::result* junk)
210+
op_diagmat::apply_times(Mat<typename T1::elem_type>& out, const T1& X, const T2& Y, const typename arma_not_cx<typename T1::elem_type>::result* junk)
186211
{
187212
arma_debug_sigprint();
188213
arma_ignore(junk);
@@ -218,9 +243,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
218243
const eT* C_mem = C.memptr();
219244
const uword N = C.n_elem;
220245

221-
actual_out.zeros(N,N);
246+
out.zeros(N,N);
222247

223-
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
248+
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
224249

225250
return;
226251
}
@@ -236,9 +261,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
236261
const eT* C_mem = C.memptr();
237262
const uword N = C.n_elem;
238263

239-
actual_out.zeros(N,N);
264+
out.zeros(N,N);
240265

241-
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
266+
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
242267

243268
return;
244269
}
@@ -254,9 +279,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
254279
const eT* C_mem = C.memptr();
255280
const uword N = C.n_elem;
256281

257-
actual_out.zeros(N,N);
282+
out.zeros(N,N);
258283

259-
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
284+
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
260285

261286
return;
262287
}
@@ -272,20 +297,15 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
272297
const eT* C_mem = C.memptr();
273298
const uword N = C.n_elem;
274299

275-
actual_out.zeros(N,N);
300+
out.zeros(N,N);
276301

277-
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
302+
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
278303

279304
return;
280305
}
281306
}
282307

283308
// if we got to this point, the multiplication results in a matrix
284-
285-
const bool is_alias = (UA.is_alias(actual_out) || UB.is_alias(actual_out));
286-
287-
Mat<eT> tmp;
288-
Mat<eT>& out = (is_alias) ? tmp : actual_out;
289309

290310
if( (partial_unwrap<T1>::do_trans == false) && (partial_unwrap<T2>::do_trans == false) )
291311
{
@@ -398,16 +418,14 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
398418
out.at(k,k) = (use_alpha) ? eT(alpha * acc) : eT(acc);
399419
}
400420
}
401-
402-
if(is_alias) { actual_out.steal_mem(tmp); }
403421
}
404422

405423

406424

407425
template<typename T1, typename T2>
408426
inline
409427
void
410-
op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, const T2& Y, const typename arma_cx_only<typename T1::elem_type>::result* junk)
428+
op_diagmat::apply_times(Mat<typename T1::elem_type>& out, const T1& X, const T2& Y, const typename arma_cx_only<typename T1::elem_type>::result* junk)
411429
{
412430
arma_debug_sigprint();
413431
arma_ignore(junk);
@@ -444,9 +462,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
444462
const eT* C_mem = C.memptr();
445463
const uword N = C.n_elem;
446464

447-
actual_out.zeros(N,N);
465+
out.zeros(N,N);
448466

449-
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
467+
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
450468

451469
return;
452470
}
@@ -462,9 +480,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
462480
const eT* C_mem = C.memptr();
463481
const uword N = C.n_elem;
464482

465-
actual_out.zeros(N,N);
483+
out.zeros(N,N);
466484

467-
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
485+
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
468486

469487
return;
470488
}
@@ -480,9 +498,9 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
480498
const eT* C_mem = C.memptr();
481499
const uword N = C.n_elem;
482500

483-
actual_out.zeros(N,N);
501+
out.zeros(N,N);
484502

485-
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
503+
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
486504

487505
return;
488506
}
@@ -498,20 +516,15 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
498516
const eT* C_mem = C.memptr();
499517
const uword N = C.n_elem;
500518

501-
actual_out.zeros(N,N);
519+
out.zeros(N,N);
502520

503-
for(uword i=0; i<N; ++i) { actual_out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
521+
for(uword i=0; i<N; ++i) { out.at(i,i) = (use_alpha) ? eT(alpha * C_mem[i]) : eT(C_mem[i]); }
504522

505523
return;
506524
}
507525
}
508526

509527
// if we got to this point, the multiplication results in a matrix
510-
511-
const bool is_alias = (UA.is_alias(actual_out) || UB.is_alias(actual_out));
512-
513-
Mat<eT> tmp;
514-
Mat<eT>& out = (is_alias) ? tmp : actual_out;
515528

516529
if( (partial_unwrap<T1>::do_trans == false) && (partial_unwrap<T2>::do_trans == false) )
517530
{
@@ -673,8 +686,6 @@ op_diagmat::apply_times(Mat<typename T1::elem_type>& actual_out, const T1& X, co
673686
out.at(k,k) = (use_alpha) ? eT(alpha * acc) : eT(acc);
674687
}
675688
}
676-
677-
if(is_alias) { actual_out.steal_mem(tmp); }
678689
}
679690

680691

inst/include/armadillo_bits/op_diagvec_bones.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@ struct op_diagvec
3333
template<typename T1>
3434
inline static void apply_proxy(Mat<typename T1::elem_type>& out, const Proxy<T1>& P);
3535

36+
//
37+
38+
template<typename T1, typename T2>
39+
inline static void apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X);
40+
41+
template<typename T1, typename T2>
42+
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X);
43+
3644
template<typename T1, typename T2>
37-
inline static void apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X, const typename arma_not_cx<typename T1::elem_type>::result* junk = nullptr);
45+
inline static void apply_glue_times(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X, const typename arma_not_cx<typename T1::elem_type>::result* junk = nullptr);
3846

3947
template<typename T1, typename T2>
40-
inline static void apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X, const typename arma_cx_only<typename T1::elem_type>::result* junk = nullptr);
48+
inline static void apply_glue_times(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X, const typename arma_cx_only<typename T1::elem_type>::result* junk = nullptr);
4149
};
4250

4351

inst/include/armadillo_bits/op_diagvec_meat.hpp

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -101,31 +101,63 @@ op_diagvec::apply_proxy(Mat<typename T1::elem_type>& out, const Proxy<T1>& P)
101101
template<typename T1, typename T2>
102102
inline
103103
void
104-
op_diagvec::apply(Mat<typename T1::elem_type>& actual_out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X, const typename arma_not_cx<typename T1::elem_type>::result* junk)
104+
op_diagvec::apply(Mat<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X)
105+
{
106+
arma_debug_sigprint();
107+
108+
typedef typename T1::elem_type eT;
109+
110+
if(X.m.is_alias(out))
111+
{
112+
Mat<eT> tmp;
113+
114+
op_diagvec::apply_glue_times(tmp, X.m);
115+
116+
out.steal_mem(tmp);
117+
}
118+
else
119+
{
120+
op_diagvec::apply_glue_times(out, X.m);
121+
}
122+
}
123+
124+
125+
126+
template<typename T1, typename T2>
127+
inline
128+
void
129+
op_diagvec::apply(Mat_noalias<typename T1::elem_type>& out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X)
130+
{
131+
arma_debug_sigprint();
132+
133+
op_diagvec::apply_glue_times(out, X.m);
134+
}
135+
136+
137+
138+
template<typename T1, typename T2>
139+
inline
140+
void
141+
op_diagvec::apply_glue_times(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X, const typename arma_not_cx<typename T1::elem_type>::result* junk)
105142
{
106143
arma_debug_sigprint();
107144
arma_ignore(junk);
108145

109146
typedef typename T1::elem_type eT;
110147

111-
const partial_unwrap<T1> UA(X.m.A);
112-
const partial_unwrap<T2> UB(X.m.B);
148+
const partial_unwrap<T1> UA(X.A);
149+
const partial_unwrap<T2> UB(X.B);
113150

114151
const typename partial_unwrap<T1>::stored_type& A = UA.M;
115152
const typename partial_unwrap<T2>::stored_type& B = UB.M;
116153

117154
arma_conform_assert_trans_mul_size< partial_unwrap<T1>::do_trans, partial_unwrap<T2>::do_trans >(A.n_rows, A.n_cols, B.n_rows, B.n_cols, "matrix multiplication");
118155

119-
if( (A.n_elem == 0) || (B.n_elem == 0) ) { actual_out.reset(); return; }
156+
if( (A.n_elem == 0) || (B.n_elem == 0) ) { out.reset(); return; }
120157

121158
constexpr bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times;
122159
const eT alpha = use_alpha ? (UA.get_val() * UB.get_val()) : eT(0);
123160

124-
const bool is_alias = (UA.is_alias(actual_out) || UB.is_alias(actual_out));
125-
126-
Mat<eT> tmp;
127-
Mat<eT>& out = (is_alias) ? tmp : actual_out;
128-
129161
const uword A_n_rows = A.n_rows;
130162
const uword A_n_cols = A.n_cols;
131163

@@ -251,41 +283,34 @@ op_diagvec::apply(Mat<typename T1::elem_type>& actual_out, const Op< Glue<T1,T2,
251283
out_mem[k] = (use_alpha) ? eT(alpha * acc) : eT(acc);
252284
}
253285
}
254-
255-
if(is_alias) { actual_out.steal_mem(tmp); }
256286
}
257287

258288

259289

260290
template<typename T1, typename T2>
261291
inline
262292
void
263-
op_diagvec::apply(Mat<typename T1::elem_type>& actual_out, const Op< Glue<T1,T2,glue_times>, op_diagvec>& X, const typename arma_cx_only<typename T1::elem_type>::result* junk)
293+
op_diagvec::apply_glue_times(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X, const typename arma_cx_only<typename T1::elem_type>::result* junk)
264294
{
265295
arma_debug_sigprint();
266296
arma_ignore(junk);
267297

268298
typedef typename T1::pod_type T;
269299
typedef typename T1::elem_type eT;
270300

271-
const partial_unwrap<T1> UA(X.m.A);
272-
const partial_unwrap<T2> UB(X.m.B);
301+
const partial_unwrap<T1> UA(X.A);
302+
const partial_unwrap<T2> UB(X.B);
273303

274304
const typename partial_unwrap<T1>::stored_type& A = UA.M;
275305
const typename partial_unwrap<T2>::stored_type& B = UB.M;
276306

277307
arma_conform_assert_trans_mul_size< partial_unwrap<T1>::do_trans, partial_unwrap<T2>::do_trans >(A.n_rows, A.n_cols, B.n_rows, B.n_cols, "matrix multiplication");
278308

279-
if( (A.n_elem == 0) || (B.n_elem == 0) ) { actual_out.reset(); return; }
309+
if( (A.n_elem == 0) || (B.n_elem == 0) ) { out.reset(); return; }
280310

281311
constexpr bool use_alpha = partial_unwrap<T1>::do_times || partial_unwrap<T2>::do_times;
282312
const eT alpha = use_alpha ? (UA.get_val() * UB.get_val()) : eT(0);
283313

284-
const bool is_alias = (UA.is_alias(actual_out) || UB.is_alias(actual_out));
285-
286-
Mat<eT> tmp;
287-
Mat<eT>& out = (is_alias) ? tmp : actual_out;
288-
289314
const uword A_n_rows = A.n_rows;
290315
const uword A_n_cols = A.n_cols;
291316

@@ -460,8 +485,6 @@ op_diagvec::apply(Mat<typename T1::elem_type>& actual_out, const Op< Glue<T1,T2,
460485
out_mem[k] = (use_alpha) ? eT(alpha * acc) : eT(acc);
461486
}
462487
}
463-
464-
if(is_alias) { actual_out.steal_mem(tmp); }
465488
}
466489

467490

0 commit comments

Comments
 (0)