(* HookPsts.nb ---------------------------------------------------------- *)

(* Reads in polynomials WP(x) for the posets P and writes out the posets
	P which have the hook length property.  Writes out their hook lengths
	tp a parallel file. *)

(* Utility Needed: WriteLstOfLst[]. *)
(* Function Needed: HookQ[]. *)

(* User needs to specify the directory, the poset size, an input family
	of posets, and the file containing the coefficients of WP(x) for every
	poset P in that file.  The user must also specify two output file 
	families: one for the hook length posets and one for their corresponding
	hook lengths. *)

(* Change the directory: *)
SetDirectory["J:/isis/home/c/a/cagann/public_html/Posets"];
<< GenrlUtils.m;    << HookUtils.m; 

stmem = MaxMemoryUsed[]; sttim = AbsoluteTime[]; stcpu = TimeUsed[];

(* Change poset size: *)  psiz = 8;

(* Change Poset input file family: *)   infam1 = "IDHLcan/idhlcan";
(* Change WP(x) input file family: *)  infam2 = "IDHLCWP/idhlcwp";
(* Change Poset output file family: *)  outfam1 = "IDHLPos/idhlpos";
(* Change Hook length output family: *) outfam2 = "IDHLPhl/idhlphl";

(* Apply HookQ[] to each WP(x) in the input file. *)
hookrslts = Map[ 
	HookQ[psiz,#]&, 
	ReadList[StringJoin[infam2,ToString[psiz]]]
];

(* Find the positions of the hook length posets. *)
hlplocats = Most[ Position[ hookrslts, {__}] ];

(* Pick out the hook length posets from the input file and form the list
	of their corresponding hook lengths. *)
hlplist = Extract[ ReadList[StringJoin[infam1,ToString[psiz]]], hlplocats ];
hlphooks = Extract[ hookrslts, hlplocats ];

WriteLstOfLst[ StringJoin[outfam1,ToString[psiz]], hlplist ];
WriteLstOfLst[ StringJoin[outfam2,ToString[psiz]], hlphooks ];	

emem = MaxMemoryUsed[]; etim = AbsoluteTime[]; ecpu = TimeUsed[];
PrntCnsmptn[stmem,emem,sttim,etim,stcpu,ecpu];

(* End of HookPsts.nb. *)