@Override public Vector set(double alpha, Vector y) { if (!(y instanceof DenseVector)) return super.set(alpha, y); checkSize(y); if (alpha == 0) return zero(); double[] yd = ((DenseVector) y).getData(); for (int i = 0; i < size; ++i) data[i] = alpha * yd[i]; return this; }
@Override public Vector set(double alpha, Vector y) { if (!(y instanceof DenseVector)) return super.set(alpha, y); checkSize(y); if (alpha == 0) return zero(); double[] yd = ((DenseVector) y).getData(); for (int i = 0; i < size; ++i) data[i] = alpha * yd[i]; return this; }
/** * Performs a multigrid cycle * * @param k * Level to cycle at. Start by calling <code>cycle(0)</code> */ private void cycle(int k) { if (k == m - 1) directSolve(); else { // Presmoothings preRelax(k); u[k + 1].zero(); // Compute the residual A[k].multAdd(-1, u[k], r[k].set(f[k])); // Restrict to the next coarser level I[k].transMult(r[k], f[k + 1]); // Recurse to next level for (int i = 0; i < gamma; ++i) cycle(k + 1); // Add residual correction by prolongation I[k].multAdd(u[k + 1], u[k]); // Postsmoothings postRelax(k); } }
/** * Performs a multigrid cycle * * @param k * Level to cycle at. Start by calling <code>cycle(0)</code> */ private void cycle(int k) { if (k == m - 1) directSolve(); else { // Presmoothings preRelax(k); u[k + 1].zero(); // Compute the residual A[k].multAdd(-1, u[k], r[k].set(f[k])); // Restrict to the next coarser level I[k].transMult(r[k], f[k + 1]); // Recurse to next level for (int i = 0; i < gamma; ++i) cycle(k + 1); // Add residual correction by prolongation I[k].multAdd(u[k + 1], u[k]); // Postsmoothings postRelax(k); } }
iV.zero(); for (int i = colptr[k]; i < colptr[k + 1]; ++i) iCol[rowind[i]] = Idata[i];
iV.zero(); for (int i = colptr[k]; i < colptr[k + 1]; ++i) iCol[rowind[i]] = Idata[i];
s.zero().set(0, normr); int i = 0;
s.zero().set(0, normr); int i = 0;