@Override public <M extends Number, O extends Number> Vector<O> mult(Vector<M> x, Vectors.Factory<O> using) { assert (x.length() == n); double[] product = new double[m]; if (x instanceof RealVector) { final double[] x2 = ((RealVector) x).data(); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { product[i] += data[i][j] * x2[j]; } } } else if (x instanceof IntVector) { final int[] x2 = ((IntVector) x).data(); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { product[i] += data[i][j] * x2[j]; } } } else { for (int i = 0; i < m; i++) { for (Map.Entry<Integer, M> e : x.entrySet()) { product[i] += data[i][e.getKey()] * e.getValue().doubleValue(); } } } return using.make(product); }
@Override public <M extends Number> Vector<Integer> multTransposed(Vector<M> x) { assert (x.length() == m); double[] product = new double[n]; if (x instanceof RealVector) { final double[] x2 = ((RealVector) x).data(); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { product[i] += data[j][i] * x2[j]; } } } else if (x instanceof IntVector) { final int[] x2 = ((IntVector) x).data(); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { product[i] += data[j][i] * x2[j]; } } } else { for (int i = 0; i < n; i++) { for (Map.Entry<Integer, M> e : x.entrySet()) { product[i] += data[e.getKey()][i] * e.getValue().doubleValue(); } } } return Vectors.AS_INTS.make(product); }
@Override public <M extends Number> Vector<Double> multTransposed(Vector<M> x) { assert (x.length() == m); double[] product = new double[n]; if (x instanceof RealVector) { final double[] x2 = ((RealVector) x).data(); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { product[i] += data[j][i] * x2[j]; } } } else if (x instanceof IntVector) { final int[] x2 = ((IntVector) x).data(); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { product[i] += data[j][i] * x2[j]; } } } else { for (int i = 0; i < n; i++) { for (Map.Entry<Integer, M> e : x.entrySet()) { product[i] += data[e.getKey()][i] * e.getValue().doubleValue(); } } } return new RealVector(product); }
@Override public <M extends Number, O extends Number> Vector<O> mult(Vector<M> x, Vectors.Factory<O> using) { assert (x.length() == n); double[] product = new double[m]; if (x instanceof RealVector) { final double[] x2 = ((RealVector) x).data(); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { product[i] += data[i][j] * x2[j]; } } } else if (x instanceof IntVector) { final int[] x2 = ((IntVector) x).data(); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { product[i] += data[i][j] * x2[j]; } } } else { for (int i = 0; i < m; i++) { for (Map.Entry<Integer, M> e : x.entrySet()) { product[i] += data[i][e.getKey()] * e.getValue().doubleValue(); } } } return using.make(product); }
assert (n == y.length()); if (y instanceof RealVector) { double[] y2 = ((RealVector) y).data(); if (defaultValue == 0) { double innerProduct = 0;
assert (n == y.length()); if (y instanceof RealVector) { double[] y2 = ((RealVector) y).data(); if (defaultValue == 0) { double innerProduct = 0;
assert (m == x.length()); if (x instanceof RealVector) { double[] x2 = ((RealVector) x).data();
assert (m == x.length()); if (x instanceof RealVector) { double[] x2 = ((RealVector) x).data();
for (int i = 0; i < n - k - 1; i++) { for (int j = 0; j < n - k - 1; j++) { w.data()[i] += 2 * A2.doubleValue(i + k + 1, j + k + 1) * v.doubleValue(j) / vtv;