rref(a):=block([p,q,k],[p,q]:matrix_size(a),a:echelon(a),
    k:min(p,q),
    for i thru min(p,q) do (if a[i,i]=0 then (k:i-1,return())),
    for i:k thru 2 step -1 do (for j from i-1 thru 1 step -1 do a:rowop(a,j,i,a[j,i])),
    a)$

rref(A|B),
change of basis matrices

a1:[1,0,1]$
a2:[2,1,3]$
A:transpose(matrix(a1,a2))$
b1:[2,0,2]$
b2:[3,1,4]$
B:transpose(matrix(b1,b2))$
transpose(matrix(a1,a2,b1,b2));
rref(%);
S:submatrix(3,%,1,2);
S^^-1;

Check

A.S;
B.(S^^-1);