use consistent style for std::min and std::max

This commit is contained in:
conrad
2021-04-30 23:28:18 +10:00
parent 7f6234517c
commit 2c2731d0ab
5 changed files with 22 additions and 20 deletions
@@ -123,7 +123,7 @@ DoubleShiftQR<eT>::update_block(uword il, uword iu)
// Apply the first reflector
apply_PX(mat_H, il, il, 3, n - il, il);
apply_XP(mat_H, 0, il, il + std::min(bsize, uword(4)), 3, il);
apply_XP(mat_H, 0, il, il + (std::min)(bsize, uword(4)), 3, il);
// Calculate the following reflectors
// If entering this loop, block size is at least 4.
@@ -132,7 +132,7 @@ DoubleShiftQR<eT>::update_block(uword il, uword iu)
compute_reflector(mat_H.colptr(il + i - 1) + il + i, il + i);
// Apply the reflector to X
apply_PX(mat_H, il + i, il + i - 1, 3, n + 1 - il - i, il + i);
apply_XP(mat_H, 0, il + i, il + std::min(bsize, uword(i + 4)), 3, il + i);
apply_XP(mat_H, 0, il + i, il + (std::min)(bsize, uword(i + 4)), 3, il + i);
}
// The last reflector
@@ -151,6 +151,7 @@ GenEigsSolver<eT, SelectionRule, OpType>::restart(uword k)
fac_H.diag() += ritz_val(i).real();
}
}
// V -> VQ
// Q has some elements being zero
// The first (ncv - k + i) elements of the i-th column of Q are non-zero
@@ -186,7 +187,7 @@ GenEigsSolver<eT, SelectionRule, OpType>::num_converged(eT tol)
const eT f_norm = arma::norm(fac_f);
for(uword i = 0; i < nev; i++)
{
eT thresh = tol * std::max(approx0, std::abs(ritz_val(i)));
eT thresh = tol * (std::max)(approx0, std::abs(ritz_val(i)));
eT resid = std::abs(ritz_est(i)) * f_norm;
ritz_conv[i] = (resid < thresh);
}
@@ -210,7 +211,7 @@ GenEigsSolver<eT, SelectionRule, OpType>::nev_adjusted(uword nconv)
if(std::abs(ritz_est(i)) < eps) { nev_new++; }
}
// Adjust nev_new again, according to dnaup2.f line 660~674 in ARPACK
nev_new += std::min(nconv, (ncv - nev_new) / 2);
nev_new += (std::min)(nconv, (ncv - nev_new) / 2);
if(nev_new == 1 && ncv >= 6)
{
nev_new = ncv / 2;
@@ -394,7 +395,7 @@ GenEigsSolver<eT, SelectionRule, OpType>::compute(uword maxit, eT tol)
niter = i + 1;
return std::min(nev, nconv);
return (std::min)(nev, nconv);
}
@@ -435,7 +436,7 @@ GenEigsSolver<eT, SelectionRule, OpType>::eigenvectors(uword nvec)
arma_extra_debug_sigprint();
uword nconv = std::count(ritz_conv.begin(), ritz_conv.end(), true);
nvec = std::min(nvec, nconv);
nvec = (std::min)(nvec, nconv);
Mat< std::complex<eT> > res(dim_n, nvec);
if(nvec > 0)
@@ -172,6 +172,7 @@ SymEigsSolver<eT, SelectionRule, OpType>::restart(uword k)
Col<eT> v(Vs.colptr(i), dim_n, false, true);
v = V * q;
}
Vs.col(k) = fac_V * Q.col(k);
fac_V.head_cols(k + 1) = Vs;
@@ -193,7 +194,7 @@ SymEigsSolver<eT, SelectionRule, OpType>::num_converged(eT tol)
const eT f_norm = norm(fac_f);
for(uword i = 0; i < nev; i++)
{
eT thresh = tol * std::max(eps23, std::abs(ritz_val(i)));
eT thresh = tol * (std::max)(eps23, std::abs(ritz_val(i)));
eT resid = std::abs(ritz_est(i)) * f_norm;
ritz_conv[i] = (resid < thresh);
}
@@ -217,7 +218,7 @@ SymEigsSolver<eT, SelectionRule, OpType>::nev_adjusted(uword nconv)
}
// Adjust nev_new, according to dsaup2.f line 677~684 in ARPACK
nev_new += std::min(nconv, (ncv - nev_new) / 2);
nev_new += (std::min)(nconv, (ncv - nev_new) / 2);
if(nev_new >= ncv) { nev_new = ncv - 1; }
if(nev_new == 1 && ncv >= 6)
{
@@ -416,7 +417,7 @@ SymEigsSolver<eT, SelectionRule, OpType>::compute(uword maxit, eT tol)
niter = i + 1;
return std::min(nev, nconv);
return (std::min)(nev, nconv);
}
@@ -457,7 +458,7 @@ SymEigsSolver<eT, SelectionRule, OpType>::eigenvectors(uword nvec)
arma_extra_debug_sigprint();
uword nconv = std::count(ritz_conv.begin(), ritz_conv.end(), true);
nvec = std::min(nvec, nconv);
nvec = (std::min)(nvec, nconv);
Mat<eT> res(dim_n, nvec);
if(nvec > 0)
+5 -5
View File
@@ -150,7 +150,7 @@ spop_max::vector_max
}
else
{
return std::max(eT(0), op_max::direct_max(p.get_values(), p.get_n_nonzero()));
return (std::max)(eT(0), op_max::direct_max(p.get_values(), p.get_n_nonzero()));
}
}
else
@@ -175,7 +175,7 @@ spop_max::vector_max
}
else
{
return std::max(eT(0), result);
return (std::max)(eT(0), result);
}
}
}
@@ -234,7 +234,7 @@ spop_max::max(const SpBase<typename T1::elem_type, T1>& X)
}
else
{
return std::max(eT(0), max_val);
return (std::max)(eT(0), max_val);
}
}
@@ -298,7 +298,7 @@ spop_max::max_with_index(const SpProxy<T1>& P, uword& index_of_max_val)
if(n_elem != n_nonzero)
{
max_val = std::max(eT(0), max_val);
max_val = (std::max)(eT(0), max_val);
// If the max_val is a nonzero element, we need its actual position in the matrix.
if(max_val == eT(0))
@@ -631,7 +631,7 @@ spop_max::max_with_index(const SpProxy<T1>& P, uword& index_of_max_val)
if(n_elem != n_nonzero)
{
max_val = std::max(T(0), max_val);
max_val = (std::max)(T(0), max_val);
// If the max_val is a nonzero element, we need its actual position in the matrix.
if(max_val == T(0))
+5 -5
View File
@@ -150,7 +150,7 @@ spop_min::vector_min
}
else
{
return std::min(eT(0), op_min::direct_min(p.get_values(), p.get_n_nonzero()));
return (std::min)(eT(0), op_min::direct_min(p.get_values(), p.get_n_nonzero()));
}
}
else
@@ -175,7 +175,7 @@ spop_min::vector_min
}
else
{
return std::min(eT(0), result);
return (std::min)(eT(0), result);
}
}
}
@@ -234,7 +234,7 @@ spop_min::min(const SpBase<typename T1::elem_type, T1>& X)
}
else
{
return std::min(eT(0), min_val);
return (std::min)(eT(0), min_val);
}
}
@@ -298,7 +298,7 @@ spop_min::min_with_index(const SpProxy<T1>& P, uword& index_of_min_val)
if(n_elem != n_nonzero)
{
min_val = std::min(eT(0), min_val);
min_val = (std::min)(eT(0), min_val);
// If the min_val is a nonzero element, we need its actual position in the matrix.
if(min_val == eT(0))
@@ -667,7 +667,7 @@ spop_min::min_with_index(const SpProxy<T1>& P, uword& index_of_min_val)
if(n_elem != n_nonzero)
{
min_val = std::min(T(0), min_val);
min_val = (std::min)(T(0), min_val);
// If the min_val is a nonzero element, we need its actual position in the matrix.
if(min_val == T(0))