Skip to content

Commit 16e1eb3

Browse files
committed
Armadillo changes since 11.4.0 to accomodate g++-12
1 parent 2c7c053 commit 16e1eb3

File tree

10 files changed

+108
-70
lines changed

10 files changed

+108
-70
lines changed

inst/include/armadillo_bits/Col_bones.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ class Col : public Mat<eT>
138138

139139
template<typename T1> inline void shed_rows(const Base<uword, T1>& indices);
140140

141-
inline void insert_rows(const uword row_num, const uword N, const bool set_to_zero = true);
141+
arma_deprecated inline void insert_rows(const uword row_num, const uword N, const bool set_to_zero);
142+
inline void insert_rows(const uword row_num, const uword N);
143+
142144
template<typename T1> inline void insert_rows(const uword row_num, const Base<eT,T1>& X);
143145

144146

inst/include/armadillo_bits/Col_meat.hpp

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,15 +1054,28 @@ Col<eT>::shed_rows(const Base<uword, T1>& indices)
10541054

10551055

10561056

1057-
//! insert N rows at the specified row position,
1058-
//! optionally setting the elements of the inserted rows to zero
10591057
template<typename eT>
1058+
arma_deprecated
10601059
inline
10611060
void
10621061
Col<eT>::insert_rows(const uword row_num, const uword N, const bool set_to_zero)
10631062
{
10641063
arma_extra_debug_sigprint();
10651064

1065+
arma_ignore(set_to_zero);
1066+
1067+
(*this).insert_rows(row_num, N);
1068+
}
1069+
1070+
1071+
1072+
template<typename eT>
1073+
inline
1074+
void
1075+
Col<eT>::insert_rows(const uword row_num, const uword N)
1076+
{
1077+
arma_extra_debug_sigprint();
1078+
10661079
const uword t_n_rows = Mat<eT>::n_rows;
10671080

10681081
const uword A_n_rows = row_num;
@@ -1071,30 +1084,26 @@ Col<eT>::insert_rows(const uword row_num, const uword N, const bool set_to_zero)
10711084
// insertion at row_num == n_rows is in effect an append operation
10721085
arma_debug_check_bounds( (row_num > t_n_rows), "Col::insert_rows(): index out of bounds" );
10731086

1074-
if(N > 0)
1087+
if(N == 0) { return; }
1088+
1089+
Col<eT> out(t_n_rows + N, arma_nozeros_indicator());
1090+
1091+
eT* out_mem = out.memptr();
1092+
const eT* t_mem = (*this).memptr();
1093+
1094+
if(A_n_rows > 0)
10751095
{
1076-
Col<eT> out(t_n_rows + N, arma_nozeros_indicator());
1077-
1078-
eT* out_mem = out.memptr();
1079-
const eT* t_mem = (*this).memptr();
1080-
1081-
if(A_n_rows > 0)
1082-
{
1083-
arrayops::copy( out_mem, t_mem, A_n_rows );
1084-
}
1085-
1086-
if(B_n_rows > 0)
1087-
{
1088-
arrayops::copy( &(out_mem[row_num + N]), &(t_mem[row_num]), B_n_rows );
1089-
}
1090-
1091-
if(set_to_zero)
1092-
{
1093-
arrayops::inplace_set( &(out_mem[row_num]), eT(0), N );
1094-
}
1095-
1096-
Mat<eT>::steal_mem(out);
1096+
arrayops::copy( out_mem, t_mem, A_n_rows );
10971097
}
1098+
1099+
if(B_n_rows > 0)
1100+
{
1101+
arrayops::copy( &(out_mem[row_num + N]), &(t_mem[row_num]), B_n_rows );
1102+
}
1103+
1104+
arrayops::fill_zeros( &(out_mem[row_num]), N );
1105+
1106+
Mat<eT>::steal_mem(out);
10981107
}
10991108

11001109

