/** {@inheritDoc} */ @Override public double getL1Norm() { return v.getL1Norm(); }
/** {@inheritDoc} */ @Override public double getL1Norm() { return v.getL1Norm(); }
/** {@inheritDoc} */ @Override public double getL1Norm() { return v.getL1Norm(); }
private RealVector getTermVectorInteger(Map<String, Integer> map) { RealVector vector = new ArrayRealVector(terms.size()); int i = 0; for (String term : terms) { int value = map.containsKey(term) ? map.get(term) : 0; vector.setEntry(i++, value); } return vector.mapDivide(vector.getL1Norm()); }
private RealVector getTermVectorDouble(Map<String, Double> map) { RealVector vector = new ArrayRealVector(terms.size()); int i = 0; for (String term : terms) { double value = map.containsKey(term) ? map.get(term) : 0d; vector.setEntry(i++, value); } return vector.mapDivide(vector.getL1Norm()); }
@Override public double getNorm1(Matrix m) { ArgChecker.notNull(m, "m"); if (m instanceof DoubleArray) { RealVector temp = CommonsMathWrapper.wrap((DoubleArray) m); return temp.getL1Norm(); } else if (m instanceof DoubleMatrix) { RealMatrix temp = CommonsMathWrapper.wrap((DoubleMatrix) m); // TODO find if commons implements this anywhere, so we are not doing it // by hand double max = 0.0; for (int col = temp.getColumnDimension() - 1; col >= 0; col--) { max = Math.max(max, temp.getColumnVector(col).getL1Norm()); } return max; } throw new IllegalArgumentException("Can only find norm1 of DoubleMatrix; have " + m.getClass()); }
case 2: for(int j=0; j<A.getColumnDimension(); j++){ columnNormsList.add(A.getColumnVector(j).getL1Norm());
@Override public double getNormInfinity(Matrix m) { ArgChecker.notNull(m, "m"); if (m instanceof DoubleArray) { RealVector temp = CommonsMathWrapper.wrap((DoubleArray) m); return temp.getLInfNorm(); } else if (m instanceof DoubleMatrix) { RealMatrix temp = CommonsMathWrapper.wrap((DoubleMatrix) m); //REVIEW Commons getNorm() is wrong - it returns the column norm // TODO find if commons implements this anywhere, so we are not doing it // by hand double max = 0.0; for (int row = temp.getRowDimension() - 1; row >= 0; row--) { max = Math.max(max, temp.getRowVector(row).getL1Norm()); } return max; } throw new IllegalArgumentException("Can only find normInfinity of DoubleMatrix; have " + m.getClass()); }