Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Commit

Permalink
Add method to set cholesky from a triangular matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
btracey committed Dec 13, 2016
1 parent 315e906 commit 59ef198
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mat64/cholesky.go
Expand Up @@ -86,6 +86,23 @@ func (c *Cholesky) Reset() {
c.cond = math.Inf(1)
}

// SetFromU sets the Cholesky decomposition from the given triangular matrix.
// SetFromU panics if t is not upper triangular. Note that t is copied into,
// not stored inside, the receiver.
func (c *Cholesky) SetFromU(t *TriDense) {
n, kind := t.Triangle()
if kind != matrix.Upper {
panic("cholesky: matrix must be upper triangular")
}
if c.isZero() {
c.chol = NewTriDense(n, matrix.Upper, nil)
} else {
c.chol = NewTriDense(n, matrix.Upper, use(c.chol.mat.Data, n*n))
}
c.chol.Copy(t)
c.updateCond(-1)
}

// Size returns the dimension of the factorized matrix.
func (c *Cholesky) Size() int {
if !c.valid() {
Expand Down

0 comments on commit 59ef198

Please sign in to comment.