title: How to speed up A*x if A is not a dense matrix with non-zeros entries being +1 or -1?
body: <p>In the question, A is a square matrix and x is a vector. The non-zero entries of A can only be 1 or -1. Then how to speed up A*x in Matlab?</p>
  
  <p>I asked this question, because A*x contains multiplication operations that are computation-expensive. </p>
  
  <p>However, if A only contains some +1 and -1, and assume y is a row vector from A, then y*x can avoid multiplication operations. You just need group the entries of x into 2, one is corresponding to the entries +1 of y, and the other one is corresponding to the entries -1 of y. Then do a summation of these 2 groups respectively, and do a subtraction.</p>