MatrixCorrectionTools

MatrixCorrectionTools is a lightweight package that offers a straightforward function called correction!. This function is designed to correct specific properties of a matrix using predefined strategies.

For instance, if a matrix contains zero diagonal entries, this package provides the means to replace (correct) them using either fixed predefined values or a more advanced algorithm based on SVD decomposition.

General functionality

MatrixCorrectionTools.correction!Function
correction!(strategy, input)

Modifies the input in-place using a specified correction strategy. The input can be either a matrix or a number. Certain strategies may require the input to satisfy specific properties beforehand, e.g., the input must be a square matrix. The nothing is a special correction strategy that does nothing and simply returns its input.

source

Available strategies

A strategy must implement a single function: MatrixCorrectionTools.correction!. Note that all defined strategies in the package are subtypes of the [MatrixCorrectionTools.AbstractCorrectionStrategy], but it is not necessary to subtype from it for the correction! function to work.

MatrixCorrectionTools.ReplaceZeroDiagonalEntriesType
ReplaceZeroDiagonalEntries(value)

A correction strategy option for the correction! function. It replaces zero diagonal entries with the predefined value. The LinearAlgebra.diagint function is employed to iterate over the diagonal entries. The iszero function is utilized to determine whether a diagonal entry is zero or not. This strategy converts the type of value to the exact element type of the container.

source
MatrixCorrectionTools.AddToDiagonalEntriesType
AddToDiagonalEntries(value)

A correction strategy option for the correction! function. It adds the predefined value to the diagonal entries. The LinearAlgebra.diagint function is employed to iterate over the diagonal entries. This strategy converts the type of value to the exact element type of the container.

source
MatrixCorrectionTools.ClampDiagonalEntriesType
ClampDiagonalEntries(lo, hi)

A correction strategy option for the correction! function. It clamps the diagonal entries between lo and ho. The LinearAlgebra.diagint function is employed to iterate over the diagonal entries.

source
MatrixCorrectionTools.ClampSingularValuesType
ClampSingularValues(lo, hi)

A correction strategy option for the correction! function. It clamps the singular values of the matrix between lo and hi. The LinearAlgebra.diagint function is employed to iterate over the diagonal entries. The LinearAlgebra.svd function is employed to make the SVD decomposition.

source