algorithm

package
v0.0.0-...-2ad892a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2023 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CholeskyDecomposition

type CholeskyDecomposition struct {
	L     [][]float64 // Array for internal storage of decomposition.
	N     int         // Row and column dimension (square matrix).
	Isspd bool        // Symmetric and positive definite flag.
}
  • Cholesky Decomposition. <P> For a symmetric, positive definite matrix A, the Cholesky decomposition is an lower triangular matrix L so that A = L*L'. <P> If the matrix is not symmetric or positive definite, the constructor returns a partial decomposition and sets an internal flag that may be queried by the isSPD() method.

func NewCholeskyDecomposition

func NewCholeskyDecomposition(matrix *Matrix) *CholeskyDecomposition

func (*CholeskyDecomposition) GetL

func (c *CholeskyDecomposition) GetL() *Matrix

func (*CholeskyDecomposition) Solve

func (c *CholeskyDecomposition) Solve(B *Matrix) *Matrix

* Solve A*X = B @param B A Matrix with as many rows as A and any number of columns. @return X so that L*L'*X = B @exception IllegalArgumentException Matrix row dimensions must agree. @exception RuntimeException Matrix is not symmetric positive definite.

type EigenvalueDecomposition

type EigenvalueDecomposition struct {
	N           int         // Row and column dimension (square matrix).
	IsSymmetric bool        //  Symmetry flag.
	D           []float64   // Arrays for internal storage of eigenvalues.
	E           []float64   // Array for internal storage of eigenvectors.
	V           [][]float64 // Array for internal storage of eigenvectors.
	H           [][]float64 //  Array for internal storage of nonsymmetric Hessenberg form.
	Ort         []float64   // Working storage for nonsymmetric algorithm.
}

func NewEigenvalueDecomposition

func NewEigenvalueDecomposition(matrix *Matrix) *EigenvalueDecomposition

func (*EigenvalueDecomposition) Cdiv

func (e *EigenvalueDecomposition) Cdiv(xr, xi, yr, yi float64)

func (*EigenvalueDecomposition) GetD

func (e *EigenvalueDecomposition) GetD() *Matrix

func (*EigenvalueDecomposition) GetImagEigenvalues

func (e *EigenvalueDecomposition) GetImagEigenvalues() []float64

func (*EigenvalueDecomposition) GetRealEigenvalues

func (e *EigenvalueDecomposition) GetRealEigenvalues() []float64

func (*EigenvalueDecomposition) GetV

func (e *EigenvalueDecomposition) GetV() *Matrix

func (*EigenvalueDecomposition) Getd

func (e *EigenvalueDecomposition) Getd() []float64

func (*EigenvalueDecomposition) Hqr2

func (e *EigenvalueDecomposition) Hqr2()

func (*EigenvalueDecomposition) Orthes

func (e *EigenvalueDecomposition) Orthes()

Nonsymmetric reduction to Hessenberg form.

func (*EigenvalueDecomposition) Tql2

func (e *EigenvalueDecomposition) Tql2()

func (*EigenvalueDecomposition) Tred2

func (e *EigenvalueDecomposition) Tred2()

This is derived from the Algol procedures tred2 by Bowdler, Martin, Reinsch, and Wilkinson, Handbook for Auto. Comp., Vol.ii-Linear Algebra, and the corresponding Fortran subroutine in EISPACK.

type LUDecomposition

type LUDecomposition struct {
	LU [][]float64 // Array for internal storage of decomposition.
	N  int         /** Row and column dimensions, and pivot sign.
	  column dimension.
	  l row dimension.
	  pivot sign. */
	M       int
	Pivsign int
	Piv     []int //Internal storage of pivot vector.
}

func NewLUDecomposition

func NewLUDecomposition(a *Matrix) *LUDecomposition

func (*LUDecomposition) Det

func (lud *LUDecomposition) Det() float64

* Determinant @return det(A)

func (*LUDecomposition) GetDoublePivot

func (lud *LUDecomposition) GetDoublePivot() []float64

* Return pivot permutation vector as a one-dimensional double array @return (double) piv

func (*LUDecomposition) GetL

func (lud *LUDecomposition) GetL() *Matrix

* Return lower triangular factor @return L

func (*LUDecomposition) GetPivot

func (lud *LUDecomposition) GetPivot() []int

func (*LUDecomposition) GetU

func (lud *LUDecomposition) GetU() *Matrix

* Return upper triangular factor @return U

func (*LUDecomposition) IsNonsingular

func (lud *LUDecomposition) IsNonsingular() bool

func (*LUDecomposition) Solve

func (lud *LUDecomposition) Solve(b *Matrix) *Matrix

type Matrix

type Matrix struct {
	A [][]float64
	M int
	N int
}

*

Jama = Java Matrix class.

<P>

The Java Matrix Class provides the fundamental operations of numerical
linear algebra.  Various constructors create Matrices from two dimensional
arrays of double precision floating point numbers.  Various "gets" and
"sets" provide access to submatrices and matrix elements.  Several methods
implement basic matrix arithmetic, including matrix addition and
multiplication, matrix norms, and element-by-element array operations.
Methods for reading and printing matrices are also included.  All the
operations in this version of the Matrix Class involve real matrices.
Complex matrices may be handled in a future version.

<P>

