@Override public double norm2() { return this.internalVector.norm( no.uib.cipr.matrix.Vector.Norm.Two ); }
@Override public double norm2() { return this.internalVector.norm( no.uib.cipr.matrix.Vector.Norm.Two ); }
@Override public double norm2() { return this.internalVector.norm( no.uib.cipr.matrix.Vector.Norm.Two ); }
public boolean converged(Vector r, Vector x) throws IterativeSolverNotConvergedException { return converged(r.norm(normType), x); }
public boolean converged(Vector r, Vector x) throws IterativeSolverNotConvergedException { return converged(r.norm(normType), x); }
public boolean converged(Vector r) throws IterativeSolverNotConvergedException { return converged(r.norm(normType)); }
public boolean converged(Vector r) throws IterativeSolverNotConvergedException { return converged(r.norm(normType)); }
/** * Calculates the norm of the given vector. If multiple vectors are given, calculates the * product of the vector norms. If no vector is given, 1.0 is returned. * * @param aVectors a list of vectors. * @return the vector norm or product of vector norms. */ public double apply(Vector... aVectors) { double result = 1.0; if (!this.equals(NONE)) { for (Vector v : aVectors) { switch (this) { case L1: result = result * v.norm(Norm.One); break; case L2: result = result * v.norm(Norm.TwoRobust); break; default: throw new IllegalStateException("Norm ["+this+"] not supported"); } } } return result; } }
/** * Calculates the norm of the given vector. If multiple vectors are given, calculates the * product of the vector norms. If no vector is given, 1.0 is returned. * * @param aVectors a list of vectors. * @return the vector norm or product of vector norms. */ public double apply(Vector... aVectors) { double result = 1.0; if (!this.equals(NONE)) { for (Vector v : aVectors) { switch (this) { case L1: result = result * v.norm(Norm.One); break; case L2: result = result * v.norm(Norm.TwoRobust); break; default: throw new IllegalStateException("Norm ["+this+"] not supported"); } } } return result; } }
/** * Calculates the norm of the given vector. If multiple vectors are given, calculates the * product of the vector norms. If no vector is given, 1.0 is returned. * * @param aVectors a list of vectors. * @return the vector norm or product of vector norms. */ public double apply(Vector... aVectors) { double result = 1.0; if (!this.equals(NONE)) { for (Vector v : aVectors) { switch (this) { case L1: result = result * v.norm(Norm.One); break; case L2: result = result * v.norm(Norm.TwoRobust); break; default: throw new IllegalStateException("Norm ["+this+"] not supported"); } } } return result; } }
@Override protected boolean convergedI(double r, Vector x) throws IterativeSolverNotConvergedException { // Store initial residual if (isFirst()) initR = r; // Check for convergence if (r < Math.max(rtol * (normA * x.norm(normType) + normb), atol)) return true; // Check for divergence if (r > dtol * initR) throw new IterativeSolverNotConvergedException( NotConvergedException.Reason.Divergence, this); if (iter >= maxIter) throw new IterativeSolverNotConvergedException( NotConvergedException.Reason.Iterations, this); if (Double.isNaN(r)) throw new IterativeSolverNotConvergedException( NotConvergedException.Reason.Divergence, this); // Neither convergence nor divergence return false; }
@Override protected boolean convergedI(double r, Vector x) throws IterativeSolverNotConvergedException { // Store initial residual if (isFirst()) initR = r; // Check for convergence if (r < Math.max(rtol * (normA * x.norm(normType) + normb), atol)) return true; // Check for divergence if (r > dtol * initR) throw new IterativeSolverNotConvergedException( NotConvergedException.Reason.Divergence, this); if (iter >= maxIter) throw new IterativeSolverNotConvergedException( NotConvergedException.Reason.Iterations, this); if (Double.isNaN(r)) throw new IterativeSolverNotConvergedException( NotConvergedException.Reason.Divergence, this); // Neither convergence nor divergence return false; }
@Override public Vector[] apply(double[] in) { Vector[] vmat = new Vector[in.length]; vmat[0] = new DenseVector(in); double norm = vmat[0].norm(Norm.Two); vmat[0].scale(1/norm); for (int j = 1; j < in.length; j++) { Vector randvec = randvec(vmat[0].size(),norm); vmat[j] = new DenseVector(vmat[0]).add(randvec); for (int i = 0; i < j; i++) { vmat[j].add(-1, project(vmat[j],vmat[i])); } vmat[j].scale(1/vmat[j].norm(Norm.Two)); } return vmat; }
m_Weights.scale(1.0 / m_Weights.norm(Vector.Norm.Two));