Alters the matrix A such that, A = A + c x y ' @param A the matrix to update @param x the first vector @param y the second vector @param c the scalar constant to multiply the outer product by @throws ArithmeticException if the vector dimensions are not compatible with the
(Matrix A, Vec x, Vec y, double c)
| 880 | * with the matrix <i>A</i> |
| 881 | */ |
| 882 | public static void OuterProductUpdate(Matrix A, Vec x, Vec y, double c) |
| 883 | { |
| 884 | if (x.length() != A.rows() || y.length() != A.cols()) |
| 885 | throw new ArithmeticException("Matrix dimensions do not agree with outer product"); |
| 886 | if (x.isSparse()) |
| 887 | for (IndexValue iv : x) |
| 888 | A.updateRow(iv.getIndex(), iv.getValue() * c, y); |
| 889 | else |
| 890 | for (int i = 0; i < x.length(); i++) |
| 891 | { |
| 892 | double rowCosnt = c * x.get(i); |
| 893 | A.updateRow(i, rowCosnt, y); |
| 894 | } |
| 895 | } |
| 896 | |
| 897 | /** |
| 898 | * Alters the matrix <i>A</i> such that, |