Five fundamental matrix decompositions, which consist of pairs or triples
of matrices, permutation vectors, and the like, produce results in five
decomposition classes.  These decompositions are accessed by the Matrix
class to compute solutions of simultaneous linear equations, determinants,
inverses and other matrix functions.  The five decompositions are:

<P><UL>

<LI>Cholesky Decomposition of symmetric, positive definite matrices.
<LI>LU Decomposition of rectangular matrices.
<LI>QR Decomposition of rectangular matrices.
<LI>Singular Value Decomposition of rectangular matrices.
<LI>Eigenvalue Decomposition of both symmetric and nonsymmetric square matrices.

</UL> <DL> <DT><B>Example of use:</B></DT> <P> <DD>Solve a linear system A x = b and compute the residual norm, ||b - A x||. <P><PRE>

double[][] vals = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}};
Matrix A = new Matrix(vals);
Matrix b = Matrix.random(3,1);
Matrix x = A.solve(b);
Matrix r = A.times(x).minus(b);
double rnorm = r.normInf();

</PRE></DD> </DL>

@author The MathWorks, Inc. and the National Institute of Standards and Technology. @version 5 August 1998

func NewMatrix

func NewMatrix(m, n int) *Matrix

func NewMatrixFilled

func NewMatrixFilled(m, n, s int) *Matrix

func NewMatrixWithArrays

func NewMatrixWithArrays(a [][]float64) (*Matrix, error)

func NewMatrixWithMatrix

func NewMatrixWithMatrix(a [][]float64, m, n int) (*Matrix, error)

func (*Matrix) ColumnsDimension

func (m *Matrix) ColumnsDimension() int

func (*Matrix) Eig

func (m *Matrix) Eig() *EigenvalueDecomposition

func (*Matrix) GetMatrix

func (m *Matrix) GetMatrix(r []int, j0, j1 int) *Matrix

func (*Matrix) GetMatrix2

func (m *Matrix) GetMatrix2(i0, i1 int, c []int) *Matrix

func (*Matrix) GetMatrix3

func (m *Matrix) GetMatrix3(i0, i1, j0, j1 int) *Matrix

func (*Matrix) Identity

func (mat *Matrix) Identity(m, n int) *Matrix

func (*Matrix) Inverse

func (m *Matrix) Inverse() *Matrix

func (*Matrix) Minus

func (m *Matrix) Minus(b *Matrix) *Matrix

func (*Matrix) Plus

func (m *Matrix) Plus(b *Matrix) *Matrix

func (*Matrix) PlusEqual

func (m *Matrix) PlusEqual(b *Matrix)

func (*Matrix) RowsDimension

func (m *Matrix) RowsDimension() int

func (*Matrix) SetMatrix

func (m *Matrix) SetMatrix(i0, i1, j0, j1 int, x *Matrix)

func (*Matrix) Solve

func (m *Matrix) Solve(b *Matrix) *Matrix

func (*Matrix) Times

func (m *Matrix) Times(s float64) *Matrix

func (*Matrix) TimesMatrix

func (m *Matrix) TimesMatrix(b *Matrix) *Matrix

func (*Matrix) Tostring

func (m *Matrix) Tostring() string

func (*Matrix) Transpose

func (m *Matrix) Transpose() *Matrix

func (*Matrix) UnVectorize

func (mat *Matrix) UnVectorize(width, height int) *Matrix

func (*Matrix) Vectorize

func (mat *Matrix) Vectorize() *Matrix

type QRDecomposition

type QRDecomposition struct {
	QR    [][]float64 // Array for internal storage of decomposition.
	M     int         //column dimension.
	N     int         //row dimension.
	Rdiag []float64   //Array for internal storage of diagonal of R.
}

func NewQRDecomposition

func NewQRDecomposition(a *Matrix) *QRDecomposition

func (*QRDecomposition) IsFullRank

func (q *QRDecomposition) IsFullRank() bool

func (*QRDecomposition) Solve

func (q *QRDecomposition) Solve(b *Matrix) *Matrix

type SingularValueDecomposition

type SingularValueDecomposition struct {

	/** Arrays for internal storage of U and V.
	@serial internal storage of U.
	@serial internal storage of V.
	*/
	U [][]float64
	V [][]float64
	/** Array for internal storage of singular values.
	@serial internal storage of singular values.
	*/
	S []float64

	/** Row and column dimensions.
	@serial row dimension.
	@serial column dimension.
	*/
	M int
	N int
}

func NewSingularValueDecomposition

func NewSingularValueDecomposition(matrix *Matrix) *SingularValueDecomposition

func (*SingularValueDecomposition) Cond

* Two norm condition number @return max(S)/min(S)

func (*SingularValueDecomposition) GetS

* Return the diagonal matrix of singular values @return S

func (*SingularValueDecomposition) GetSingularValues

func (s *SingularValueDecomposition) GetSingularValues() []float64

func (*SingularValueDecomposition) GetU

* Return the left singular vectors @return U

func (*SingularValueDecomposition) GetV

* Return the right singular vectors @return V

func (*SingularValueDecomposition) Norm2

* Two norm @return max(S)

func (*SingularValueDecomposition) Rank

func (s *SingularValueDecomposition) Rank() int

* Effective numerical matrix rank @return Number of nonnegligible singular values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL