| 115 | } |
| 116 | |
| 117 | @Override |
| 118 | public void transposeMultiply(double c, Vec b, Vec x) |
| 119 | { |
| 120 | if(this.rows() != b.length()) |
| 121 | throw new ArithmeticException("Matrix dimensions do not agree, [" + cols() +"," + rows() + "] x [" + b.length() + ",1]" ); |
| 122 | else if(this.cols() != x.length()) |
| 123 | throw new ArithmeticException("Matrix dimensions do not agree with target vector"); |
| 124 | |
| 125 | for(int i = 0; i < rows(); i++)//if b was sparce, we want to skip every time b_i = 0 |
| 126 | { |
| 127 | double b_i = b.get(i); |
| 128 | if(b_i == 0)//Skip, not quite as good as sparce handeling |
| 129 | continue;//TODO handle sparce input vector better |
| 130 | |
| 131 | double[] A_i = this.matrix[i]; |
| 132 | for(int j = 0; j < cols(); j++) |
| 133 | x.increment(j, c*b_i*A_i[j]); |
| 134 | } |
| 135 | } |
| 136 | @SuppressWarnings("unused") |
| 137 | private Matrix blockMultiply(Matrix b) |
| 138 | { |