On this page:
matrix-op-1norm
matrix-op-2norm
matrix-op-inf-norm
matrix-basis-cos-angle
matrix-basis-angle
matrix-error-norm
matrix-absolute-error
matrix-relative-error
matrix-zero?
matrix-identity?
matrix-orthonormal?

7.12 Operator Norms and Comparing Matrices🔗ℹ

Inner Product Space Operations describes functions that deal with matrices as vectors in an inner product space. This section describes functions that deal with matrices as linear operators, or as functions from column matrices to column matrices.

Wikipedia: Induced norm In this setting, a norm is the largest relative change in magnitude an operator (i.e. matrix) can effect on a column matrix, where “magnitude” is defined by a vector norm. (See the Wikipedia article linked to in the margin for a formal definition.) Matrix norms that are defined in terms of a vector norm are called induced norms, or operator norms.

procedure

(matrix-op-1norm M)  Nonnegative-Real

  M : (Matrix Number)
The operator norm induced by the vector norm matrix-1norm.

When M is a column matrix, (matrix-op-1norm M) is equivalent to (matrix-1norm M).

procedure

(matrix-op-2norm M)  Nonnegative-Real

  M : (Matrix Number)
The operator norm induced by the vector norm matrix-2norm.

This function is currently undefined because a required algorithm (singular value decomposition or eigendecomposition) is not yet implemented in math/matrix.

When M is a column matrix, (matrix-op-2norm M) is equivalent to (matrix-2norm M).

procedure

(matrix-op-inf-norm M)  Nonnegative-Real

  M : (Matrix Number)
The operator norm induced by the vector norm matrix-inf-norm.

When M is a column matrix, (matrix-op-inf-norm M) is equivalent to (matrix-inf-norm M).

procedure

(matrix-basis-cos-angle M0 M1)  Number

  M0 : (Matrix Number)
  M1 : (Matrix Number)
Returns the cosine of the angle between the two subspaces spanned by M0 and M1.

This function is currently undefined because a required algorithm (singular value decomposition or eigendecomposition) is not yet implemented in math/matrix.

When M0 and M1 are column matrices, (matrix-basis-cos-angle M0 M1) is equivalent to (matrix-cos-angle M0 M1).

procedure

(matrix-basis-angle M0 M1)  Number

  M0 : (Matrix Number)
  M1 : (Matrix Number)
Equivalent to (acos (matrix-basis-cos-angle M0 M1)).

The function is currently undefined because matrix-basis-cos-angle is currently undefined.

parameter

(matrix-error-norm)  ((Matrix Number) -> Nonnegative-Real)

(matrix-error-norm norm)  void?
  norm : ((Matrix Number) -> Nonnegative-Real)
The norm used by matrix-relative-error and matrix-absolute-error. The default value is matrix-op-inf-norm.

Besides being a true norm, norm should also be submultiplicative:

(norm (matrix* M0 M1)) <= (* (norm M0) (norm M1))

This additional triangle-like inequality makes it possible to prove error bounds for formulas that involve matrix multiplication.

All operator norms (matrix-op-1norm, matrix-op-2norm, matrix-op-inf-norm) are submultiplicative by definition, as is the Frobenius norm (matrix-2norm).

procedure

(matrix-absolute-error M R [norm])  Nonnegative-Real

  M : (Matrix Number)
  R : (Matrix Number)
  norm : ((Matrix Number) -> Nonnegative-Real)
   = (matrix-error-norm)
Basically equivalent to (norm (matrix- M R)), but handles non-rational flonums like +inf.0 and +nan.0 specially.

See absolute-error for the scalar version of this function.

procedure

(matrix-relative-error M R [norm])  Nonnegative-Real

  M : (Matrix Number)
  R : (Matrix Number)
  norm : ((Matrix Number) -> Nonnegative-Real)
   = (matrix-error-norm)
Measures the error in M relative to the true matrix R, under the norm norm. Basically equivalent to (/ (norm (matrix- M R)) (norm R)), but handles non-rational flonums like +inf.0 and +nan.0 specially, as well as the case (norm R) = 0.

See relative-error for the scalar version of this function.

procedure

(matrix-zero? M [eps])  Boolean

  M : (Matrix Number)
  eps : Real = (* 10 epsilon.0)
Returns #t when M is very close to a zero matrix (by default, within a few epsilons). Equivalent to

(<= (matrix-absolute-error M (make-matrix m n 0)) eps)

where m n is the shape of M.

procedure

(matrix-identity? M [eps])  Boolean

  M : (Matrix Number)
  eps : Real = (* 10 epsilon.0)
Returns #t when M is very close to the identity matrix (by default, within a few epsilons). Equivalent to
(and (square-matrix? M)
     (<= (matrix-relative-error M (identity-matrix (square-matrix-size M)))
         eps))

procedure

(matrix-orthonormal? M [eps])  Boolean

  M : (Matrix Number)
  eps : Real = (* 10 epsilon.0)
Returns #t when M is very close to being orthonormal; that is, when (matrix* M (matrix-hermitian M)) is very close to an identity matrix. Equivalent to