(* ::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["KnotTheory`QuantumKnotInvariants`",{"KnotTheory`","QuantumGroups`","QuantumGroups`Braiding`","QuantumGroups`Representations`","QuantumGroups`Utilities`DataPackage`"}];


QuantumKnotInvariant::about="Quantum knot invariants are calculated using the mathematica package QuantumGroups`, written by Scott Morrison 2003-2008.";


QuantumKnotInvariant::usage="QuantumKnotInvariant[\[CapitalGamma], V][K][q] calculates the quantum knot invariant of the knot K in the representation V of the quantum group \[CapitalGamma]. This relies on the QuantumGroups` package, and you should look there for details of how \[CapitalGamma] and V may be specified.

Examples:
   QuantumKnotInvariant[Subscript[A,2], Irrep[Subscript[A,2]][{1, 0}]][Knot[5, 2]][q]
   QuantumKnotInvariant[Subscript[G,2], Irrep[Subscript[G,2]][{1, 0}]\[CirclePlus]Irrep[Subscript[G,2]][{0, 1}]][Knot[5, 2]][q]"


PackageQuantumKnotInvariants::usage="PackageQuantumKnotInvariants[\[CapitalGamma]] saves all calculated quantum knot invariants for the quantum group K into a data file in the QuantumGroupsDataDirectory[]."


Begin["`Private`"]


q=Global`q;


Wants[x_]:=
(Off[Get::noopen];Off[Needs::nocont];Needs[x];On[Needs::nocont];On[Get::noopen];)


ExtractMatrices[indices:{__Integer},matrices_]:=Extract[matrices,indices/.{n_/;n<0:>{2,-n},n_/;n>0:>{1,n}}]


TogetherDot[x_]:=x
TogetherDot[x_,y_]:=x.y
TogetherDot[x_,y_,z__]:=TogetherDot[Together[x.y],z]


QuantumKnotInvariant[Subscript[\[CapitalGamma]_, n_],V_][K_]:=QuantumKnotInvariant[Subscript[\[CapitalGamma], n],V][K]=Module[{br=BR[K],k,data},
CreditMessage[QuantumKnotInvariant::about];
If[br===BR[1,{}],
Return[Function[{Global`q0},Evaluate[qDimension[Subscript[\[CapitalGamma], n]][V]/.q->Global`q0]]]
];
Wants["QuantumGroups`Data`"<>ToString[\[CapitalGamma]]<>ToString[n]<>"`BraidingData`"];
k=br[[1]];
data=BraidingData[Subscript[\[CapitalGamma], n]][V,k];
Function[{Global`q0},Evaluate[Expand[Together[Plus@@(#[[1]]Tr[TogetherDot@@ExtractMatrices[br[[2]],#[[2]]]]&)/@data]]/.q->Global`q0]]
]


PackageQuantumKnotInvariants[Subscript[\[CapitalGamma]_, n_]]:=PackageData[
{{QuantumKnotInvariant,HoldPattern[QuantumKnotInvariant[Subscript[\[CapitalGamma], n],_][_Knot]]}},
{ToString[\[CapitalGamma]]<>ToString[n],"QuantumKnotInvariants"},
"Needs"->{"QuantumGroups`","KnotTheory`","KnotTheory`QuantumKnotInvariants`"},
"ExtraPrivateCode"->"q0=Global`q0;","UseGzip"->False
]


End[]


EndPackage[]
