Skip to content

Commit 2e0fa79

Browse files
committed
Sync with Armadillo 14.4.3
1 parent aba93fb commit 2e0fa79

File tree

13 files changed

+115
-159
lines changed

13 files changed

+115
-159
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2025-05-21 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/armadillo_bits/: Sync with Armadillo 14.4.3
4+
15
2025-04-25 Dirk Eddelbuettel <[email protected]>
26

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

inst/include/armadillo_bits/MapMat_meat.hpp

Lines changed: 31 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -970,18 +970,17 @@ MapMat_val<eT>::operator*=(const eT in_val)
970970

971971
if(it != it_end)
972972
{
973-
if(in_val != eT(0))
974-
{
975-
eT& val = (*it).second;
976-
977-
val *= in_val;
978-
979-
if(val == eT(0)) { map_ref.erase(it); }
980-
}
981-
else
982-
{
983-
map_ref.erase(it);
984-
}
973+
eT& val = (*it).second;
974+
975+
val *= in_val;
976+
977+
if(val == eT(0)) { map_ref.erase(it); }
978+
}
979+
else
980+
{
981+
const eT val = eT(0) * in_val; // in case in_val is inf or nan
982+
983+
if(val != eT(0)) { parent.set_val(index, val); }
985984
}
986985
}
987986

@@ -1009,9 +1008,7 @@ MapMat_val<eT>::operator/=(const eT in_val)
10091008
}
10101009
else
10111010
{
1012-
// silly operation, but included for completeness
1013-
1014-
const eT val = eT(0) / in_val;
1011+
const eT val = eT(0) / in_val; // in case in_val is zero or nan
10151012

10161013
if(val != eT(0)) { parent.set_val(index, val); }
10171014
}
@@ -1481,38 +1478,27 @@ SpMat_MapMat_val<eT>::mul(const eT in_val)
14811478

14821479
if(it != it_end)
14831480
{
1484-
if(in_val != eT(0))
1485-
{
1486-
eT& val = (*it).second;
1487-
1488-
val *= in_val;
1489-
1490-
if(val == eT(0)) { map_ref.erase(it); }
1491-
}
1492-
else
1493-
{
1494-
map_ref.erase(it);
1495-
}
1481+
eT& val = (*it).second;
1482+
1483+
val *= in_val;
1484+
1485+
if(val == eT(0)) { map_ref.erase(it); }
14961486

14971487
s_parent.sync_state = 1;
14981488

14991489
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
15001490
}
15011491
else
15021492
{
1503-
// element not found, ie. it's zero; zero multiplied by anything is zero, except for nan and inf
1504-
if(arma_isfinite(in_val) == false)
1493+
const eT result = eT(0) * in_val; // in case in_val is inf or nan
1494+
1495+
if(result != eT(0))
15051496
{
1506-
const eT result = eT(0) * in_val;
1497+
m_parent.set_val(index, result);
1498+
1499+
s_parent.sync_state = 1;
15071500

1508-
if(result != eT(0)) // paranoia, in case compiling with -ffast-math
1509-
{
1510-
m_parent.set_val(index, result);
1511-
1512-
s_parent.sync_state = 1;
1513-
1514-
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
1515-
}
1501+
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
15161502
}
15171503
}
15181504
}
@@ -1554,19 +1540,15 @@ SpMat_MapMat_val<eT>::div(const eT in_val)
15541540
}
15551541
else
15561542
{
1557-
// element not found, ie. it's zero; zero divided by anything is zero, except for zero and nan
1558-
if( (in_val == eT(0)) || (arma_isnan(in_val)) )
1543+
const eT result = eT(0) / in_val; // in case in_val is zero or nan
1544+
1545+
if(result != eT(0))
15591546
{
1560-
const eT result = eT(0) / in_val;
1547+
m_parent.set_val(index, result);
1548+
1549+
s_parent.sync_state = 1;
15611550

1562-
if(result != eT(0)) // paranoia, in case compiling with -ffast-math
1563-
{
1564-
m_parent.set_val(index, result);
1565-
1566-
s_parent.sync_state = 1;
1567-
1568-
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
1569-
}
1551+
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
15701552
}
15711553
}
15721554
}

