class RealVector {
/**
* Returns the L<sub>1</sub> norm of the vector.
* <p>The L<sub>1</sub> norm is the sum of the absolute
* values of the elements.</p>
*
* @return the norm.
* @see #getNorm()
* @see #getLInfNorm()
* @see #getL1Distance(RealVector)
*/
public double getL1Norm() {
double norm = 0;
Iterator<Entry> it = iterator();
while (it.hasNext()) {
final Entry e = it.next();
norm += FastMath.abs(e.getValue());
}
return norm;
}
}
class RealVector {
@Override
public double getL1Norm() {
return v.getL1Norm();
}
}
|