Skip to content

Commit

Permalink
Simplify lq matrix creation and avoid one allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Jan 19, 2014
1 parent 5924af1 commit 47479fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mat64/lq.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func LQ(a *Dense) LQFactor {
panic(ErrShape)
}

lq := &Dense{}
*lq = *a
lq := *a

lDiag := make([]float64, m)
projs := make(Vec, m)
Expand All @@ -54,7 +53,7 @@ func LQ(a *Dense) LQFactor {

// Apply transformation to remaining columns.
if k < m-1 {
*a = *lq
*a = lq
a.View(k+1, k, m-k-1, n-k)
projs = projs[0 : m-k-1]
projs.Mul(a, &hh)
Expand All @@ -67,8 +66,9 @@ func LQ(a *Dense) LQFactor {
}
}
}
*a = lq

return LQFactor{lq, lDiag}
return LQFactor{a, lDiag}
}

// IsFullRank returns whether the L matrix and hence a has full rank.
Expand Down

0 comments on commit 47479fd

Please sign in to comment.