inst/include/armadillo_bits/SpMat_meat.hpp

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -612,33 +612,26 @@ SpMat<eT>::operator*=(const eT val)
612612
{
613613
arma_debug_sigprint();
614614

615-
if(val != eT(0))
615+
sync_csc();
616+
invalidate_cache();
617+
618+
const uword n_nz = n_nonzero;
619+
620+
eT* vals = access::rwp(values);
621+
622+
bool has_zero = false;
623+
624+
for(uword i=0; i<n_nz; ++i)
616625
{
617-
sync_csc();
618-
invalidate_cache();
619-
620-
const uword n_nz = n_nonzero;
621-
622-
eT* vals = access::rwp(values);
623-
624-
bool has_zero = false;
626+
eT& vals_i = vals[i];
625627

626-
for(uword i=0; i<n_nz; ++i)
627-
{
628-
eT& vals_i = vals[i];
629-
630-
vals_i *= val;
631-
632-
if(vals_i == eT(0)) { has_zero = true; }
633-
}
628+
vals_i *= val;
634629

635-
if(has_zero) { remove_zeros(); }
636-
}
637-
else
638-
{
639-
(*this).zeros();
630+
if(vals_i == eT(0)) { has_zero = true; }
640631
}
641632

633+
if(has_zero) { remove_zeros(); }
634+
642635
return *this;
643636
}
644637

