Skip to content

Commit

Permalink
Sync with Armadillo 14.2.x branch
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Dec 3, 2024
1 parent 05aa195 commit c00595b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 15 deletions.
2 changes: 2 additions & 0 deletions inst/include/armadillo_bits/Col_bones.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class Col<eT>::fixed : public Col<eT>
{
private:

using Mat<eT>::mem_local;

static constexpr bool use_extra = (fixed_n_elem > arma_config::mat_prealloc);

arma_align_mem eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ];
Expand Down
10 changes: 5 additions & 5 deletions inst/include/armadillo_bits/Col_meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,11 +1345,11 @@ Col<eT>::fixed<fixed_n_elem>::fixed(const fill::fill_class<fill_type>&)
{
arma_debug_sigprint_this(this);

if(is_same_type<fill_type, fill::fill_zeros>::yes) { (*this).zeros(); }
if(is_same_type<fill_type, fill::fill_ones >::yes) { (*this).ones(); }
if(is_same_type<fill_type, fill::fill_eye >::yes) { (*this).eye(); }
if(is_same_type<fill_type, fill::fill_randu>::yes) { (*this).randu(); }
if(is_same_type<fill_type, fill::fill_randn>::yes) { (*this).randn(); }
if(is_same_type<fill_type, fill::fill_zeros>::yes) { (*this).zeros(); }
if(is_same_type<fill_type, fill::fill_ones >::yes) { (*this).ones(); }
if(is_same_type<fill_type, fill::fill_eye >::yes) { Mat<eT>::eye(); }
if(is_same_type<fill_type, fill::fill_randu>::yes) { Mat<eT>::randu(); }
if(is_same_type<fill_type, fill::fill_randn>::yes) { Mat<eT>::randn(); }
}


Expand Down
2 changes: 2 additions & 0 deletions inst/include/armadillo_bits/Row_bones.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class Row<eT>::fixed : public Row<eT>
{
private:

using Mat<eT>::mem_local;

static constexpr bool use_extra = (fixed_n_elem > arma_config::mat_prealloc);

arma_align_mem eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ];
Expand Down
10 changes: 5 additions & 5 deletions inst/include/armadillo_bits/Row_meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,11 +1345,11 @@ Row<eT>::fixed<fixed_n_elem>::fixed(const fill::fill_class<fill_type>&)
{
arma_debug_sigprint_this(this);

if(is_same_type<fill_type, fill::fill_zeros>::yes) { (*this).zeros(); }
if(is_same_type<fill_type, fill::fill_ones >::yes) { (*this).ones(); }
if(is_same_type<fill_type, fill::fill_eye >::yes) { (*this).eye(); }
if(is_same_type<fill_type, fill::fill_randu>::yes) { (*this).randu(); }
if(is_same_type<fill_type, fill::fill_randn>::yes) { (*this).randn(); }
if(is_same_type<fill_type, fill::fill_zeros>::yes) { (*this).zeros(); }
if(is_same_type<fill_type, fill::fill_ones >::yes) { (*this).ones(); }
if(is_same_type<fill_type, fill::fill_eye >::yes) { Mat<eT>::eye(); }
if(is_same_type<fill_type, fill::fill_randu>::yes) { Mat<eT>::randu(); }
if(is_same_type<fill_type, fill::fill_randn>::yes) { Mat<eT>::randn(); }
}


Expand Down
37 changes: 32 additions & 5 deletions inst/include/armadillo_bits/sym_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,26 @@ guess_sympd_worker(const Mat<eT>& A)
const eT* A_mem = A.memptr();
const eT* A_col = A_mem;

bool diag_below_tol = true;

eT max_diag = eT(0);

for(uword j=0; j < N; ++j)
{
const eT A_jj = A_col[j];

if(A_jj <= eT(0)) { return false; }
if( A_jj <= eT(0)) { return false; }
if(arma_isfinite(A_jj) == false) { return false; }

if(A_jj >= tol) { diag_below_tol = false; }

max_diag = (A_jj > max_diag) ? A_jj : max_diag;

A_col += N;
}

if(diag_below_tol) { return false; } // assume matrix is suspect if all diagonal elements are close to zero

A_col = A_mem;

const uword Nm1 = N-1;
Expand Down Expand Up @@ -128,6 +135,8 @@ guess_sympd_worker(const Mat<eT>& A)
const eT* A_mem = A.memptr();
const eT* A_col = A_mem;

bool diag_below_tol = true;

T max_diag = T(0);

for(uword j=0; j < N; ++j)
Expand All @@ -138,15 +147,21 @@ guess_sympd_worker(const Mat<eT>& A)
const T A_jj_rabs = std::abs(A_jj_r);
const T A_jj_iabs = std::abs(A_jj_i);

if(A_jj_r <= T(0) ) { return false; } // real should be positive
if(A_jj_iabs > tol ) { return false; } // imag should be approx zero
if(A_jj_iabs > A_jj_rabs) { return false; } // corner case: real and imag are close to zero, and imag is dominant
if( A_jj_r <= T(0) ) { return false; } // real should be positive
if(arma_isfinite(A_jj_r) == false) { return false; }

if(A_jj_iabs > tol ) { return false; } // imag should be approx zero
if(A_jj_iabs > A_jj_rabs) { return false; } // corner case: real and imag are close to zero, and imag is dominant

if(A_jj_r >= tol) { diag_below_tol = false; }

max_diag = (A_jj_r > max_diag) ? A_jj_r : max_diag;

A_col += N;
}

if(diag_below_tol) { return false; } // assume matrix is suspect if all diagonal elements are close to zero

const T square_max_diag = max_diag * max_diag;

if(arma_isfinite(square_max_diag) == false) { return false; }
Expand Down Expand Up @@ -264,15 +279,21 @@ is_approx_sym_worker(const Mat<eT>& A)
const eT* A_mem = A.memptr();
const eT* A_col = A_mem;

bool diag_below_tol = true;

for(uword j=0; j < N; ++j)
{
const eT& A_jj = A_col[j];
const eT A_jj = A_col[j];

if(arma_isfinite(A_jj) == false) { return false; }

if(std::abs(A_jj) >= tol) { diag_below_tol = false; }

A_col += N;
}

if(diag_below_tol) { return false; } // assume matrix is suspect if all diagonal elements are close to zero

A_col = A_mem;

const uword Nm1 = N-1;
Expand Down Expand Up @@ -324,6 +345,8 @@ is_approx_sym_worker(const Mat<eT>& A)
const eT* A_mem = A.memptr();
const eT* A_col = A_mem;

bool diag_below_tol = true;

// ensure diagonal has approx real-only elements
for(uword j=0; j < N; ++j)
{
Expand All @@ -338,9 +361,13 @@ is_approx_sym_worker(const Mat<eT>& A)

if(arma_isfinite(A_jj_r) == false) { return false; }

if(A_jj_rabs >= tol) { diag_below_tol = false; }

A_col += N;
}

if(diag_below_tol) { return false; } // assume matrix is suspect if all diagonal elements are close to zero

A_col = A_mem;

const uword Nm1 = N-1;
Expand Down

0 comments on commit c00595b

Please sign in to comment.