%%
%% This is file `PJLmath.sty',
%% generated with the docstrip utility.

%% Copyright (C) 2021 by Jinwen XU
%% 
%% This is part of the ProjLib Toolkit.
%% 
%% This work may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License, either version 1.3c of this license or (at
%% your option) any later version. The latest version of this license is in
%% 
%%     http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3c or later is part of all distributions of LaTeX version
%% 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[2020-10-01]
\ProvidesPackage{PJLmath}
    [2021/07/30 Useful math macros and shortcuts]
\RequirePackage{kvoptions}
\RequirePackage{etoolbox}
\RequirePackage{mathtools}
\RequirePackage{mathrsfs}
\@ifpackageloaded{unicode-math}{}{\RequirePackage{amssymb}}

%%================================
%% Shorthands
%%================================
\providecommand{\N}{\ensuremath{\mathbb{N}}}
\providecommand{\Z}{\ensuremath{\mathbb{Z}}}
\providecommand{\Q}{\ensuremath{\mathbb{Q}}}
\providecommand{\R}{\ensuremath{\mathbb{R}}}
\providecommand{\C}{\ensuremath{\mathbb{C}}}
\providecommand{\F}{\ensuremath{\mathbb{F}}}
\providecommand{\A}{\ensuremath{\mathbb{A}}}

\providecommand{\bb}[1]{\ensuremath{\mathbb{#1}}}
\providecommand{\bbA}{\ensuremath{\mathbb{A}}}
\providecommand{\bbB}{\ensuremath{\mathbb{B}}}
\providecommand{\bbC}{\ensuremath{\mathbb{C}}}
\providecommand{\bbD}{\ensuremath{\mathbb{D}}}
\providecommand{\bbE}{\ensuremath{\mathbb{E}}}
\providecommand{\bbF}{\ensuremath{\mathbb{F}}}
\providecommand{\bbG}{\ensuremath{\mathbb{G}}}
\providecommand{\bbH}{\ensuremath{\mathbb{H}}}
\providecommand{\bbI}{\ensuremath{\mathbb{I}}}
\providecommand{\bbJ}{\ensuremath{\mathbb{J}}}
\providecommand{\bbK}{\ensuremath{\mathbb{K}}}
\providecommand{\bbL}{\ensuremath{\mathbb{L}}}
\providecommand{\bbM}{\ensuremath{\mathbb{M}}}
\providecommand{\bbN}{\ensuremath{\mathbb{N}}}
\providecommand{\bbO}{\ensuremath{\mathbb{O}}}
\providecommand{\bbP}{\ensuremath{\mathbb{P}}}
\providecommand{\bbQ}{\ensuremath{\mathbb{Q}}}
\providecommand{\bbR}{\ensuremath{\mathbb{R}}}
\providecommand{\bbS}{\ensuremath{\mathbb{S}}}
\providecommand{\bbT}{\ensuremath{\mathbb{T}}}
\providecommand{\bbU}{\ensuremath{\mathbb{U}}}
\providecommand{\bbV}{\ensuremath{\mathbb{V}}}
\providecommand{\bbW}{\ensuremath{\mathbb{W}}}
\providecommand{\bbX}{\ensuremath{\mathbb{X}}}
\providecommand{\bbY}{\ensuremath{\mathbb{Y}}}
\providecommand{\bbZ}{\ensuremath{\mathbb{Z}}}

\providecommand{\mc}[1]{\ensuremath{\mathcal{#1}}}
\providecommand{\mcA}{\ensuremath{\mathcal{A}}}
\providecommand{\mcB}{\ensuremath{\mathcal{B}}}
\providecommand{\mcC}{\ensuremath{\mathcal{C}}}
\providecommand{\mcD}{\ensuremath{\mathcal{D}}}
\providecommand{\mcE}{\ensuremath{\mathcal{E}}}
\providecommand{\mcF}{\ensuremath{\mathcal{F}}}
\providecommand{\mcG}{\ensuremath{\mathcal{G}}}
\providecommand{\mcH}{\ensuremath{\mathcal{H}}}
\providecommand{\mcI}{\ensuremath{\mathcal{I}}}
\providecommand{\mcJ}{\ensuremath{\mathcal{J}}}
\providecommand{\mcK}{\ensuremath{\mathcal{K}}}
\providecommand{\mcL}{\ensuremath{\mathcal{L}}}
\providecommand{\mcM}{\ensuremath{\mathcal{M}}}
\providecommand{\mcN}{\ensuremath{\mathcal{N}}}
\providecommand{\mcO}{\ensuremath{\mathcal{O}}}
\providecommand{\mcP}{\ensuremath{\mathcal{P}}}
\providecommand{\mcQ}{\ensuremath{\mathcal{Q}}}
\providecommand{\mcR}{\ensuremath{\mathcal{R}}}
\providecommand{\mcS}{\ensuremath{\mathcal{S}}}
\providecommand{\mcT}{\ensuremath{\mathcal{T}}}
\providecommand{\mcU}{\ensuremath{\mathcal{U}}}
\providecommand{\mcV}{\ensuremath{\mathcal{V}}}
\providecommand{\mcW}{\ensuremath{\mathcal{W}}}
\providecommand{\mcX}{\ensuremath{\mathcal{X}}}
\providecommand{\mcY}{\ensuremath{\mathcal{Y}}}
\providecommand{\mcZ}{\ensuremath{\mathcal{Z}}}

\providecommand{\cal}[1]{\ensuremath{\mathcal{#1}}}
\providecommand{\calA}{\ensuremath{\mathcal{A}}}
\providecommand{\calB}{\ensuremath{\mathcal{B}}}
\providecommand{\calC}{\ensuremath{\mathcal{C}}}
\providecommand{\calD}{\ensuremath{\mathcal{D}}}
\providecommand{\calE}{\ensuremath{\mathcal{E}}}
\providecommand{\calF}{\ensuremath{\mathcal{F}}}
\providecommand{\calG}{\ensuremath{\mathcal{G}}}
\providecommand{\calH}{\ensuremath{\mathcal{H}}}
\providecommand{\calI}{\ensuremath{\mathcal{I}}}
\providecommand{\calJ}{\ensuremath{\mathcal{J}}}
\providecommand{\calK}{\ensuremath{\mathcal{K}}}
\providecommand{\calL}{\ensuremath{\mathcal{L}}}
\providecommand{\calM}{\ensuremath{\mathcal{M}}}
\providecommand{\calN}{\ensuremath{\mathcal{N}}}
\providecommand{\calO}{\ensuremath{\mathcal{O}}}
\providecommand{\calP}{\ensuremath{\mathcal{P}}}
\providecommand{\calQ}{\ensuremath{\mathcal{Q}}}
\providecommand{\calR}{\ensuremath{\mathcal{R}}}
\providecommand{\calS}{\ensuremath{\mathcal{S}}}
\providecommand{\calT}{\ensuremath{\mathcal{T}}}
\providecommand{\calU}{\ensuremath{\mathcal{U}}}
\providecommand{\calV}{\ensuremath{\mathcal{V}}}
\providecommand{\calW}{\ensuremath{\mathcal{W}}}
\providecommand{\calX}{\ensuremath{\mathcal{X}}}
\providecommand{\calY}{\ensuremath{\mathcal{Y}}}
\providecommand{\calZ}{\ensuremath{\mathcal{Z}}}

\providecommand{\mf}[1]{\ensuremath{\mathfrak{#1}}}
\providecommand{\mfa}{\ensuremath{\mathfrak{a}}}
\providecommand{\mfb}{\ensuremath{\mathfrak{b}}}
\providecommand{\mfc}{\ensuremath{\mathfrak{c}}}
\providecommand{\mfd}{\ensuremath{\mathfrak{d}}}
\providecommand{\mfe}{\ensuremath{\mathfrak{e}}}
\providecommand{\mff}{\ensuremath{\mathfrak{f}}}
\providecommand{\mfg}{\ensuremath{\mathfrak{g}}}
\providecommand{\mfh}{\ensuremath{\mathfrak{h}}}
\providecommand{\mfi}{\ensuremath{\mathfrak{i}}}
\providecommand{\mfj}{\ensuremath{\mathfrak{j}}}
\providecommand{\mfk}{\ensuremath{\mathfrak{k}}}
\providecommand{\mfl}{\ensuremath{\mathfrak{l}}}
\providecommand{\mfm}{\ensuremath{\mathfrak{m}}}
\providecommand{\mfn}{\ensuremath{\mathfrak{n}}}
\providecommand{\mfo}{\ensuremath{\mathfrak{o}}}
\providecommand{\mfp}{\ensuremath{\mathfrak{p}}}
\providecommand{\mfq}{\ensuremath{\mathfrak{q}}}
\providecommand{\mfr}{\ensuremath{\mathfrak{r}}}
\providecommand{\mfs}{\ensuremath{\mathfrak{s}}}
\providecommand{\mft}{\ensuremath{\mathfrak{t}}}
\providecommand{\mfu}{\ensuremath{\mathfrak{u}}}
\providecommand{\mfv}{\ensuremath{\mathfrak{v}}}
\providecommand{\mfw}{\ensuremath{\mathfrak{w}}}
\providecommand{\mfx}{\ensuremath{\mathfrak{x}}}
\providecommand{\mfy}{\ensuremath{\mathfrak{y}}}
\providecommand{\mfz}{\ensuremath{\mathfrak{z}}}
\providecommand{\mfA}{\ensuremath{\mathfrak{A}}}
\providecommand{\mfB}{\ensuremath{\mathfrak{B}}}
\providecommand{\mfC}{\ensuremath{\mathfrak{C}}}
\providecommand{\mfD}{\ensuremath{\mathfrak{D}}}
\providecommand{\mfE}{\ensuremath{\mathfrak{E}}}
\providecommand{\mfF}{\ensuremath{\mathfrak{F}}}
\providecommand{\mfG}{\ensuremath{\mathfrak{G}}}
\providecommand{\mfH}{\ensuremath{\mathfrak{H}}}
\providecommand{\mfI}{\ensuremath{\mathfrak{I}}}
\providecommand{\mfJ}{\ensuremath{\mathfrak{J}}}
\providecommand{\mfK}{\ensuremath{\mathfrak{K}}}
\providecommand{\mfL}{\ensuremath{\mathfrak{L}}}
\providecommand{\mfM}{\ensuremath{\mathfrak{M}}}
\providecommand{\mfN}{\ensuremath{\mathfrak{N}}}
\providecommand{\mfO}{\ensuremath{\mathfrak{O}}}
\providecommand{\mfP}{\ensuremath{\mathfrak{P}}}
\providecommand{\mfQ}{\ensuremath{\mathfrak{Q}}}
\providecommand{\mfR}{\ensuremath{\mathfrak{R}}}
\providecommand{\mfS}{\ensuremath{\mathfrak{S}}}
\providecommand{\mfT}{\ensuremath{\mathfrak{T}}}
\providecommand{\mfU}{\ensuremath{\mathfrak{U}}}
\providecommand{\mfV}{\ensuremath{\mathfrak{V}}}
\providecommand{\mfW}{\ensuremath{\mathfrak{W}}}
\providecommand{\mfX}{\ensuremath{\mathfrak{X}}}
\providecommand{\mfY}{\ensuremath{\mathfrak{Y}}}
\providecommand{\mfZ}{\ensuremath{\mathfrak{Z}}}

\providecommand{\frak}[1]{\ensuremath{\mathfrak{#1}}}
\providecommand{\fraka}{\ensuremath{\mathfrak{a}}}
\providecommand{\frakb}{\ensuremath{\mathfrak{b}}}
\providecommand{\frakc}{\ensuremath{\mathfrak{c}}}
\providecommand{\frakd}{\ensuremath{\mathfrak{d}}}
\providecommand{\frake}{\ensuremath{\mathfrak{e}}}
\providecommand{\frakf}{\ensuremath{\mathfrak{f}}}
\providecommand{\frakg}{\ensuremath{\mathfrak{g}}}
\providecommand{\frakh}{\ensuremath{\mathfrak{h}}}
\providecommand{\fraki}{\ensuremath{\mathfrak{i}}}
\providecommand{\frakj}{\ensuremath{\mathfrak{j}}}
\providecommand{\frakk}{\ensuremath{\mathfrak{k}}}
\providecommand{\frakl}{\ensuremath{\mathfrak{l}}}
\providecommand{\frakm}{\ensuremath{\mathfrak{m}}}
\providecommand{\frakn}{\ensuremath{\mathfrak{n}}}
\providecommand{\frako}{\ensuremath{\mathfrak{o}}}
\providecommand{\frakp}{\ensuremath{\mathfrak{p}}}
\providecommand{\frakq}{\ensuremath{\mathfrak{q}}}
\providecommand{\frakr}{\ensuremath{\mathfrak{r}}}
\providecommand{\fraks}{\ensuremath{\mathfrak{s}}}
\providecommand{\frakt}{\ensuremath{\mathfrak{t}}}
\providecommand{\fraku}{\ensuremath{\mathfrak{u}}}
\providecommand{\frakv}{\ensuremath{\mathfrak{v}}}
\providecommand{\frakw}{\ensuremath{\mathfrak{w}}}
\providecommand{\frakx}{\ensuremath{\mathfrak{x}}}
\providecommand{\fraky}{\ensuremath{\mathfrak{y}}}
\providecommand{\frakz}{\ensuremath{\mathfrak{z}}}
\providecommand{\frakA}{\ensuremath{\mathfrak{A}}}
\providecommand{\frakB}{\ensuremath{\mathfrak{B}}}
\providecommand{\frakC}{\ensuremath{\mathfrak{C}}}
\providecommand{\frakD}{\ensuremath{\mathfrak{D}}}
\providecommand{\frakE}{\ensuremath{\mathfrak{E}}}
\providecommand{\frakF}{\ensuremath{\mathfrak{F}}}
\providecommand{\frakG}{\ensuremath{\mathfrak{G}}}
\providecommand{\frakH}{\ensuremath{\mathfrak{H}}}
\providecommand{\frakI}{\ensuremath{\mathfrak{I}}}
\providecommand{\frakJ}{\ensuremath{\mathfrak{J}}}
\providecommand{\frakK}{\ensuremath{\mathfrak{K}}}
\providecommand{\frakL}{\ensuremath{\mathfrak{L}}}
\providecommand{\frakM}{\ensuremath{\mathfrak{M}}}
\providecommand{\frakN}{\ensuremath{\mathfrak{N}}}
\providecommand{\frakO}{\ensuremath{\mathfrak{O}}}
\providecommand{\frakP}{\ensuremath{\mathfrak{P}}}
\providecommand{\frakQ}{\ensuremath{\mathfrak{Q}}}
\providecommand{\frakR}{\ensuremath{\mathfrak{R}}}
\providecommand{\frakS}{\ensuremath{\mathfrak{S}}}
\providecommand{\frakT}{\ensuremath{\mathfrak{T}}}
\providecommand{\frakU}{\ensuremath{\mathfrak{U}}}
\providecommand{\frakV}{\ensuremath{\mathfrak{V}}}
\providecommand{\frakW}{\ensuremath{\mathfrak{W}}}
\providecommand{\frakX}{\ensuremath{\mathfrak{X}}}
\providecommand{\frakY}{\ensuremath{\mathfrak{Y}}}
\providecommand{\frakZ}{\ensuremath{\mathfrak{Z}}}

\providecommand{\ms}[1]{\ensuremath{\mathscr{#1}}}
\providecommand{\msA}{\ensuremath{\mathscr{A}}}
\providecommand{\msB}{\ensuremath{\mathscr{B}}}
\providecommand{\msC}{\ensuremath{\mathscr{C}}}
\providecommand{\msD}{\ensuremath{\mathscr{D}}}
\providecommand{\msE}{\ensuremath{\mathscr{E}}}
\providecommand{\msF}{\ensuremath{\mathscr{F}}}
\providecommand{\msG}{\ensuremath{\mathscr{G}}}
\providecommand{\msH}{\ensuremath{\mathscr{H}}}
\providecommand{\msI}{\ensuremath{\mathscr{I}}}
\providecommand{\msJ}{\ensuremath{\mathscr{J}}}
\providecommand{\msK}{\ensuremath{\mathscr{K}}}
\providecommand{\msL}{\ensuremath{\mathscr{L}}}
\providecommand{\msM}{\ensuremath{\mathscr{M}}}
\providecommand{\msN}{\ensuremath{\mathscr{N}}}
\providecommand{\msO}{\ensuremath{\mathscr{O}}}
\providecommand{\msP}{\ensuremath{\mathscr{P}}}
\providecommand{\msQ}{\ensuremath{\mathscr{Q}}}
\providecommand{\msR}{\ensuremath{\mathscr{R}}}
\providecommand{\msS}{\ensuremath{\mathscr{S}}}
\providecommand{\msT}{\ensuremath{\mathscr{T}}}
\providecommand{\msU}{\ensuremath{\mathscr{U}}}
\providecommand{\msV}{\ensuremath{\mathscr{V}}}
\providecommand{\msW}{\ensuremath{\mathscr{W}}}
\providecommand{\msX}{\ensuremath{\mathscr{X}}}
\providecommand{\msY}{\ensuremath{\mathscr{Y}}}
\providecommand{\msZ}{\ensuremath{\mathscr{Z}}}

\providecommand{\scr}[1]{\ensuremath{\mathscr{#1}}}
\providecommand{\scrA}{\ensuremath{\mathscr{A}}}
\providecommand{\scrB}{\ensuremath{\mathscr{B}}}
\providecommand{\scrC}{\ensuremath{\mathscr{C}}}
\providecommand{\scrD}{\ensuremath{\mathscr{D}}}
\providecommand{\scrE}{\ensuremath{\mathscr{E}}}
\providecommand{\scrF}{\ensuremath{\mathscr{F}}}
\providecommand{\scrG}{\ensuremath{\mathscr{G}}}
\providecommand{\scrH}{\ensuremath{\mathscr{H}}}
\providecommand{\scrI}{\ensuremath{\mathscr{I}}}
\providecommand{\scrJ}{\ensuremath{\mathscr{J}}}
\providecommand{\scrK}{\ensuremath{\mathscr{K}}}
\providecommand{\scrL}{\ensuremath{\mathscr{L}}}
\providecommand{\scrM}{\ensuremath{\mathscr{M}}}
\providecommand{\scrN}{\ensuremath{\mathscr{N}}}
\providecommand{\scrO}{\ensuremath{\mathscr{O}}}
\providecommand{\scrP}{\ensuremath{\mathscr{P}}}
\providecommand{\scrQ}{\ensuremath{\mathscr{Q}}}
\providecommand{\scrR}{\ensuremath{\mathscr{R}}}
\providecommand{\scrS}{\ensuremath{\mathscr{S}}}
\providecommand{\scrT}{\ensuremath{\mathscr{T}}}
\providecommand{\scrU}{\ensuremath{\mathscr{U}}}
\providecommand{\scrV}{\ensuremath{\mathscr{V}}}
\providecommand{\scrW}{\ensuremath{\mathscr{W}}}
\providecommand{\scrX}{\ensuremath{\mathscr{X}}}
\providecommand{\scrY}{\ensuremath{\mathscr{Y}}}
\providecommand{\scrZ}{\ensuremath{\mathscr{Z}}}

%%================================
%% General symbols
%%================================
\providecommand{\abs}[1]{\lvert#1\rvert}
\providecommand{\norm}[1]{\lVert#1\rVert}

\providecommand*{\injection}{\ensuremath{\hookrightarrow}}
\providecommand*{\surjection}{\ensuremath{\twoheadrightarrow}}
\providecommand*{\bijection}{\ensuremath{\xrightarrow{\sim}}}

%%================================
%% Symbols for number theory
%%================================
\ifdefined\@@pmod\else
\let\@@pmod\pmod
\DeclareRobustCommand{\pmod}{\@ifstar\@pmods\@@pmod}
\def\@pmods#1{\mkern4mu({\operator@font mod}\mkern 6mu#1)}
\fi

\newcommand{\genlegendre}[4]{%
  \genfrac{(}{)}{}{#1}{#3}{#4}%
  \if\relax\detokenize{#2}\relax\else_{\!#2}\fi%
}
\newcommand{\legendre}[3][]{\genlegendre{}{#1}{#2}{#3}}
\newcommand{\dlegendre}[3][]{\genlegendre{0}{#1}{#2}{#3}}
\newcommand{\tlegendre}[3][]{\genlegendre{1}{#1}{#2}{#3}}

\endinput
%%
%% End of file `PJLmath.sty'.
