#52.maple
#
# Frank Sottile
# 27 October 1998
# Berkeley, CA
#
#   Testing instances of Shapiro's Totally Positive conjecture
# for the case of 6 2-planes in C^7 meeting 5 4-planes non-trivially.
#
# Number  Seed                    Time       Size   
#  200     1      Make systems  156.990     648194   \
#                 Eliminants    209         190062    > Schur
#                 Real roots     20                  /
# 2800   123      Make systems 14309.18    9054899   \
#                 Eliminants   10087       2653975    > Schubert
#                 Real roots    1864.130             /
#
# 1000   1212     Make systems  5190.539   3235288   \
#                 Eliminants    4106        947026    > Schubert
#                 Real roots     644.120             /
#

interface(quiet=true):
with(linalg):
_seed:=1212:
die:=rand(1..10):

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

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

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

COLS:=[[1,2,3,4,5,6],[1,2,3,4,5,7],[1,2,3,4,6,7],
[1,2,3,5,6,7],[1,2,4,5,6,7],[1,3,4,5,6,7],[2,3,4,5,6,7]]:

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

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

#############################################################################
#
#
#lprint(`timer = 1;`);
lprint(`option(redSB);`);
lprint(`int t=timer;`);
lprint(`ring R= 0, (a,b,c,d,e,f), (dp(5),dp(1));`);
lprint(`ideal I;`);
lprint(`ideal G;`);

lprint(`print("interface(quiet=true):");`);
lprint(`print("readlib(realroot):");`);


for ntrials from 1 to 1000 do

SEED:=_seed:

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

 lprint(`I=`);

 for j from 1 to 3 do
   M:=stackmatrix(submatrix(M.j,[1,2,3,4],[1,2,3,4,5,6,7]),Coords):
  for Col in COLS do
  lprint(det(submatrix(M,[1,2,3,4,5,6],Col)),`,`);:
 od: od:
 lprint(`0;`);

 lprint(`G = std(I);`);
 lprint(`print("POLY:=");`);
 lprint(`short=0;`);
 lprint(`G[1];`);
 lprint(`print(":");`);
 lprint(`print("NREAL:= nops(realroot(POLY, 1/100)): ");`);
 lprint(`print(" if NREAL<6 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;
