How to implement doubly-stochastic matrices for consensus-based distributed algorithms