Record Class MeasurementMatrix

java.lang.Object
java.lang.Record
smile.cs.MeasurementMatrix
Record Components:
phi - The underlying sensing matrix Φ (m × n).
wavelet - Optional wavelet sparsifying basis. May be null.
All Implemented Interfaces:
Serializable

public record MeasurementMatrix(DenseMatrix phi, Wavelet wavelet) extends Record implements Serializable
Measurement matrix for compressed sensing.

In compressed sensing the measurement process is modeled as y = Φ Ψ s, where:

  • Φ is the m × n sensing matrix (e.g. random Gaussian or Bernoulli projections),
  • Ψ is the n × n sparsifying basis (e.g. a wavelet transform), and
  • s is the sparse coefficient vector in the basis domain.

Recovery algorithms (BasisPursuit, OMP, CoSaMP) operate on the compound measurement matrix A = Φ Ψ or, when no sparsifying basis is needed, directly on Φ.

For large n the wavelet sparsifying basis is applied implicitly as a matrix–vector operator (forward / inverse DWT) rather than explicitly forming the full n × n matrix, which makes the approach memory-efficient.

Supported sensing matrix types

  • gaussian(int, int) – i.i.d. Gaussian entries scaled by 1/√m; satisfies the RIP with high probability for m = O(k log(n/k)).
  • bernoulli(int, int) – i.i.d. ±1/√m Bernoulli entries; also satisfies the RIP with the same sample complexity.
  • partial(int[], int) – a random row-sub-sampling of the n × n identity matrix (partial identity / random sampling).

Sparsifying bases

When the signal is sparse in a wavelet domain, pass a Wavelet instance to withWavelet(Wavelet). The returned matrix operator composes Φ with the DWT implicitly, so y = Φ DWT(x) for a signal x of length n (a power of 2).

