ref: b53bbd5a75d2682dc6606269714bec8f8d9d9796
parent: 6bf0a834bc0b9a179a63eab0f603db232227da42
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Jul 11 16:01:00 EDT 2024
raster: don't compute coefficients from K and L if they are all zero
--- a/rast.c
+++ b/rast.c
@@ -299,11 +299,12 @@
else
f = qKL;
+ z = 0;
if(tx₀ == 0){
- f(s, jj, px+0, py+0, K[0], L[0]);
- f(s, jj, px+0, py+1, K[1], L[1]);
- f(s, jj, px+1, py+0, K[2], L[2]);
- f(s, jj, px+1, py+1, K[3], L[3]);
+ z |= f(s, jj, px+0, py+0, K[0], L[0]);
+ z |= f(s, jj, px+0, py+1, K[1], L[1]);
+ z |= f(s, jj, px+1, py+0, K[2], L[2]);
+ z |= f(s, jj, px+1, py+1, K[3], L[3]);
}else{
z = 0;
if(f(s, jj, px+0, py+0, K[0], L[0]))
@@ -318,9 +319,11 @@
all |= z;
}
- c[0] += L[0][1] + L[2][1] + K[1][1] - L[1][1] + K[3][1] - L[3][1];
- c[1] += L[0][0] + L[1][0] + K[2][0] - L[2][0] + K[3][0] - L[3][0];
- c[2] += L[0][0] - L[1][0] + K[2][0] - L[2][0] - K[3][0] + L[3][0];
+ if(z != 0){
+ c[0] += L[0][1] + L[2][1] + K[1][1] - L[1][1] + K[3][1] - L[3][1];
+ c[1] += L[0][0] + L[1][0] + K[2][0] - L[2][0] + K[3][0] - L[3][0];
+ c[2] += L[0][0] - L[1][0] + K[2][0] - L[2][0] - K[3][0] + L[3][0];
+ }
}
return all;
}