inst/include/armadillo_bits/Cube_meat.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,14 @@ Cube<eT>::init_warm(const uword in_n_rows, const uword in_n_cols, const uword in
368368
bool err_state = false;
369369
char* err_msg = nullptr;
370370

371-
arma_debug_set_error( err_state, err_msg, (t_mem_state == 3), "Cube::init(): size is fixed and hence cannot be changed" );
371+
const char* error_message_1 = "Cube::init(): size is fixed and hence cannot be changed";
372+
373+
arma_debug_set_error( err_state, err_msg, (t_mem_state == 3), error_message_1 );
372374

373375
#if defined(ARMA_64BIT_WORD)
374-
const char* error_message = "Cube::init(): requested size is too large";
376+
const char* error_message_2 = "Cube::init(): requested size is too large";
375377
#else
376-
const char* error_message = "Cube::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD";
378+
const char* error_message_2 = "Cube::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD";
377379
#endif
378380

379381
arma_debug_set_error
@@ -385,7 +387,7 @@ Cube<eT>::init_warm(const uword in_n_rows, const uword in_n_cols, const uword in
385387
? ( (double(in_n_rows) * double(in_n_cols) * double(in_n_slices)) > double(ARMA_MAX_UWORD) )
386388
: false
387389
),
388-
error_message
390+
error_message_2
389391
);
390392

391393
arma_debug_check(err_state, err_msg);

inst/include/armadillo_bits/MapMat_meat.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ MapMat<eT>::operator=(MapMat<eT>&& x)
198198
{
199199
arma_extra_debug_sigprint();
200200

201+
if(this == &x) { return; }
202+
201203
reset();
202204

203205
if(map_ptr) { delete map_ptr; }

inst/include/armadillo_bits/Mat_meat.hpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,11 @@ Mat<eT>::init_warm(uword in_n_rows, uword in_n_cols)
351351
const uhword t_vec_state = vec_state;
352352
const uhword t_mem_state = mem_state;
353353

354-
arma_debug_set_error( err_state, err_msg, (t_mem_state == 3), "Mat::init(): size is fixed and hence cannot be changed" );
354+
const char* error_message_1 = "Mat::init(): size is fixed and hence cannot be changed";
355+
const char* error_message_2 = "Mat::init(): requested size is not compatible with column vector layout";
356+
const char* error_message_3 = "Mat::init(): requested size is not compatible with row vector layout";
357+
358+
arma_debug_set_error( err_state, err_msg, (t_mem_state == 3), error_message_1 );
355359

356360
if(t_vec_state > 0)
357361
{
@@ -362,17 +366,17 @@ Mat<eT>::init_warm(uword in_n_rows, uword in_n_cols)
362366
}
363367
else
364368
{
365-
if(t_vec_state == 1) { arma_debug_set_error( err_state, err_msg, (in_n_cols != 1), "Mat::init(): requested size is not compatible with column vector layout" ); }
366-
if(t_vec_state == 2) { arma_debug_set_error( err_state, err_msg, (in_n_rows != 1), "Mat::init(): requested size is not compatible with row vector layout" ); }
369+
if(t_vec_state == 1) { arma_debug_set_error( err_state, err_msg, (in_n_cols != 1), error_message_2 ); }
370+
if(t_vec_state == 2) { arma_debug_set_error( err_state, err_msg, (in_n_rows != 1), error_message_3 ); }
367371
}
368372
}
369373

370374
// ensure that n_elem can hold the result of (n_rows * n_cols)
371375

372376
#if defined(ARMA_64BIT_WORD)
373-
const char* error_message = "Mat::init(): requested size is too large";
377+
const char* error_message_4 = "Mat::init(): requested size is too large";
374378
#else
375-
const char* error_message = "Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD";
379+
const char* error_message_4 = "Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD";
376380
#endif
377381

378382
arma_debug_set_error
@@ -384,7 +388,7 @@ Mat<eT>::init_warm(uword in_n_rows, uword in_n_cols)
384388
? ( (double(in_n_rows) * double(in_n_cols)) > double(ARMA_MAX_UWORD) )
385389
: false
386390
),
387-
error_message
391+
error_message_4
388392
);
389393

390394
arma_debug_check(err_state, err_msg);
@@ -2758,7 +2762,7 @@ Mat<eT>::operator%=(const SpBase<eT, T1>& m)
27582762
typename SpProxy<T1>::const_iterator_type it_end = p.end();
27592763

27602764
// We have to zero everything that isn't being used.
2761-
arrayops::inplace_set(memptr(), eT(0), (it.col() * n_rows) + it.row());
2765+
arrayops::fill_zeros(memptr(), (it.col() * n_rows) + it.row());
27622766

