@@ -48,6 +48,39 @@ func Potrf(a blas64.Symmetric) (t blas64.Triangular, ok bool) {
48
48
return
49
49
}
50
50
51
+ // Gels finds a minimum-norm solution based on the matrices A and B using the
52
+ // QR or LQ factorization. Dgels returns false if the matrix
53
+ // A is singular, and true if this solution was successfully found.
54
+ //
55
+ // The minimization problem solved depends on the input parameters.
56
+ //
57
+ // 1. If m >= n and trans == blas.NoTrans, Dgels finds X such that || A*X - B||_2
58
+ // is minimized.
59
+ // 2. If m < n and trans == blas.NoTrans, Dgels finds the minimum norm solution of
60
+ // A * X = B.
61
+ // 3. If m >= n and trans == blas.Trans, Dgels finds the minimum norm solution of
62
+ // A^T * X = B.
63
+ // 4. If m < n and trans == blas.Trans, Dgels finds X such that || A*X - B||_2
64
+ // is minimized.
65
+ // Note that the least-squares solutions (cases 1 and 3) perform the minimization
66
+ // per column of B. This is not the same as finding the minimum-norm matrix.
67
+ //
68
+ // The matrix A is a general matrix of size m×n and is modified during this call.
69
+ // The input matrix B is of size max(m,n)×nrhs, and serves two purposes. On entry,
70
+ // the elements of b specify the input matrix B. B has size m×nrhs if
71
+ // trans == blas.NoTrans, and n×nrhs if trans == blas.Trans. On exit, the
72
+ // leading submatrix of b contains the solution vectors X. If trans == blas.NoTrans,
73
+ // this submatrix is of size n×nrhs, and of size m×nrhs otherwise.
74
+ //
75
+ // Work is temporary storage, and lwork specifies the usable memory length.
76
+ // At minimum, lwork >= max(m,n) + max(m,n,nrhs), and this function will panic
77
+ // otherwise. A longer work will enable blocked algorithms to be called.
78
+ // In the special case that lwork == -1, work[0] will be set to the optimal working
79
+ // length.
80
+ func Gels (trans blas.Transpose , a blas64.General , b blas64.General , work []float64 , lwork int ) {
81
+ lapack64 .Dgels (trans , a .Rows , a .Cols , b .Cols , a .Data , a .Stride , b .Data , b .Stride , work , lwork )
82
+ }
83
+
51
84
// Geqrf computes the QR factorization of the m×n matrix A using a blocked
52
85
// algorithm. A is modified to contain the information to construct Q and R.
53
86
// The upper triangle of a contains the matrix R. The lower triangular elements
@@ -93,3 +126,39 @@ func Geqrf(a blas64.General, tau, work []float64, lwork int) {
93
126
func Gelqf (a blas64.General , tau , work []float64 , lwork int ) {
94
127
lapack64 .Dgelqf (a .Rows , a .Cols , a .Data , a .Stride , tau , work , lwork )
95
128
}
129
+
130
+ // Getrf computes the LU decomposition of the m×n matrix A.
131
+ // The LU decomposition is a factorization of A into
132
+ // A = P * L * U
133
+ // where P is a permutation matrix, L is a unit lower triangular matrix, and
134
+ // U is a (usually) non-unit upper triangular matrix. On exit, L and U are stored
135
+ // in place into a.
136
+ //
137
+ // ipiv is a permutation vector. It indicates that row i of the matrix was
138
+ // changed with ipiv[i]. ipiv must have length at least min(m,n), and will panic
139
+ // otherwise. ipiv is zero-indexed.
140
+ //
141
+ // Dgetrf is the blocked version of the algorithm.
142
+ //
143
+ // Dgetrf returns whether the matrix A is singular. The LU decomposition will
144
+ // be computed regardless of the singularity of A, but division by zero
145
+ // will occur if the false is returned and the result is used to solve a
146
+ // system of equations.
147
+ func Getrf (a blas64.General , ipiv []int ) bool {
148
+ return lapack64 .Dgetrf (a .Rows , a .Cols , a .Data , a .Stride , ipiv )
149
+ }
150
+
151
+ // Dgetrs solves a system of equations using an LU factorization.
152
+ // The system of equations solved is
153
+ // A * X = B if trans == blas.Trans
154
+ // A^T * X = B if trans == blas.NoTrans
155
+ // A is a general n×n matrix with stride lda. B is a general matrix of size n×nrhs.
156
+ //
157
+ // On entry b contains the elements of the matrix B. On exit, b contains the
158
+ // elements of X, the solution to the system of equations.
159
+ //
160
+ // a and ipiv contain the LU factorization of A and the permutation indices as
161
+ // computed by Getrf. ipiv is zero-indexed.
162
+ func Getrs (trans blas.Transpose , a blas64.General , b blas64.General , ipiv []int ) {
163
+ lapack64 .Dgetrs (trans , a .Cols , b .Cols , a .Data , a .Stride , ipiv , b .Data , b .Stride )
164
+ }
0 commit comments