dip::CovarianceMatrix class

A 2D covariance matrix for computation with 2D vertices.

The matrix is real, symmetric, positive semidefinite. See dip::Polygon::CovarianceMatrix for how to create a covariance matrix.

The elements stored are xx, xy and yy, with xx the top-left element, and xy both the off-diagonal elements, which are equal by definition.

Constructors, destructors, assignment and conversion operators

CovarianceMatrix() defaulted
Default-initialized covariance matrix is all zeros.
CovarianceMatrix(dip::VertexFloat v) explicit
Construct a covariance matrix as the outer product of a vector and itself.
CovarianceMatrix(dip::dfloat xx, dip::dfloat yy, dip::dfloat xy) explicit
Construct a covariance matrix with the three components.

Classes

struct Eigenvalues
Container for matrix eigenvalues. more...

Functions

auto Det() const -> dip::dfloat
Compute determinant of matrix.
auto Eig() const -> dip::CovarianceMatrix::Eigenvalues
Compute eigenvalues of matrix.
auto Ellipse(bool solid = false) const -> dip::CovarianceMatrix::EllipseParameters
Compute parameters of ellipse with same covariance matrix. more...
auto Inv() const -> dip::CovarianceMatrix
Compute inverse of matrix.
auto Project(dip::VertexFloat const& v) const -> dip::dfloat
Computes v’ * C * v, with v’ the transpose of v. This is a positive scalar if v is non-zero, because C (this matrix) is positive semidefinite.
auto xx() const -> dip::dfloat
Read matrix element.
auto xy() const -> dip::dfloat
Read matrix element.
auto yy() const -> dip::dfloat
Read matrix element.

Operators

auto operator*=(dip::dfloat d) -> dip::CovarianceMatrix&
Scale matrix.
auto operator+=(dip::CovarianceMatrix const& other) -> dip::CovarianceMatrix&
Add other matrix to this matrix.
auto operator/=(dip::dfloat d) -> dip::CovarianceMatrix&
Scale matrix.

Function documentation

CovarianceMatrix( ) defaulted

Default-initialized covariance matrix is all zeros.

CovarianceMatrix( dip::VertexFloat v) explicit

Construct a covariance matrix as the outer product of a vector and itself.

CovarianceMatrix( dip::dfloat xx, dip::dfloat yy, dip::dfloat xy) explicit

Construct a covariance matrix with the three components.

dip::dfloat xx( ) const

Read matrix element.

dip::dfloat xy( ) const

Read matrix element.

dip::dfloat yy( ) const

Read matrix element.

dip::dfloat Det( ) const

Compute determinant of matrix.

dip::CovarianceMatrix Inv( ) const

Compute inverse of matrix.

dip::dfloat Project( dip::VertexFloat const& v) const

Computes v’ * C * v, with v’ the transpose of v. This is a positive scalar if v is non-zero, because C (this matrix) is positive semidefinite.

dip::CovarianceMatrix::Eigenvalues Eig( ) const

Compute eigenvalues of matrix.

dip::CovarianceMatrix::EllipseParameters Ellipse( bool solid = false) const

Compute parameters of ellipse with same covariance matrix.

If solid is false (default), then it is assumed that the covariance matrix corresponds to an ellipse shell (e.g. obtained through dip::Polygon::CovarianceMatrixVertices). This is the default for backwards-compatibility. If true, the covariance matrix corresponds to a solid ellipse (e.g. obtained though dip::Polygon::CovarianceMatrixSolid).

dip::CovarianceMatrix& operator+=( dip::CovarianceMatrix const& other)

Add other matrix to this matrix.