27632767
while(it != it_end)
27642768
{
@@ -2772,7 +2776,7 @@ Mat<eT>::operator%=(const SpBase<eT, T1>& m)
27722776
? (p.get_n_cols() * n_rows)
27732777
: (it.col() * n_rows) + it.row();
27742778

2775-
arrayops::inplace_set(memptr() + cur_loc + 1, eT(0), (next_loc - cur_loc - 1));
2779+
arrayops::fill_zeros(memptr() + cur_loc + 1, (next_loc - cur_loc - 1));
27762780
}
27772781

27782782
return *this;
@@ -4668,22 +4672,25 @@ Mat<eT>::insert_rows(const uword row_num, const Base<eT,T1>& X)
46684672
bool err_state = false;
46694673
char* err_msg = nullptr;
46704674

4675+
const char* error_message_1 = "Mat::insert_rows(): index out of bounds";
4676+
const char* error_message_2 = "Mat::insert_rows(): given object has an incompatible number of columns";
4677+
46714678
// insertion at row_num == n_rows is in effect an append operation
46724679

46734680
arma_debug_set_error
46744681
(
46754682
err_state,
46764683
err_msg,
46774684
(row_num > t_n_rows),
4678-
"Mat::insert_rows(): index out of bounds"
4685+
error_message_1
46794686
);
46804687

46814688
arma_debug_set_error
46824689
(
46834690
err_state,
46844691
err_msg,
46854692
( (C_n_cols != t_n_cols) && ( (t_n_rows > 0) || (t_n_cols > 0) ) && ( (C_n_rows > 0) || (C_n_cols > 0) ) ),
4686-
"Mat::insert_rows(): given object has an incompatible number of columns"
4693+
error_message_2
46874694
);
46884695

46894696
arma_debug_check_bounds(err_state, err_msg);
@@ -4741,22 +4748,25 @@ Mat<eT>::insert_cols(const uword col_num, const Base<eT,T1>& X)
47414748
bool err_state = false;
47424749
char* err_msg = nullptr;
47434750

4751+
const char* error_message_1 = "Mat::insert_cols(): index out of bounds";
4752+
const char* error_message_2 = "Mat::insert_cols(): given object has an incompatible number of rows";
4753+
47444754
// insertion at col_num == n_cols is in effect an append operation
47454755

47464756
arma_debug_set_error
47474757
(
47484758
err_state,
47494759
err_msg,
47504760
(col_num > t_n_cols),
4751-
"Mat::insert_cols(): index out of bounds"
4761+
error_message_1
47524762
);
47534763

47544764
arma_debug_set_error
47554765
(
47564766
err_state,
47574767
err_msg,
47584768
( (C_n_rows != t_n_rows) && ( (t_n_rows > 0) || (t_n_cols > 0) ) && ( (C_n_rows > 0) || (C_n_cols > 0) ) ),
4759-
"Mat::insert_cols(): given object has an incompatible number of rows"
4769+
error_message_2
47604770
);
47614771

47624772
arma_debug_check_bounds(err_state, err_msg);

inst/include/armadillo_bits/Row_bones.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ class Row : public Mat<eT>
138138

139139
template<typename T1> inline void shed_cols(const Base<uword, T1>& indices);
140140

141-
inline void insert_cols(const uword col_num, const uword N, const bool set_to_zero = true);
141+
arma_deprecated inline void insert_cols(const uword col_num, const uword N, const bool set_to_zero);
142+
inline void insert_cols(const uword col_num, const uword N);
143+
142144
template<typename T1> inline void insert_cols(const uword col_num, const Base<eT,T1>& X);
143145

144146

inst/include/armadillo_bits/Row_meat.hpp

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,15 +1054,28 @@ Row<eT>::shed_cols(const Base<uword, T1>& indices)
10541054

10551055

10561056

