It would be nice to know my mistake in the below:
With 1.22, the following does not compile when I pass a vector expression
to the to the little routine _5tuple.
// ?R is some real(?w) floating point number
// returns a 5-tuple if given a 5-element 1D array
inline proc _5tuple(const in t : [?tD] ?R)
{
return (t[0], t[1], t[2], t[3], t[4]);
}
// shift from bottom 2x2 minor - Golub+Reinsch but scaled as per LINPACK
inline proc shift(j : int, k : int, ref e : [?D] ?R, ref q : [D] R)
{
const qe = [ q[j], q[k - 1], q[k], e[k - 1], e[k] ];
// const qeNormalized = qe / (max reduce abs(qe));
const (_x, _y, _z, _g, _h) = _5tuple(qe);
const (x, y, z, g, h) = _5tuple(qe / (max reduce abs(qe)));
const t = (half * ((y - z) * (y + z) + (g - h) * (g + h))) / (h * y);
const s = sqrt(t * t + one);
const f = if t < zero then t - s else t + s;
:
return (_x, ((_x + _z) * (x - z) + _h * ((y / f) - h)) / x);
}
The compiler tells me:
sa.chpl:13: In function 'svd':
sa.chpl:32: error: unresolved call '_5tuple(promoted expression)'
sa.chpl:20: note: this candidate did not match: _5tuple(t: [])
sa.chpl:32: note: because call actual argument #1 with type iterator
sa.chpl:20: note: is passed to formal 'const in t: []'
sa.chpl:410: Function 'svd' instantiated as: svd(a: [domain(2,int(64),false)]
real(64), w: [domain(1,int(64),false)] real(64), v: [domain(2,int(64),false)]
real(64))
Why does it consider that I am sending a promoted expression? An expression
yes. But promoted? The expression is the normalization of a 5-element vector
and yields a 5-element array. No promotion involved.
If I normalize that array myself into another constant 5-slement array, it
works. For example
// shift from bottom 2x2 minor - Golub+Reinsch but scaled as per LINPACK
inline proc shift(j : int, k : int, ref e : [?D] ?R, ref q : [D] R)
{
const qe = [ q[j], q[k - 1], q[k], e[k - 1], e[k] ];
const qeNormalized = qe / (max reduce abs(qe));
const (_x, _y, _z, _g, _h) = _5tuple(qe);
const (x, y, z, g, h) = _5tuple(qeNormalized);
const t = (half * ((y - z) * (y + z) + (g - h) * (g + h))) / (h * y);
const s = sqrt(t * t + one);
const f = if t < zero then t - s else t + s;
return (_x, ((_x + _z) * (x - z) + _h * ((y / f) - h)) / x);
}
I can live with this but it seems like array algebra expressions cannot
appear in parameter lists.
Or is my problem that there are generic arguments?
Or is my problem just me?
I can send the complete code if needed.
Thanks - Damian
Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers