#42.maple
#
# Frank Sottile
# 10 October 1998
# Berkeley, CA
#
#	Testing instances of Shapiro's Totally Posaitive conjecture
#
#    1500 instances with initial seed = 1
#      Creation of Singular file took 1913.990 seconds
#	            and it had size 2043175 Bytes
#      Computation of eliminants took Singular 34548 seconds
#		    and created a Maple input file of size 4649062
#      Checking that each instance had 14 roots took   59716.620 seconds

#
#
#

interface(quiet=true):
with(linalg):
with(Groebner):
die:=rand(1..5):
readlib(realroot):

ELM:=proc(X,Y,Z,W,S)
matrix([
[1,X,0,0,0,0],
[0,1,Y,0,0,0],
[0,0,1,Z,0,0],
[0,0,0,1,W,0],
[0,0,0,0,1,S],
[0,0,0,0,0,1]])
end:

Pos:=proc(a1,b1,b2,c1,c2,c3,d1,d2,d3,d4,e1,e2,e3,e4,e5)		
multiply(ELM(a1,0,0,0,0),ELM(b1,b2,0,0,0),ELM(c1,c2,c3,0,0),
	ELM(d1,d2,d3,d4,0),ELM(e1,e2,e3,e4,e5))
end:				

Coords:=matrix([
	[1,a,b,c,0,0],
	[0,0,1,d,e,f]]):

M.0:=band([1],6):

ST_Nreal:="lprint(`realroots = `,NREAL,`seed = `,":
ST_end:=");":

#############################################################################
#
#
#

#lprint(`timer = 1;`);
lprint(`int t=timer;`);
lprint(`ring R= 0, (a,b,c,d,e,f), (dp(5),dp(1));`);
lprint(`short=0;`);
lprint(`print("interface(quiet=true):");`);
lprint(`print("readlib(realroot):");`);
lprint(`ideal I=0;`);
lprint(`ideal G=0;`);


for ntrials from 1 to 1500 do

 lprint(`I = `);

SEED:=_seed:

 for j from 1 to 6 do
  Params:=[]:
  for i from 1 to 15 do Params:=[Params[],die()]: od:
  M.j:=multiply(Pos(Params[]),M.(j-1));
 od:

 for j from 1 to 6 do
  F.j:=det(stackmatrix(submatrix(M.j,[1,2,3,4],[1,2,3,4,5,6]),Coords)):
 od:

 lprint(F1,`,`);
 lprint(F2,`,`);
 lprint(F3,`,`);
 lprint(F4,`,`);
 lprint(F5,`,`);
 lprint(F6,`;`);


 lprint(`G = std(I);`);
 lprint(`print("POLY:=");`);
 lprint(`G[1];`);
 lprint(`print(":");`);
 lprint(`print("NREAL:= nops(realroot(POLY, 1/100)): ");`);
 lprint(`print(" if NREAL<14 then");`);
 lprint(`print("`,convert(ST_Nreal,symbol));
 lprint(convert(SEED,symbol));
 lprint(convert(ST_end,symbol),` ");`);
 lprint(`print("fi: ");`);
 lprint(`print(" ");`);
 lprint(`print(" ");`);
 lprint(`print("############################################################");`);
 lprint(`print("#                                                          #");`);
 lprint(`print("#          Next One                                        #");`);
 lprint(`print("#                                                          #");`);
 lprint(`print("############################################################");`);
 lprint(`print(" ");`);
od:

lprint(`print("time(); ");`);
lprint(`print("quit; ");`);
lprint(`timer-t;`);
lprint(`quit;`);

time();

quit;
