(* :Title: Kasteleyn *) (* :Context: "Kasteleyn`" *) (* :Author: P.H. Lundow Bug reports to phl@kth.se *) (* :Summary: Functions for smoothing equidistant data with a Savitsky-Golay filter. *) (* :History: 070618 Created. *) (* :Mathematica Version: 4.0 *) (* :Keywords: *) (* :Limitations: *) (* :Discussion: *) (* :References: P. W. Kasteleyn, The statistics of dimers on a lattice, Physica 27 (1961), 1209-1225. *) BeginPackage["Kasteleyn`"] NumberOfOneFactorsCC::usage = "NumerOfOneFactorsCC[m, n] returns the number of 1-factors in the graph Cm x Cn, the mxn toroidal square lattice." NumberOfOneFactorsCP::usage = "NumerOfOneFactorsCP[m, n] returns the number of 1-factors in the graph Cm x Pn, the mxn cylindrical square lattice." NumberOfOneFactorsPP::usage = "NumerOfOneFactorsPP[m, n] returns the number of 1-factors in the graph Pm x Pn, the mxn planar square lattice with open boundary." Begin["`Private`"] definitions = {NumberOfOneFactorsCC, NumberOfOneFactorsCP, NumberOfOneFactorsPP} Scan[Unprotect, definitions] NumberOfOneFactorsCC[m_, n_] := 0 /; OddQ[m*n] NumberOfOneFactorsCC[m_, n_] := NumberOfOneFactorsCC[n, m] /; OddQ[n] NumberOfOneFactorsCC[m_, n_] := Module[{i, j}, (Product[ Sqrt[Sin[Pi*(2*i-1)/m]^2 + Sin[Pi*2*j/n]^2], {i, 1 ,m}, {j, 1, n/2} ] + Product[ Sqrt[Sin[Pi*2*i/m]^2 + Sin[Pi*(2*j-1)/n]^2], {i, 1, m}, {j, 1, n/2} ] + Product[ Sqrt[Sin[Pi*(2*i-1)/m]^2 + Sin[Pi*(2*j-1)/n]^2], {i, 1, m}, {j, 1, n/2} ])*2^(m*n/2-1) ] /; EvenQ[n] NumberOfOneFactorsCP[m_, n_] := 0 /; OddQ[m*n] NumberOfOneFactorsCP[m_, n_] := fcp[m, n]/2^(m/2-1) /; OddQ[n] NumberOfOneFactorsCP[m_, n_] := fcp[m, n] /; EvenQ[n] fcp[m_, n_] := Module[{i, j}, Product[ Sqrt[Sin[Pi*(2*i-1)/m]^2 + Cos[Pi*j/(n+1)]^2], {i, 1, m}, {j, 1, n/2} ]*2^(m*n/2) ] NumberOfOneFactorsPP[m_, n_] := 0 /; OddQ[m*n] NumberOfOneFactorsPP[m_, n_] := NumberOfOneFactorsPP[n, m] /; OddQ[n] NumberOfOneFactorsPP[m_, n_] := Module[{i, j}, Product[ Sqrt[Cos[Pi*i/(m+1)]^2 + Cos[Pi*j/(n+1)]^2], {i, 1, m}, {j, 1, n/2} ]*2^(m*n/2) ] /; EvenQ[n] Scan[Protect, definitions] End[] EndPackage[]