/*
** BUG: ∇ doesn't seem to work on 1D fields;
** compiling with: ../../bin/diderotc --exec bug053.diderot
** generates:
***** Internal error after translation to MidIL: see log file for details
which is due to the "∇F(pos1);" line. If that line is commented out,
the following "∇⊗∇F(pos1)" line causes this error:
[bug053.diderot:24.15-25] Error: type error for unary operator "'∇⊗'"
expected: field#1(1)'shp0108;'dim0107
but found: field#1(1)[]
[bug053.diderot:10.1-30.0] Error: program does not have any strands
Which raises the question: what is the correct way to express the
second (or higher) derivative of a 1D field?
*/
field#2(2)[] G = image("../data/data2D.nrrd") ⊛ bspln3;
field#2(1)[] F = image("../data/data1D.nrrd") ⊛ bspln3;
strand foo (int xi, int yi) {
real xx = lerp(5, 25, 0, xi, 2);
real yy = lerp(5, 25, 0, yi, 2);
vec2 pos2 = [xx,yy];
real pos1 = xx;
output real out = 0;
update {
out += |∇G(pos2)|;
out += |∇⊗∇G(pos2)|;
out += ∇F(pos1); // how should 1st deriv be expressed for 1D fields?
out += ∇∇F(pos1); // how should 2nd deriv be expressed for 1D fields?
// out += ∇⊗∇F(pos1); // should this form be allowed?
stabilize;
}
}
initially [ foo(xi, yi) | yi in 0..2, xi in 0..2 ];