(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



BeginPackage["QuantumGroups`QuantumRoots`",{"QuantumGroups`","QuantumGroups`Utilities`Debugging`","QuantumGroups`MatrixPresentations`","QuantumGroups`Algebra`","QuantumGroups`RootSystems`","QuantumGroups`Representations`","QuantumGroups`BraidAction`","QuantumGroups`WeylGroups`"}];


ExpandQuantumRoot::usage="";


QuantumPositiveRoots::usage="";


QuantumNegativeRoots::usage="";


QuantumRootHeight::usage="";


Begin["`Private`"];


q=Global`q;


LoadQuantumRoots[Subscript[\[CapitalGamma]_, n_]]:=Module[{},
Off[Get::noopen,Needs::nocont];
Needs["QuantumGroups`Data`"<>SymbolName[\[CapitalGamma]]<>ToString[n]<>"`QuantumRoots`"];
On[Get::noopen,Needs::nocont];
LoadQuantumRoots[Subscript[\[CapitalGamma], n]]=False;
True
]


ExpandQuantumRoot[\[CapitalGamma]_][SuperPlus[Subscript[X, \[CapitalGamma]_,r_]]]/;MemberQ[SimpleRoots[\[CapitalGamma]],PositiveRoots[\[CapitalGamma]][[r]]]:=SuperPlus[Subscript[X, Position[SimpleRoots[\[CapitalGamma]],PositiveRoots[\[CapitalGamma]][[r]]][[1,1]]]]
ExpandQuantumRoot[\[CapitalGamma]_][SuperPlus[Subscript[X, \[CapitalGamma]_,r_]]]:=ExpandQuantumRoot[\[CapitalGamma]][SuperPlus[Subscript[X, \[CapitalGamma],r]]]=
If[LoadQuantumRoots[\[CapitalGamma]],ExpandQuantumRoot[\[CapitalGamma]][SuperPlus[Subscript[X, \[CapitalGamma],r]]],
With[{i=LongestWordDecomposition[\[CapitalGamma]]},
DebugPrintHeld["Calculating ",ExpandQuantumRoot[\[CapitalGamma]][SuperPlus[Subscript[X, \[CapitalGamma],r]]]];
BraidAction[\[CapitalGamma]][Subscript[T, #]&/@Take[i,r-1],SuperPlus[Subscript[X, i[[r]]]]]
]
]


ExpandQuantumRoot[\[CapitalGamma]_][SuperMinus[Subscript[X, \[CapitalGamma]_,r_]]]:=ExpandQuantumRoot[\[CapitalGamma]][SuperPlus[Subscript[X, \[CapitalGamma],r]]]/.q->q^-1/.{SuperPlus[Subscript[X, i_]]:>SuperMinus[Subscript[X, i]]}/.Z_NonCommutativeMultiply:>Reverse[Z]


\[CapitalDelta][A:(SuperPlus[Subscript[X, \[CapitalGamma]_,r_]]|SuperMinus[Subscript[X, \[CapitalGamma]_,r_]])]:=\[CapitalDelta][ExpandQuantumRoot[\[CapitalGamma]][A]]


OperatorWeight[\[CapitalGamma]_][SuperPlus[Subscript[X, \[CapitalGamma]_,r_]]]:=PositiveRoots[\[CapitalGamma]][[r]]
OperatorWeight[\[CapitalGamma]_][SuperMinus[Subscript[X, \[CapitalGamma]_,r_]]]:=-PositiveRoots[\[CapitalGamma]][[r]]


QuantumPositiveRoots[\[CapitalGamma]_]:=Table[SuperPlus[Subscript[X, \[CapitalGamma],i]],{i,1,Length[LongestWordDecomposition[\[CapitalGamma]]]}]
QuantumNegativeRoots[\[CapitalGamma]_]:=Table[SuperMinus[Subscript[X, \[CapitalGamma],i]],{i,1,Length[LongestWordDecomposition[\[CapitalGamma]]]}]


MatrixPresentation[\[CapitalGamma]_][A:(SuperPlus[Subscript[X, \[CapitalGamma]_,r_]]|SuperMinus[Subscript[X, \[CapitalGamma]_,r_]])][V_,\[Beta]_,\[Lambda]_]:=MatrixPresentation[\[CapitalGamma]][A][V,\[Beta],\[Lambda]]=MatrixPresentation[\[CapitalGamma]][ExpandQuantumRoot[\[CapitalGamma]][A]][V,\[Beta],\[Lambda]]


QuantumRootHeight[\[CapitalGamma]_][SuperPlus[Subscript[X, \[CapitalGamma]_,r_]]|SuperMinus[Subscript[X, \[CapitalGamma]_,r_]]]:=Plus@@(PositiveRoots[\[CapitalGamma]][[r]].Inverse[SimpleRoots[\[CapitalGamma]]])


End[];


EndPackage[];
