Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtschump committed Feb 9, 2024
1 parent d6bdf33 commit b5482a3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions CImg.h
Original file line number Diff line number Diff line change
Expand Up @@ -31446,9 +31446,9 @@ namespace cimg_library {
CImg<Tfloat> _get_invert_svd(const float lambda) const {
CImg<Tfloat> 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();
Expand Down Expand Up @@ -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<Ttfloat> 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;
}

Expand Down Expand Up @@ -31940,7 +31940,7 @@ namespace cimg_library {
const CImg<T>& SVD(CImg<t>& U, CImg<t>& S, CImg<t>& 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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit b5482a3

Please sign in to comment.