Class MatrixOps

java.lang.Object
de.labathome.trustconstr.matrix.MatrixOps

public final class MatrixOps extends Object
Small static helpers that operate on double[] vectors and Matrix instances.
  • Method Details

    • norm2

      public static double norm2(double[] v)
      Euclidean (2-)norm of a vector.
      Parameters:
      v - vector
      Returns:
      sqrt(sum_i v[i]^2)
    • dot

      public static double dot(double[] a, double[] b)
      Dot product of two equal-length vectors.
      Parameters:
      a - left operand
      b - right operand (must have the same length as a)
      Returns:
      sum_i a[i] * b[i]
    • diag

      public static Matrix diag(double[] diagonal)
      Build a sparse diagonal matrix with the given entries on the diagonal.
      Parameters:
      diagonal - length-n array of diagonal values
      Returns:
      n x n SparseMatrix with the diagonal populated and zeros elsewhere
    • sparse

      public static Matrix sparse(Matrix A)
      Materialise the non-zero entries of a possibly-dense matrix into a SparseMatrix (DOK-backed). Used by tests that exercise the sparse code paths against a dense reference.
      Parameters:
      A - source matrix
      Returns:
      SparseMatrix with the same shape and non-zero entries