matfunc := proc (A, f) local v, x, g; options `Maple Advisor Database 1.01 for Maple V Release 5`, `Copyright (c) 1999 Robert B. Israel. All rights reserved`; if type(f,{name, procedure}) then v := traperror(f(x,args[3 .. -1])); if v = lasterror then g := proc (x) if type(x,constant) then f(args) else 'g'(args) fi end; v := g(x, args[3 .. -1]) elif type(v,constant) then RETURN(linalg['diag'](`$`(v,linalg[' rowdim'](A)))) fi else v := f; x := remove(type,indets(f,name),constant); if nops(x) = 1 then x := op(x) else ERROR( "must have only one variable but received",f) fi fi; subs(linalg[''eigenvals'' ] = `matfunc/eigenvals`,readlib(`linalg/matfunc`))(A,v,x) end; `matfunc/eigenvals` := proc (A) local r; options `Maple Advisor Database 1.01 for Maple V Release 5`, `Copyright (c) 1999 Robert B. Israel. All rights reserved`; r := [linalg[' eigenvals'](A,implicit)]; op(map(proc (t) if type(t,RootOf) and type(op(1,t), quadratic(_Z)) then solve(op(1,t),_Z) else t fi end,r)) end;