def bin_matrix(M, subsampling_factor=<NUM_LIT:3>):
try:<EOL><INDENT>from scipy.sparse import issparse<EOL>if issparse(M):<EOL><INDENT>return bin_sparse(M, subsampling_factor=subsampling_factor)<EOL><DEDENT>else:<EOL><INDENT>raise ImportError<EOL><DEDENT><DEDENT>except ImportError:<EOL><INDENT>return bin_dense(M, subsampling_factor=subsampling_factor)<EOL><DEDENT>
Bin either sparse or dense matrices.