Riffle

This is an implementation of the riffle-shuffle transition matrix made famous by Diaconis et al. The computation of binomial and Eulerian coefficients closely follows the scripts provided in Trefethen and Embree’s Spectra and Pseudospectra: The Behaviour of Nonnormal Matrices and Operators.

C++ API

void Riffle(Matrix<F> &P, Int n)
void Riffle(AbstractDistMatrix<F> &P, Int n)

Return the \(n \times n\) transition matrix.

void Riffle(Matrix<F> &P, Matrix<F> &PInf, Int n)
void Riffle(ElementalMatrix<F> &P, ElementalMatrix<F> &PInf, Int n)

Return both the \(n \times n\) transition matrix and its stationary distribution (as a square matrix with identical rows).

void RiffleStationary(Matrix<F> &PInf, Int n)
void RiffleStationary(AbstractDistMatrix<F> &PInf, Int n)

Return the stationary distribution of the \(n \times n\) system as a square matrix with identical rows.

void RiffleDecay(Matrix<F> &A, Int n)
void RiffleDecay(ElementalMatrix<F> &A, Int n)

Return the transition matrix with its stationary distribution subtracted from each row.

C API

ElError ElRiffle_s(ElMatrix_s P, ElInt n)
ElError ElRiffle_d(ElMatrix_d P, ElInt n)
ElError ElRiffle_c(ElMatrix_c P, ElInt n)
ElError ElRiffle_z(ElMatrix_z P, ElInt n)
ElError ElRiffleDist_s(ElDistMatrix_s P, ElInt n)
ElError ElRiffleDist_d(ElDistMatrix_d P, ElInt n)
ElError ElRiffleDist_c(ElDistMatrix_c P, ElInt n)
ElError ElRiffleDist_z(ElDistMatrix_z P, ElInt n)

Return the \(n \times n\) transition matrix.

ElError ElRiffleStationary_s(ElMatrix_s PInf, ElInt n)
ElError ElRiffleStationary_d(ElMatrix_d PInf, ElInt n)
ElError ElRiffleStationary_c(ElMatrix_c PInf, ElInt n)
ElError ElRiffleStationary_z(ElMatrix_z PInf, ElInt n)
ElError ElRiffleStationaryDist_s(ElDistMatrix_s PInf, ElInt n)
ElError ElRiffleStationaryDist_d(ElDistMatrix_d PInf, ElInt n)
ElError ElRiffleStationaryDist_c(ElDistMatrix_c PInf, ElInt n)
ElError ElRiffleStationaryDist_z(ElDistMatrix_z PInf, ElInt n)

Return the stationary distribution of the \(n \times n\) system as a square matrix with identical rows.

ElError ElRiffleDecay_s(ElMatrix_s A, ElInt n)
ElError ElRiffleDecay_d(ElMatrix_d A, ElInt n)
ElError ElRiffleDecay_c(ElMatrix_c A, ElInt n)
ElError ElRiffleDecay_z(ElMatrix_z A, ElInt n)

Return the transition matrix with its stationary distribution subtracted from each row.

Python API

Riffle(P, n)
RiffleStationary(PInf, n)
RiffleDecay(A, n)