One Norm

This documentation was generated with the assistance of AI. Please report any inaccuracies.

OneNormComputer computes the one norm (L1 norm) of a matrix or array. For a matrix, it is the maximum absolute column sum:

This library represents an array as a single column matrix, so for an array the one norm reduces to the sum of the absolute values of its elements. This is the p = 1 case of the general p-norm family for vectors described in Wikipedia’s "Norm (mathematics)" article:

Instances are obtained through NormComputer.create(NormType.ONE_NORM), and Utils.norm1 is built directly on this class.

Plotting the set of vectors with norm exactly 1 for a few values of p shows why the one norm is also called the "taxicab" norm: its unit ball is the diamond below, in contrast with the familiar circle of the Euclidean/Frobenius norm (p = 2) and the square of the infinity norm (p tending to infinity):

Unit balls for the 1-norm 2-norm 4-norm and infinity-norm showing the one norm’s diamond shape

Usage

The getNorm instance methods implement the abstract NormComputer contract; static norm methods are also available for direct use without instantiating the class:

import com.irurueta.algebra.OneNormComputer;
import com.irurueta.algebra.Matrix;
import com.irurueta.algebra.NormComputer;
import com.irurueta.algebra.NormType;

Matrix a = new Matrix(2, 2);
// ... fill a with data ...

// static usage
double norm = OneNormComputer.norm(a);

double[] array = {-3.0, 4.0};
double arrayNorm = OneNormComputer.norm(array); // 7.0

// through the NormComputer factory
NormComputer computer = NormComputer.create(NormType.ONE_NORM);
double sameNorm = computer.getNorm(a);

A norm(double[], Matrix jacobian) overload also computes the norm’s 1xN Jacobian with respect to the input array; unlike FrobeniusNormComputer and InfinityNormComputer, this overload sets every element of the Jacobian to Double.MAX_VALUE when the array norm is zero, since the one norm is not differentiable at the origin.

Utils.norm1(Matrix) and Utils.norm1(double[]) are convenience wrappers around this class.

Error handling

The Jacobian overload throws WrongSizeException if the provided Jacobian matrix is not 1xN, where N is the length of the input array.

Reference

The one norm is one of the standard vector and matrix norms described in Wikipedia, "Norm (mathematics)" and Wikipedia, "Matrix norm".