It appears I have to take all my integers in an array and put either a .0 or at least . after the number. For instance
var d = Matrix([3.0 , 7, 4.3], [4.7 , 9, 22.8]);
> pginsert.chpl:29: error: Array literal element 2 expected to be of type real(64) but is of type int(64)
I think Chapel arrays assume reals, so why not just take that 7 at 7.0?
An even more distilled example of this:
var A = [1, 2.0];
> chpl a.chpl
a.chpl:1: error: Array literal element 2 expected to be of type int(64) but is of type real(64)
it's like your shooting for the "everclear of array examples". Gotta have goals in life.
I think Chapel arrays assume reals
To help prevent the spread of misinformation: this statement isn't accurate鈥擟hapel arrays can be of any type and no assumption is made about what the type is when looking at an array literal.
That said, the request is completely reasonable and appropriate. I'd describe it as: Try to find a unified "most general type" for all array elements, similar to how we do so for return statements that return different types:
config var flag = true;
proc foo() {
if flag then
return 1;
else
return 2.3;
}
var a = foo();
writeln(a.type:string);
I believe what @buddha314 meant was that LinearAlgebra.Matrix() assumes eltType=real when no eltType argument is specified.
Most helpful comment
To help prevent the spread of misinformation: this statement isn't accurate鈥擟hapel arrays can be of any type and no assumption is made about what the type is when looking at an array literal.
That said, the request is completely reasonable and appropriate. I'd describe it as: Try to find a unified "most general type" for all array elements, similar to how we do so for
returnstatements that return different types: