Documentation ¶
Index ¶
- func CompAllClose(matrix1, matrix2 Matrix, tolerance float64) bool
- func CompDiagonalClose(matrix1, matrix2 Matrix, tolerance float64) bool
- func CosineSimilarity(vec1 Matrix, vec2 Matrix) float64
- func EuclideanDistance(x, y []float64) float64
- func EuclideanNorm(x []float64) float64
- func RbfKernel(x1 []float64, x2 []float64, sigma float64) float64
- func SumNorm(x []float64) float64
- type Eigen
- type Matrix
- func BackwardsSubstitution(matrix *Matrix, vector *Matrix) Matrix
- func ComponentWiseMultiplication(matrix1, matrix2 Matrix) Matrix
- func CreateAllOnesVector(n int) Matrix
- func CreateIdentity(n int) Matrix
- func MatrixAddition(matrix1, matrix2 Matrix) Matrix
- func MatrixMultiplication(matrix1, matrix2 Matrix) Matrix
- func MatrixSubtraction(matrix1, matrix2 Matrix) Matrix
- func NewMatrix(n, m int) *Matrix
- func QPSolve(D, d Matrix) Matrix
- func SliceToDiagonalMatrix(x []float64) Matrix
- func (matrix *Matrix) AddDiagonal(a float64)
- func (matrix *Matrix) CalculateEigen() Eigen
- func (pointsX *Matrix) CalculateKernelMatrix(pointsY Matrix, sigma float64) Matrix
- func (pointsX *Matrix) CalculateKernelVector(point []float64, sigma float64) Matrix
- func (matrix *Matrix) DiagonalMatrixToSlice() []float64
- func (matrix *Matrix) DiagonalMatrixToVector() Matrix
- func (matrix Matrix) Inverse() Matrix
- func (matrix *Matrix) InverseDiagonal() Matrix
- func (matrix *Matrix) MatrixScalarMultiplication(scalar float64) Matrix
- func (matrix *Matrix) QrDecomposition() (Matrix, Matrix)
- func (matrix *Matrix) SubDiagonal(a float64)
- func (matrix *Matrix) TransposeMatrix() Matrix
- func (matrix *Matrix) VectorToDiagonalMatrix() Matrix
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompAllClose ¶
tests if two matrices are the same within the given tolerance
similar to this numpy function: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html
func CompDiagonalClose ¶
tests if the diagonal of two quadratic matrices is almost same within given tolerance
func CosineSimilarity ¶
Calculate cosine similarity between two vectors
func EuclideanDistance ¶
Calculates the Euclidian Distance between two vectors
func RbfKernel ¶
using the popular rbfKernel (https://en.wikipedia.org/wiki/Radial_basis_function_kernel)
is necessary for the kernel regression and many parts of the algorithms
Types ¶
type Matrix ¶
N represents the number of columns (so that a vector can be in one array)
M represents the number rows (e.g. dimension of a vector)
func BackwardsSubstitution ¶
func ComponentWiseMultiplication ¶
Multiply each element of matrix1 with the coresponding element of matrix2
func CreateAllOnesVector ¶
func MatrixAddition ¶
add the matrices component wise
func MatrixMultiplication ¶
Basic Matrix Multiplication
func MatrixSubtraction ¶
subtract the matrices component wise
func QPSolve ¶
Use the following library https://github.com/badgerodon/quadprog as current solution
might write my own byndings to https://doc.cgal.org/latest/QP_solver/index.html
func SliceToDiagonalMatrix ¶
convert slice to diagonal Matrix
func (*Matrix) AddDiagonal ¶
adds a component to each diagonal element of matrix
ensure that matrix is quadratic
func (*Matrix) CalculateEigen ¶
Calculate Eigen uses the QR Algorithm to calculate the eigenvalues (Schur Factorization) and the Eigenvectors by solving (A - eigenValue * I) * x = 0 for each eigenvalue
func (*Matrix) CalculateKernelMatrix ¶
Applies the Kernel function to every component of the matrix
func (*Matrix) CalculateKernelVector ¶
Applies the Kernel function on every component of the vector
func (*Matrix) DiagonalMatrixToSlice ¶
convert diagonal Matrix to slice
func (*Matrix) DiagonalMatrixToVector ¶
Converts a Diagonal Matrix to a Matrix with N=1
func (Matrix) Inverse ¶
calculates the multiplicative Inverse of the matrix, using the Gauss Jordan Algorithm
to keep the complexity in check, this function can only be performed on symmetric matrices
implementation based on this article: https://www.codesansar.com/numerical-methods/python-program-inverse-matrix-using-gauss-jordan.htm
func (*Matrix) InverseDiagonal ¶
Calculate the Inverse of a DiagonalMatrix
since the inverse of a diagonal matrix can easily be computed by inverting each entry, this function can be used for efficiency
func (*Matrix) MatrixScalarMultiplication ¶
Multiply all elements of the matrix with the scalar
func (*Matrix) QrDecomposition ¶
calculating the QR-Decomposition using the Householder Transformation
Explanation can be found here: https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections
func (*Matrix) SubDiagonal ¶
subtracts a component to each diagonal element of matrix
ensure that matrix is quadratic
func (*Matrix) TransposeMatrix ¶
Transpose the given matrix
func (*Matrix) VectorToDiagonalMatrix ¶
converts a Matrix with N=1 to a Diagonal Matrix