Hi all, I'm scratching my head over the logic behind Maple's (I'm using version 10) overloaded operators. Consider the code attached below, it is a verbatim copy of the operator overloading example from the Maple online help. Using this example, it calculates the product of two quaternions, which yields the correct result, and then the dot product of two quaternion-valued 'LinearAlgebra,Vector's -- resulting in the unevaluated product of two quaternions, in the wrong order to boot: ``` > a := Quaternion(0,1,0,0): > b := Quaternion(0,0,1,0): > > A := Transpose(Vector([a])): > B := Vector([b]): > > > lprint(a*b): QUATERNION(0,0,0,1) > lprint(b*a): QUATERNION(0,0,0,-1) > > lprint(A . B); QUATERNION(0,0,1,0)*QUATERNION(0,1,0,0) ``` What do I have to do to have the overloaded `*` rule correctly applied to the result? I have played around with 'eval', 'simplify', 'unprotect', and 'use' to no avail. Any help would be greatly appreciated. Andreas ```Quaternion := module() export `?[]`, `*`, `+`, `-`: local `?[assign]`, `?[select]`, ModuleLoad, ModuleApply: ModuleApply := proc( h, i, j, k ) QUATERNION(h,i,j,k); end proc: ModuleLoad := proc() global `print/QUATERNION`; `print/QUATERNION` := proc(h,i,j,k) h + `i `*i + `j `*j + `k `*k; end proc: TypeTools[AddType]( tQuaternion, t->evalb(op(0,t) = 'QUATERNION')\ ); end proc: ModuleLoad(); `+` := proc(a::tQuaternion, b::tQuaternion) option overload: QUATERNION(op(1,a)+op(1,b), op(2,a)+op(2,b), op(3,a)+op(3,b), op(4,a)+op(4,b)); end proc; `-` := proc(a::tQuaternion) option overload: QUATERNION(-op(1,a), -op(2,a), -op(3,a), -op(4,a)); end proc; `*` := proc(a::tQuaternion, b::tQuaternion) option overload: local A, B; A := [op(a)]: B := [op(b)]: QUATERNION(A[1]*B[1] - A[2]*B[2] - A[3]*B[3] - A[4]*B[4], A[1]*B[2] + A[2]*B[1] + A[3]*B[4] - A[4]*B[3], A[1]*B[3] - A[2]*B[4] + A[3]*B[1] + A[4]*B[2], A[1]*B[4] + A[2]*B[3] - A[3]*B[2] + A[4]*B[1]); end proc; `?[]` := proc(q::uneval, index::[{1,2,3,4}], val) option overload: if nargs = 2 then `?[select]`(eval(q),op(index)); else `?[assign]`(q,eval(q),op(index),op(val)); end if; end proc: `?[select]` := proc(q::tQuaternion, index::{1,2,3,4} ) op(index, q) end proc: `?[assign]` := proc(var::uneval, q::tQuaternion, index::{1,2,3,4}, val::integer ) var := subsop(index = val, q); end proc: end module: with(Quaternion): with(LinearAlgebra): a := Quaternion(0,1,0,0): b := Quaternion(0,0,1,0): A := Transpose(Vector([a])): B := Vector([b]): lprint(a*b): lprint(b*a): lprint(A . B); ```