implemented dense and sparse Polya