Skip to content

Commit 81743c0

Browse files
committed
Armadillo 12.6.5
1 parent 18ae440 commit 81743c0

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

inst/include/armadillo_bits/Mat_meat.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,8 @@ Mat<eT>::operator=(const SpBase<eT, T1>& m)
26572657

26582658
(*this).zeros(x.n_rows, x_n_cols);
26592659

2660+
if(x.n_nonzero == 0) { return *this; }
2661+
26602662
const eT* x_values = x.values;
26612663
const uword* x_row_indices = x.row_indices;
26622664
const uword* x_col_ptrs = x.col_ptrs;

inst/include/armadillo_bits/SpMat_meat.hpp

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,12 +2971,11 @@ SpMat<eT>::swap_cols(const uword in_col1, const uword in_col2)
29712971

29722972
// TODO: this is a rudimentary implementation
29732973

2974-
SpMat<eT> tmp = (*this);
2974+
const SpMat<eT> tmp1 = (*this).col(in_col1);
2975+
const SpMat<eT> tmp2 = (*this).col(in_col2);
29752976

2976-
tmp.col(in_col1) = (*this).col(in_col2);
2977-
tmp.col(in_col2) = (*this).col(in_col1);
2978-
2979-
steal_mem(tmp);
2977+
(*this).col(in_col2) = tmp1;
2978+
(*this).col(in_col1) = tmp2;
29802979

29812980
// for(uword lrow = 0; lrow < n_rows; ++lrow)
29822981
// {
@@ -4099,9 +4098,14 @@ SpMat<eT>::zeros()
40994098
{
41004099
arma_extra_debug_sigprint();
41014100

4102-
const bool already_done = ( (sync_state != 1) && (n_nonzero == 0) );
4103-
4104-
if(already_done == false) { init(n_rows, n_cols); }
4101+
if((n_nonzero == 0) && (values != nullptr))
4102+
{
4103+
invalidate_cache();
4104+
}
4105+
else
4106+
{
4107+
init(n_rows, n_cols);
4108+
}
41054109

41064110
return *this;
41074111
}
@@ -4136,9 +4140,14 @@ SpMat<eT>::zeros(const uword in_rows, const uword in_cols)
41364140
{
41374141
arma_extra_debug_sigprint();
41384142

4139-
const bool already_done = ( (sync_state != 1) && (n_nonzero == 0) && (n_rows == in_rows) && (n_cols == in_cols) );
4140-
4141-
if(already_done == false) { init(in_rows, in_cols); }
4143+
if((n_nonzero == 0) && (n_rows == in_rows) && (n_cols == in_cols) && (values != nullptr))
4144+
{
4145+
invalidate_cache();
4146+
}
4147+
else
4148+
{
4149+
init(in_rows, in_cols);
4150+
}
41424151

41434152
return *this;
41444153
}
@@ -5197,11 +5206,21 @@ SpMat<eT>::init_simple(const SpMat<eT>& x)
51975206

51985207
if(this == &x) { return; }
51995208

5200-
init(x.n_rows, x.n_cols, x.n_nonzero);
5209+
if((x.n_nonzero == 0) && (n_nonzero == 0) && (n_rows == x.n_rows) && (n_cols == x.n_cols) && (values != nullptr))
5210+
{
5211+
invalidate_cache();
5212+
}
5213+
else
5214+
{
5215+
init(x.n_rows, x.n_cols, x.n_nonzero);
5216+
}
52015217

5202-
if(x.values ) { arrayops::copy(access::rwp(values), x.values, x.n_nonzero + 1); }
5203-
if(x.row_indices) { arrayops::copy(access::rwp(row_indices), x.row_indices, x.n_nonzero + 1); }
5204-
if(x.col_ptrs ) { arrayops::copy(access::rwp(col_ptrs), x.col_ptrs, x.n_cols + 1); }
5218+
if(x.n_nonzero != 0)
5219+
{
5220+
if(x.values ) { arrayops::copy(access::rwp(values), x.values, x.n_nonzero + 1); }
5221+
if(x.row_indices) { arrayops::copy(access::rwp(row_indices), x.row_indices, x.n_nonzero + 1); }
5222+
if(x.col_ptrs ) { arrayops::copy(access::rwp(col_ptrs), x.col_ptrs, x.n_cols + 1); }
5223+
}
52055224
}
52065225

52075226

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 12
2525
#define ARMA_VERSION_MINOR 6
26-
#define ARMA_VERSION_PATCH 4
26+
#define ARMA_VERSION_PATCH 5
2727
#define ARMA_VERSION_NAME "Cortisol Retox"
2828

2929

0 commit comments

Comments
 (0)