inst/include/armadillo_bits/SpSubview_col_list_meat.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ SpSubview_col_list<eT,T1>::operator*= (const eT val)
253253
{
254254
arma_debug_sigprint();
255255

256-
if(val == eT(0)) { (*this).zeros(); return; }
257-
258256
SpMat<eT>& m_local = const_cast< SpMat<eT>& >(m);
259257

260258
const umat& ci = U_ci.M;

inst/include/armadillo_bits/SpSubview_meat.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ SpSubview<eT>::operator*=(const eT val)
157157
{
158158
arma_debug_sigprint();
159159

160-
if(val == eT(0)) { (*this).zeros(); return *this; }
161-
162160
if((n_elem == 0) || (n_nonzero == 0)) { return *this; }
163161

164162
m.sync_csc();

inst/include/armadillo_bits/SpValProxy_meat.hpp

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,17 @@ inline
148148
SpValProxy<T1>&
149149
SpValProxy<T1>::operator*=(const eT rhs)
150150
{
151-
if(rhs != eT(0))
151+
if(val_ptr)
152152
{
153-
if(val_ptr)
154-
{
155-
// The value already exists and merely needs to be updated.
156-
*val_ptr *= rhs;
157-
parent.invalidate_cache();
158-
check_zero();
159-
}
153+
*val_ptr *= rhs;
154+
parent.invalidate_cache();
155+
check_zero();
160156
}
161157
else
162158
{
163-
if(val_ptr)
164-
{
165-
// Since we are multiplying by zero, the value can be deleted.
166-
parent.delete_element(row, col);
167-
val_ptr = nullptr;
168-
}
159+
const eT val = eT(0) * rhs; // in case rhs is inf or nan
160+
161+
if(val != eT(0)) { val_ptr = &parent.insert_element(row, col, val); }
169162
}
170163

171164
return *this;
@@ -178,37 +171,17 @@ inline
178171
SpValProxy<T1>&
179172
SpValProxy<T1>::operator/=(const eT rhs)
180173
{
181-
if(rhs != eT(0)) // I hope this is true!
174+
if(val_ptr)
182175
{
183-
if(val_ptr)
184-
{
185-
*val_ptr /= rhs;
186-
parent.invalidate_cache();
187-
check_zero();
188-
}
176+
*val_ptr /= rhs;
177+
parent.invalidate_cache();
178+
check_zero();
189179
}
190180
else
191181
{
192-
if(val_ptr)
193-
{
194-
*val_ptr /= rhs; // That is where it gets ugly.
195-
// Now check if it's 0.
196-
if(*val_ptr == eT(0))
197-
{
198-
parent.delete_element(row, col);
199-
val_ptr = nullptr;
200-
}
201-
}
202-
else
203-
{
204-
eT val = eT(0) / rhs; // This may vary depending on type and implementation.
205-
206-
if(val != eT(0))
207-
{
208-
// Ok, now we have to insert it.
209-
val_ptr = &parent.insert_element(row, col, val);
210-
}
211-
}
182+
const eT val = eT(0) / rhs; // in case rhs is zero or nan
183+
184+
if(val != eT(0)) { val_ptr = &parent.insert_element(row, col, val); }
212185
}
213186

214187
return *this;

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 14
2525
#define ARMA_VERSION_MINOR 4
26-
#define ARMA_VERSION_PATCH 2
26+
#define ARMA_VERSION_PATCH 3
2727
#define ARMA_VERSION_NAME "Filtered Espresso"
2828

2929

inst/include/armadillo_bits/compiler_setup.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@
172172
#pragma message("INFO: support for GCC versions older than 8.1 is deprecated"
173173
#endif
174174

175+
#if (ARMA_GCC_VERSION >= 170000)
176+
#undef ARMA_IGNORE_DEPRECATED_MARKER
177+
#endif
178+
175179
#define ARMA_GOOD_COMPILER
176180

177181
#undef arma_hot
@@ -229,6 +233,12 @@
229233

230234
// #pragma message ("using Clang extensions")
231235

236+
#if defined(__clang_major__) && !defined(__apple_build_version__)
237+
#if (__clang_major__ >= 24)
238+
#undef ARMA_IGNORE_DEPRECATED_MARKER
239+
#endif
240+
#endif
241+
232242
#define ARMA_GOOD_COMPILER
233243

234244
#if !defined(__has_attribute)
@@ -477,7 +487,7 @@
477487
#undef major
478488

479489

480-
// WARNING: option 'ARMA_IGNORE_DEPRECATED_MARKER' will be removed;
490+
// WARNING: option 'ARMA_IGNORE_DEPRECATED_MARKER' is not supported when compiling with gcc 17+ or clang 24+
481491
// WARNING: disabling deprecation messages is counter-productive
482492

483493
#if defined(ARMA_IGNORE_DEPRECATED_MARKER)

inst/include/armadillo_bits/fn_accu.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,8 @@ accu(const SpGlue<T1,T2,spglue_schur>& expr)
11211121

11221122
arma_conform_assert_same_size(px.get_n_rows(), px.get_n_cols(), py.get_n_rows(), py.get_n_cols(), "element-wise multiplication");
11231123

1124+
if( (px.get_n_nonzero() == 0) && (py.get_n_nonzero() == 0) ) { return eT(0); }
1125+
11241126
typedef typename SpProxy<T1>::stored_type px_Q_type;
11251127
typedef typename SpProxy<T2>::stored_type py_Q_type;
11261128

@@ -1162,10 +1164,14 @@ accu(const SpGlue<T1,T2,spglue_schur>& expr)
11621164

11631165
if((x_it_col < y_it_col) || ((x_it_col == y_it_col) && (x_it_row < y_it_row))) // if y is closer to the end
11641166
{
1167+
acc += (*x_it) * eT(0); // in case (*x_it) is inf or nan
1168+
11651169
++x_it;
11661170
}
11671171
else // x is closer to the end
11681172
{
1173+
acc += eT(0) * (*y_it); // in case (*y_it) is inf or nan
1174+
11691175
++y_it;
11701176
}
11711177
}

inst/include/armadillo_bits/fn_misc.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ logspace(const double A, const double B, const uword N = 50u)
149149

150150
//! kept for compatibility with old user code
151151
template<typename eT>
152-
arma_warn_unused
153-
arma_inline
152+
arma_frown("change arma::is_finite(val) to std::isfinite(val)")
153+
inline
154154
bool
155155
is_finite(const eT x, const typename arma_scalar_only<eT>::result* junk = nullptr)
156156
{
@@ -163,7 +163,7 @@ is_finite(const eT x, const typename arma_scalar_only<eT>::result* junk = nullpt
163163

164164
//! kept for compatibility with old user code
165165
template<typename T1>
166-
arma_warn_unused
166+
arma_frown("change arma::is_finite(X) to X.is_finite()")
167167
inline
168168
bool
169169
is_finite(const Base<typename T1::elem_type,T1>& X)
@@ -177,7 +177,7 @@ is_finite(const Base<typename T1::elem_type,T1>& X)
177177

178178
//! kept for compatibility with old user code
179179
template<typename T1>
180-
arma_warn_unused
180+
arma_frown("change arma::is_finite(X) to X.is_finite()")
181181
inline
182182
bool
183183
is_finite(const SpBase<typename T1::elem_type,T1>& X)
@@ -191,7 +191,7 @@ is_finite(const SpBase<typename T1::elem_type,T1>& X)
191191

192192
//! kept for compatibility with old user code
193193
template<typename T1>
194-
arma_warn_unused
194+
arma_frown("change arma::is_finite(X) to X.is_finite()")
195195
inline
196196
bool
197197
is_finite(const BaseCube<typename T1::elem_type,T1>& X)

0 commit comments

Comments
 (0)