43 #ifndef _VARYINGLAMBDA
45 #define _VARYINGLAMBDA 0
47 #define _VARYINGLAMBDA 1
58 #define ALPHA(i) (ConstantAlpha)
59 #define DENOM_INTERIOR (DenomInterior)
60 const num ConstantAlpha = S->
Alpha;
61 const num DenomInterior = ConstantAlpha + 4;
66 #define LAMBDA_INIT Lambda = VaryingLambda
67 #define LAMBDA_STEP Lambda += Width
68 #define ALPHA(i) (Lambda[i] / Gamma)
69 #define DENOM_INTERIOR (4 + ALPHA(x))
70 const num *VaryingLambda = S->
Opt.VaryingLambda;
72 const num Gamma = S->
Opt.Gamma1;
76 const num *ztilde = S->
f;
78 const num *ztilde = (S->
UseZ) ? S->ztilde : S->
f;
81 const int Width = S->
Width;
82 const int Height = S->
Height;
87 for(k = 0; k < NumChannels; k++)
92 unew = (ALPHA(0)*ztilde[0] - dtilde[0].x - dtilde[0].y
93 + u[1] + u[Width]) / (2 + ALPHA(0));
94 Norm += (unew - u[0]) * (unew - u[0]);
98 for(x = 1; x < Width - 1; x++)
100 unew = (ALPHA(x)*ztilde[x] - dtilde[x].x + dtilde[x - 1].x
101 - dtilde[x].y + u[x - 1] + u[x + 1] + u[x + Width])
103 Norm += (unew - u[x]) * (unew - u[x]);
108 unew = (ALPHA(x)*ztilde[x] - dtilde[x].y
109 + u[x - 1] + u[x + Width]) / (2 + ALPHA(x));
110 Norm += (unew - u[x]) * (unew - u[x]);
119 for(y = 1; y < Height - 1; y++,
120 u += Width, ztilde += Width, dtilde += Width)
123 unew = (ALPHA(0)*ztilde[0] - dtilde[0].x - dtilde[0].y
124 + dtilde[-Width].y + u[1] + u[-Width] + u[Width])
126 Norm += (unew - u[0]) * (unew - u[0]);
130 for(x = 1; x < Width - 1; x++)
132 unew = (ALPHA(x)*ztilde[x] - dtilde[x].x + dtilde[x - 1].x
133 - dtilde[x].y + dtilde[x - Width].y
134 + u[x - 1] + u[x + 1] + u[x - Width] + u[x + Width])
137 Norm += (unew - u[x]) * (unew - u[x]);
142 unew = (ALPHA(x)*ztilde[x] - dtilde[x].y + dtilde[x - Width].y
143 + u[x - 1] + u[x - Width] + u[x + Width]) / (3 + ALPHA(x));
144 Norm += (unew - u[x]) * (unew - u[x]);
150 unew = (ALPHA(0)*ztilde[0] - dtilde[0].x
151 + u[1] + u[-Width]) / (2 + ALPHA(0));
152 Norm += (unew - u[0]) * (unew - u[0]);
156 for(x = 1; x < Width - 1; x++)
158 unew = (ALPHA(x)*ztilde[x] - dtilde[x].x + dtilde[x - 1].x
159 + u[x - 1] + u[x + 1] + u[x - Width]) / (3 + ALPHA(x));
160 Norm += (unew - u[x]) * (unew - u[x]);
165 unew = (ALPHA(x)*ztilde[x] + u[x - 1] + u[x - Width])
167 Norm += (unew - u[x]) * (unew - u[x]);
175 return (num)sqrt(Norm) / S->
fNorm;
176 #undef DENOM_INTERIOR
180 #undef _VARYINGLAMBDA