1
function [flag]=%choose(x)
2
// Utility function for use with schur
3
// [U,dim]=schur(A,choose) returns orth. basis
4
// for eigenspace associated to selected polynomials
5
//Needs two global variables :
6
// %sel = list of selected polynomials (user defined)
7
// eps = threshold for polynomials selection (eps= 0.0001 as default value)
11
// chis=poly(A,'s'); //Characteristic polynomial
12
// w=factors(chis); //Factors of chis in a list
13
// %sel=list(w(2),w(3)); // two selected polynomials
14
// eps=0.01; //Threshold (see almosteq below)
15
// [U,dim]=schur(A,%choose); //Ordered Schur form
16
// U1=U(:,1:dim);chi1=poly(U1'*A*U1,'s') //Check
17
// w1=factors(chi1) // w1 = %sel ?
20
eps=0.0001; //modify eps here !
22
ls=x(1);flag=0;s=poly(0,'s');
25
// ASSUME x(3) NOT ZERO (for gev pb. x(3)=0 => eval @ infty)
26
vp=x(2)/x(3);pol=s-vp; //disp(pol);
27
for p=%sel; if almosteq(pol,p,eps) then flag=1;end;end
29
pol=s^2-x(2)*s+x(3); //disp(pol);
30
for p=%sel; if almosteq(pol,p,eps) then flag=1;end;end
33
function trfa=almosteq(pol,p,eps)
34
// returns %T if pol ~ p %F if not
35
if degree(pol)<>degree(p) then trfa=%F;return;end
36
if norm((coeff(p)-coeff(pol)),1)<=eps then trfa=%T;return;end