From b5482a3133bc36cff06202179a59a69de26056e9 Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 9 Feb 2024 08:03:43 +0100 Subject: [PATCH] . --- CImg.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/CImg.h b/CImg.h index 183b5118..553733e2 100644 --- a/CImg.h +++ b/CImg.h @@ -31446,9 +31446,9 @@ namespace cimg_library { CImg _get_invert_svd(const float lambda) const { CImg U, S, V; SVD(U,S,V,false); - const Tfloat epsilon = (sizeof(Tfloat)<=4?5.96e-8f:1.11e-16f)*std::max(_width,_height)*S.max(); + const Tfloat eps = (sizeof(Tfloat)<=4?5.96e-8f:1.11e-16f)*std::max(_width,_height)*S.max(); cimg_forX(V,x) { - const Tfloat s = S(x), invs = lambda?1/(lambda + s):s>epsilon?1/s:0; + const Tfloat s = S(x), invs = lambda?1/(lambda + s):s>eps?1/s:0; cimg_forY(V,y) V(x,y)*=invs; } return V*U.transpose(); @@ -31616,15 +31616,15 @@ namespace cimg_library { cimg_instance, A._width,A._height,A._depth,A._spectrum,A._data); typedef _cimg_Ttfloat Ttfloat; - const Ttfloat epsilon = 1e-4f; + const Ttfloat eps = 1e-4f; CImg B = A.get_column(1), V(*this,false); for (int i = 1; i<(int)siz; ++i) { - const Ttfloat m = A(0,i)/(B[i - 1]?B[i - 1]:epsilon); + const Ttfloat m = A(0,i)/(B[i - 1]?B[i - 1]:eps); B[i] -= m*A(2,i - 1); V[i] -= m*V[i - 1]; } - (*this)[siz - 1] = (T)(V[siz - 1]/(B[siz - 1]?B[siz - 1]:epsilon)); - for (int i = (int)siz - 2; i>=0; --i) (*this)[i] = (T)((V[i] - A(2,i)*(*this)[i + 1])/(B[i]?B[i]:epsilon)); + (*this)[siz - 1] = (T)(V[siz - 1]/(B[siz - 1]?B[siz - 1]:eps)); + for (int i = (int)siz - 2; i>=0; --i) (*this)[i] = (T)((V[i] - A(2,i)*(*this)[i + 1])/(B[i]?B[i]:eps)); return *this; } @@ -31940,7 +31940,7 @@ namespace cimg_library { const CImg& SVD(CImg& U, CImg& S, CImg& V, const bool sorting=true, const unsigned int max_iteration=40, const float lambda=0) const { typedef _cimg_Ttfloat Ttfloat; - const Ttfloat epsilon = (Ttfloat)1e-25; + const Ttfloat eps = (Ttfloat)1e-25; if (is_empty()) { U.assign(); S.assign(); V.assign(); } else if (_depth!=1 || _spectrum!=1) @@ -32079,9 +32079,9 @@ namespace cimg_library { t x = S[l], y = S[nm]; g = rv1[nm]; h = rv1[k]; - f = ((y - z)*(y + z) + (g - h)*(g + h))/std::max(epsilon,(Ttfloat)2*h*y); + f = ((y - z)*(y + z) + (g - h)*(g + h))/std::max(eps,(Ttfloat)2*h*y); g = cimg::hypot(f,(Ttfloat)1); - f = ((x - z)*(x + z) + h*((y/(f + (f>=0?g:-g))) - h))/std::max(epsilon,(Ttfloat)x); + f = ((x - z)*(x + z) + h*((y/(f + (f>=0?g:-g))) - h))/std::max(eps,(Ttfloat)x); c = s = 1; for (int j = l; j<=nm; ++j) { const int i = j + 1; @@ -32090,8 +32090,8 @@ namespace cimg_library { g = c*g; t y1 = S[i], z1 = cimg::hypot(f,h); rv1[j] = z1; - c = f/std::max(epsilon,(Ttfloat)z1); - s = h/std::max(epsilon,(Ttfloat)z1); + c = f/std::max(eps,(Ttfloat)z1); + s = h/std::max(eps,(Ttfloat)z1); f = x*c + g*s; g = g*c - x*s; h = y1*s; @@ -32104,7 +32104,7 @@ namespace cimg_library { z1 = cimg::hypot(f,h); S[j] = z1; if (z1) { - z1 = 1/std::max(epsilon,(Ttfloat)z1); + z1 = 1/std::max(eps,(Ttfloat)z1); c = f*z1; s = h*z1; }