Question: How to evaluate an expression using the command eval ?

Hello everybody,

In my code, i would like to create a square matrix M of dimension 'a' (which is a ColumnDimension of an imput matrix A):
Otherwise, i have an expression ('EXPR') on alpha[i](x) and beta[i](x), i=1..b, (where b is a ColumnDimension of an imput matrix B).
The matrix M that i want to get must be M:=(EXPR(alpha[i],beta[j])),i,j=1..a, evaluated for particular alpha[i](x) and beta[j](x) wich are stored in A and B respectively.

Below, is the code that i write: 

Test := proc(A, B,EXPR)
local a, b, M, i, j, k;
a := LinearAlgebra['ColumnDimension'](A);
b := LinearAlgebra['ColumnDimension'](B);
M := Matrix(a);
for i to a do for j to a do
if evalb(i = j) then
M[i, j] := M[i, j] + eval(EXPR, {seq(alpha[k] = (t -> eval(A[k, i], x = t)), k = 1 .. b), seq(beta[k] = (t -> eval(B[j, k], x = t)), k = 1 .. b)}); else
if evalb(i < j) then
M[i, j] := M[i, j] + eval(EXPR, {seq(alpha[k] = (t -> eval(A[k, j], x = t)), k = 1 .. b), seq(beta[k] = (t -> eval(B[i,K], x = t)), k = 1 .. b)}); else
M[i, j] := M[i, j] + eval(EXPR, {seq(alpha[k] = (t -> eval(A[k, j], x = t)), k = 1 .. b), seq(beta[k] = (t -> eval(B[i, k], x = t)), k = 1 .. b)}); end if;
end if;
end do;
end do;
return M;
end proc:

I tested the program for A, B and EXPR given by: 
A := Matrix(2, 3, [[4, x, 1/4*x^2], [2, 3, x]]);
B := Matrix(3, 2, [[3, 5], [x, 2], [1/2*x^2, -x]]);
EXPR := alpha[1](1/2)*beta[1](1/2) + int(alpha[1](x + 1/2)*beta[2](1/2*x), x = -1/2 .. 1/2) + alpha[2](1/2)*beta[2](1/2);

Maple returns the following:  Error, (in anonymous procedure called from Test) bad index into Matrix.
I understood that the problem comes from the k that I wrote in bold in the code.
I would like to evaluate the EXPR for alpha[k]:=A[k, i] and beta[k]:=B[j,k] , but I don't really know how to interpret this for maple.

Could you help me please ?
Do you have an idea ?

Best regards,

Please Wait...