Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtschump committed Feb 11, 2024
1 parent 7889b9a commit 5dfa95e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions CImg.h
Original file line number Diff line number Diff line change
Expand Up @@ -6907,9 +6907,9 @@ namespace cimg_library {
return _fibonacci(n); // Not precise, but better than the wrong overflowing calculation
}

//! Calculate greatest common divisor.
inline long gcd(long a, long b) {
while (a) { const long c = a; a = b%a; b = c; }
//! Calculate greatest common divisor of two integers.
inline cimg_long gcd(cimg_long a, cimg_long b) {
while (a) { const cimg_long c = a; a = b%a; b = c; }
return b;
}

Expand Down Expand Up @@ -30524,6 +30524,15 @@ namespace cimg_library {
return (s%2)?res:(T)((res + kth_smallest((s>>1) - 1))/2);
}

//! Return greatest common diviser of all image values.
cimg_long gcd() const {
if (is_empty()) return 0;
const ulongT siz = size();
cimg_long res = (cimg_long)*data;
for (ulongT k = 1; k<siz; ++k) res = cimg::gcd(res,data[k]);
return res;
}

//! Return the product of all the pixel values.
/**
**/
Expand Down

0 comments on commit 5dfa95e

Please sign in to comment.