oldk1331 wrote:
>
> The default behaviour of "SquareMatrix(n, FRAC INT) * INT"
> is to treat the INT as DirectProduct and return DirectProduct:
>
> y := [[1,2],[3,4]];
>
>
> Type: List(List(PositiveInteger))
> y::SQMATRIX(2,FRAC INT)*1
>
>
> (2) [3,7]
> Type: DirectProduct(2,Fraction(Integer))
<snip>
> This problem doesn't happen for Matrix FRAC INT.
>
> I think this is a bug.
IIRC very similar problem was discussed in the past.
When types do not match exactly intepreter has to do
some coercions. Note that there is coercion from
INT (or more generally any ring R) into
direct product of R-s. Also, matrices acts on columns
and in case of SQMATRIX columns are of type DirectProduct.
Apparently interpreter decided to coerce first from Integer
to DirectProduct(2, Integer) and then from DirectProduct(2, Integer)
to DirectProduct(2, Fraction(Integer)). I am not sure why
interpreter prefered this to coercing from Integer to
Fraction(Integer) and using multiplication by scalar.
How to fix this? One way is to disable coercion from
Integer to DirectProduct. Another is to change type
of columns in SQMATRIX so to they no longer are DirectProduct-s.
Each may have unwanted consequences...
--
Waldek Hebisch