1057-
//! insert N cols at the specified col position,
1058-
//! optionally setting the elements of the inserted cols to zero
10591057
template<typename eT>
1058+
arma_deprecated
10601059
inline
10611060
void
10621061
Row<eT>::insert_cols(const uword col_num, const uword N, const bool set_to_zero)
10631062
{
10641063
arma_extra_debug_sigprint();
10651064

1065+
arma_ignore(set_to_zero);
1066+
1067+
(*this).insert_cols(col_num, N);
1068+
}
1069+
1070+
1071+
1072+
template<typename eT>
1073+
inline
1074+
void
1075+
Row<eT>::insert_cols(const uword col_num, const uword N)
1076+
{
1077+
arma_extra_debug_sigprint();
1078+
10661079
const uword t_n_cols = Mat<eT>::n_cols;
10671080

10681081
const uword A_n_cols = col_num;
@@ -1071,30 +1084,26 @@ Row<eT>::insert_cols(const uword col_num, const uword N, const bool set_to_zero)
10711084
// insertion at col_num == n_cols is in effect an append operation
10721085
arma_debug_check_bounds( (col_num > t_n_cols), "Row::insert_cols(): index out of bounds" );
10731086

1074-
if(N > 0)
1087+
if(N == 0) { return; }
1088+
1089+
Row<eT> out(t_n_cols + N, arma_nozeros_indicator());
1090+
1091+
eT* out_mem = out.memptr();
1092+
const eT* t_mem = (*this).memptr();
1093+
1094+
if(A_n_cols > 0)
10751095
{
1076-
Row<eT> out(t_n_cols + N, arma_nozeros_indicator());
1077-
1078-
eT* out_mem = out.memptr();
1079-
const eT* t_mem = (*this).memptr();
1080-
1081-
if(A_n_cols > 0)
1082-
{
1083-
arrayops::copy( out_mem, t_mem, A_n_cols );
1084-
}
1085-
1086-
if(B_n_cols > 0)
1087-
{
1088-
arrayops::copy( &(out_mem[col_num + N]), &(t_mem[col_num]), B_n_cols );
1089-
}
1090-
1091-
if(set_to_zero)
1092-
{
1093-
arrayops::inplace_set( &(out_mem[col_num]), eT(0), N );
1094-
}
1095-
1096-
Mat<eT>::steal_mem(out);
1096+
arrayops::copy( out_mem, t_mem, A_n_cols );
10971097
}
1098+
1099+
if(B_n_cols > 0)
1100+
{
1101+
arrayops::copy( &(out_mem[col_num + N]), &(t_mem[col_num]), B_n_cols );
1102+
}
1103+
1104+
arrayops::fill_zeros( &(out_mem[col_num]), N );
1105+
1106+
Mat<eT>::steal_mem(out);
10981107
}
10991108

11001109

inst/include/armadillo_bits/arrayops_meat.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ arma_inline
2626
void
2727
arrayops::copy(eT* dest, const eT* src, const uword n_elem)
2828
{
29-
if( (n_elem == 0) || (dest == src) ) { return; }
29+
if( (dest == src) || (n_elem == 0) ) { return; }
3030

3131
std::memcpy(dest, src, n_elem*sizeof(eT));
3232
}
@@ -40,7 +40,7 @@ arrayops::fill_zeros(eT* dest, const uword n_elem)
4040
{
4141
typedef typename get_pod_type<eT>::result pod_type;
4242

43-
if( (n_elem == 0) || (dest == nullptr) ) { return; }
43+
if(n_elem == 0) { return; }
4444

4545
if(std::numeric_limits<eT>::is_integer || std::numeric_limits<pod_type>::is_iec559)
4646
{

inst/include/armadillo_bits/field_meat.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ field<oT>::operator=(field<oT>&& X)
427427
{
428428
arma_extra_debug_sigprint(arma_str::format("this = %x X = %x") % this % &X);
429429

430+
if(this == &X) { return *this; }
431+
430432
reset();
431433

432434
access::rw(n_rows ) = X.n_rows;

inst/include/armadillo_bits/sp_auxlib_meat.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,10 +1376,10 @@ sp_auxlib::spsolve_refine(Mat<typename T1::elem_type>& X, typename T1::pod_type&
13761376
superlu_array_wrangler<T> berr(B.n_cols+1);
13771377

13781378
superlu::GlobalLU_t glu;
1379-
arrayops::inplace_set(reinterpret_cast<char*>(&glu), char(0), sizeof(superlu::GlobalLU_t));
1379+
arrayops::fill_zeros(reinterpret_cast<char*>(&glu), sizeof(superlu::GlobalLU_t));
13801380

13811381
superlu::mem_usage_t mu;
1382-
arrayops::inplace_set(reinterpret_cast<char*>(&mu), char(0), sizeof(superlu::mem_usage_t));
1382+
arrayops::fill_zeros(reinterpret_cast<char*>(&mu), sizeof(superlu::mem_usage_t));
13831383

13841384
superlu_stat_wrangler stat;
13851385

0 commit comments

Comments
 (0)