Common subexpression elimination algorithm for low-cost multiplierless implementation of matrix multipliers