diff --git a/mat/lu.go b/mat/lu.go index 31171eab..e8ff34e7 100644 --- a/mat/lu.go +++ b/mat/lu.go @@ -265,16 +265,16 @@ func (m *Dense) Permutation(r int, swaps []int) { } } -// SolveLU solves a system of linear equations using the LU decomposition of a matrix. +// Solve solves a system of linear equations using the LU decomposition of a matrix. // It computes // A * x = b if trans == false // A^T * x = b if trans == true // In both cases, A is represented in LU factorized form, and the matrix x is -// stored into the receiver. +// stored into m. // // If A is singular or near-singular a Condition error is returned. Please see // the documentation for Condition for more information. -func (m *Dense) SolveLU(lu *LU, trans bool, b Matrix) error { +func (lu *LU) Solve(m *Dense, trans bool, b Matrix) error { _, n := lu.lu.Dims() br, bc := b.Dims() if br != n { @@ -308,16 +308,16 @@ func (m *Dense) SolveLU(lu *LU, trans bool, b Matrix) error { return nil } -// SolveLUVec solves a system of linear equations using the LU decomposition of a matrix. +// SolveVec solves a system of linear equations using the LU decomposition of a matrix. // It computes // A * x = b if trans == false // A^T * x = b if trans == true // In both cases, A is represented in LU factorized form, and the matrix x is -// stored into the receiver. +// stored into v. // // If A is singular or near-singular a Condition error is returned. Please see // the documentation for Condition for more information. -func (v *Vector) SolveLUVec(lu *LU, trans bool, b *Vector) error { +func (lu *LU) SolveVec(v *Vector, trans bool, b *Vector) error { _, n := lu.lu.Dims() bn := b.Len() if bn != n { diff --git a/mat/lu_test.go b/mat/lu_test.go index 2b89f704..2523c563 100644 --- a/mat/lu_test.go +++ b/mat/lu_test.go @@ -128,7 +128,7 @@ func TestSolveLU(t *testing.T) { var lu LU lu.Factorize(a) var x Dense - if err := x.SolveLU(&lu, false, b); err != nil { + if err := lu.Solve(&x, false, b); err != nil { continue } var got Dense @@ -149,13 +149,13 @@ func TestSolveLUCond(t *testing.T) { lu.Factorize(test) b := NewDense(m, 2, nil) var x Dense - if err := x.SolveLU(&lu, false, b); err == nil { + if err := lu.Solve(&x, false, b); err == nil { t.Error("No error for near-singular matrix in matrix solve.") } bvec := NewVector(m, nil) var xvec Vector - if err := xvec.SolveLUVec(&lu, false, bvec); err == nil { + if err := lu.SolveVec(&xvec, false, bvec); err == nil { t.Error("No error for near-singular matrix in matrix solve.") } } @@ -176,7 +176,7 @@ func TestSolveLUVec(t *testing.T) { var lu LU lu.Factorize(a) var x Vector - if err := x.SolveLUVec(&lu, false, b); err != nil { + if err := lu.SolveVec(&x, false, b); err != nil { continue } var got Vector diff --git a/mat/solve.go b/mat/solve.go index 6f29fea5..75b0a962 100644 --- a/mat/solve.go +++ b/mat/solve.go @@ -91,7 +91,7 @@ func (m *Dense) Solve(a, b Matrix) error { } var lu LU lu.Factorize(a) - return m.SolveLU(&lu, false, b) + return lu.Solve(m, false, b) case ar > ac: var qr QR qr.Factorize(a)