References

  1. E. J. Candès and M. B. Wakin, "An introduction to compressive sampling", IEEE Signal Process. Mag., 25(2):21–30, 2008.
  2. R. Baraniuk, "Compressive sensing", IEEE Signal Process. Mag., 24(4):118–121, 2007.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a measurement matrix without a sparsifying basis.
    Creates an instance of a MeasurementMatrix record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    backProject(double[] y)
    Computes the adjoint operation v = Φ^T y (back-projection).
    double[]
    backProjectSparse(double[] y)
    Computes the adjoint in the sparse (wavelet) domain: v = Ψ^T Φ^T y = DWT(Φ^T y).
    bernoulli(int m, int n)
    Creates a random Bernoulli sensing matrix with entries Φ_{ij} ∈ {+1/√m, −1/√m} with equal probability.
    final boolean
    Indicates whether some other object is "equal to" this one.
    gaussian(int m, int n)
    Creates a random Gaussian sensing matrix with entries Φ_{ij} ~ N(0, 1/m).
    final int
    Returns a hash code value for this object.
    double[]
    measure(double[] x)
    Computes measurements y = Φ x (no wavelet basis).
    double[]
    measureSparse(double[] s)
    Computes measurements y = Φ Ψ s where Ψ is the inverse-DWT operator (synthesis).
    int
    Returns the signal dimension (columns of Φ).
    int
    Returns the number of measurements (rows of Φ).
    partial(int[] rows, int n)
    Creates a partial identity (random row-sub-sampling) sensing matrix.
    partial(int m, int n)
    Creates a random partial identity sensing matrix by selecting m rows uniformly at random without replacement.
    phi()
    Returns the underlying sensing matrix Φ.
    Returns an implicit Matrix that represents the compound operator A = Φ Ψ (or A = Φ when no wavelet is set).
    final String
    Returns a string representation of this record class.
    Returns the wavelet sparsifying basis, or null if not set.
    Returns a new MeasurementMatrix that combines this sensing matrix with the given wavelet sparsifying basis.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MeasurementMatrix

      public MeasurementMatrix(DenseMatrix phi)
      Constructs a measurement matrix without a sparsifying basis.
      Parameters:
      phi - the sensing matrix Φ.
    • MeasurementMatrix

      public MeasurementMatrix(DenseMatrix phi, Wavelet wavelet)
      Creates an instance of a MeasurementMatrix record class.
      Parameters:
      phi - the value for the phi record component
      wavelet - the value for the wavelet record component
  • Method Details

    • nrow

      public int nrow()
      Returns the number of measurements (rows of Φ).
      Returns:
      m.
    • ncol

      public int ncol()
      Returns the signal dimension (columns of Φ).
      Returns:
      n.
    • phi

      public DenseMatrix phi()
      Returns the underlying sensing matrix Φ.
      Returns:
      the sensing matrix.
    • wavelet

      public Wavelet wavelet()
      Returns the wavelet sparsifying basis, or null if not set.
      Returns:
      the wavelet.
    • measure

      public double[] measure(double[] x)
      Computes measurements y = Φ x (no wavelet basis).
      Parameters:
      x - the signal vector of length n.
      Returns:
      the measurement vector of length m.
    • measureSparse

      public double[] measureSparse(double[] s)
      Computes measurements y = Φ Ψ s where Ψ is the inverse-DWT operator (synthesis).

      When no wavelet is configured this method is equivalent to measure(double[]).

      Parameters:
      s - the sparse coefficient vector in the wavelet domain (length n, power of 2).
      Returns:
      the measurement vector of length m.
    • backProject

      public double[] backProject(double[] y)
      Computes the adjoint operation v = Φ^T y (back-projection).
      Parameters:
      y - the measurement vector of length m.
      Returns:
      the signal-domain vector of length n.
    • backProjectSparse

      public double[] backProjectSparse(double[] y)
      Computes the adjoint in the sparse (wavelet) domain: v = Ψ^T Φ^T y = DWT(Φ^T y).
      Parameters:
      y - the measurement vector of length m.
      Returns:
      the sparse-domain vector of length n.
    • toMatrix

      public Matrix toMatrix()
      Returns an implicit Matrix that represents the compound operator A = Φ Ψ (or A = Φ when no wavelet is set). The matrix is m × n and supports both mv and tv (adjoint) matrix–vector products without explicitly forming the full matrix.

      Pass the returned matrix directly to BasisPursuit.fit(Matrix, double[]), OMP.fit(Matrix, double[], int), or CoSaMP.fit(Matrix, double[], int).

      Returns:
      the implicit compound measurement matrix.
    • gaussian

      public static MeasurementMatrix gaussian(int m, int n)
      Creates a random Gaussian sensing matrix with entries Φ_{ij} ~ N(0, 1/m).

      Gaussian matrices satisfy the restricted isometry property (RIP) of order k with high probability when m ≥ C k log(n/k), for a universal constant C.

      Parameters:
      m - the number of measurements (rows).
      n - the signal dimension (columns).
      Returns:
      the sensing matrix.
    • bernoulli

      public static MeasurementMatrix bernoulli(int m, int n)
      Creates a random Bernoulli sensing matrix with entries Φ_{ij} ∈ {+1/√m, −1/√m} with equal probability.
      Parameters:
      m - the number of measurements (rows).
      n - the signal dimension (columns).
      Returns:
      the sensing matrix.
    • partial

      public static MeasurementMatrix partial(int[] rows, int n)
      Creates a partial identity (random row-sub-sampling) sensing matrix.

      The sensing matrix is a sub-matrix of the n × n identity formed by randomly selecting m rows without replacement. Equivalently, (Φ x)_i = x_{rows[i]}.

      Parameters:
      rows - the row (sample) indices to retain; must be in [0, n).
      n - the signal dimension.
      Returns:
      the sensing matrix.
    • partial

      public static MeasurementMatrix partial(int m, int n)
      Creates a random partial identity sensing matrix by selecting m rows uniformly at random without replacement.
      Parameters:
      m - the number of measurements.
      n - the signal dimension.
      Returns:
      the sensing matrix.
    • withWavelet

      public MeasurementMatrix withWavelet(Wavelet wavelet)
      Returns a new MeasurementMatrix that combines this sensing matrix with the given wavelet sparsifying basis.
      Parameters:
      wavelet - the wavelet defining the sparsifying transform Ψ.
      Returns:
      the compound measurement matrix.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.