Question: Unexpected behaviour with chrem and vectors.

I wrote some code involving chrem that broke in a recent version.

> y := Vector([0]):
> yp := Vector([1]):
> trace(chrem);
> chrem( [y, yp], [1,3] );
{--> enter chrem, args = [Vector(1, [...], datatype = anything), Vector(1, [...], 
datatype = anything)], [1, 3]
n := 2

v, m := [0], 1

v := 0

u, p := [1], 3

i := 1

Error, (in rtable/Sum) invalid arguments

It seems I was passing Vectors to chrem when only lists are allowed. The code for chrem is:

proc(U::list, M::list(posint))
local v, m, u, p, delta, i, k, n;
option `Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2005`;
    n := nops(U);
    if n <> nops(M) then
        error "list of images and list of moduli must be the same length"
    end if;
    v, m := U[1] mod M[1], M[1];
    if m = 1 then v := 0 end if;
    for k from 2 to n do
        u, p := U[k], M[k];
        if p = 1 then next end if;
        try i := modp(1/m, p)
        catch: error "the moduli must be pairwise relatively prime"
        end try;
        delta := i*modp(u - v, p) mod p;
        v, m := v + delta*m, p*m
end do;
v
end proc

 

However the problem seems to be that U[1] is evaluating to [0] = y instead of 0 (ditto for M).

My questions are these:

  1. Why is this happening?
  2. If chrem is type-checking for lists why isn't it throwing an "Invalid input error" (as it would if I did:
        proc(U::list) local x; x := U[1] end proc
    ).
  3. Why shouldn't I be able to do chrem on Vectors?
Please Wait...