Skip to content

Commit

Permalink
Changed gonum vectorsto
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericlemoine committed Sep 30, 2019
1 parent bfa8636 commit 6c135f6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion models/dna/f81.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (m *F81Model) InitModel(piA, piC, piG, piT float64) (err error) {
}

func (m *F81Model) computeEigens() (err error) {
var u mat.CDense
// Compute eigen values, left and right eigenvectors of Q
eigen := &mat.Eigen{}
if ok := eigen.Factorize(m.qmatrix, mat.EigenRight); !ok {
Expand All @@ -58,7 +59,7 @@ func (m *F81Model) computeEigens() (err error) {
for i, b := range eigen.Values(nil) {
val[i] = real(b)
}
u := eigen.VectorsTo(nil)
eigen.VectorsTo(&u)
reigenvect := mat.NewDense(4, 4, nil)
leigenvect := mat.NewDense(4, 4, nil)
reigenvect.Apply(func(i, j int, val float64) float64 { return real(u.At(i, j)) }, reigenvect)
Expand Down
4 changes: 3 additions & 1 deletion models/dna/gtr.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func (m *GTRModel) InitModel(d, f, b, e, a, c, piA, piC, piG, piT float64) (err
}

func (m *GTRModel) computeEigens() (err error) {
var u mat.CDense

// Compute eigen values, left and right eigenvectors of Q
eigen := &mat.Eigen{}
if ok := eigen.Factorize(m.qmatrix, mat.EigenRight); !ok {
Expand All @@ -58,7 +60,7 @@ func (m *GTRModel) computeEigens() (err error) {
for i, b := range eigen.Values(nil) {
val[i] = real(b)
}
u := eigen.VectorsTo(nil)
eigen.VectorsTo(&u)
reigenvect := mat.NewDense(4, 4, nil)
leigenvect := mat.NewDense(4, 4, nil)
reigenvect.Apply(func(i, j int, val float64) float64 { return real(u.At(i, j)) }, reigenvect)
Expand Down
4 changes: 3 additions & 1 deletion models/dna/tn93.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func (m *TN93Model) InitModel(kappa1, kappa2, piA, piC, piG, piT float64) (err e
}

func (m *TN93Model) computeEigens() (err error) {
var u mat.CDense

// Compute eigen values, left and right eigenvectors of Q
eigen := &mat.Eigen{}
if ok := eigen.Factorize(m.qmatrix, mat.EigenRight); !ok {
Expand All @@ -53,7 +55,7 @@ func (m *TN93Model) computeEigens() (err error) {
for i, b := range eigen.Values(nil) {
val[i] = real(b)
}
u := eigen.VectorsTo(nil)
eigen.VectorsTo(&u)
reigenvect := mat.NewDense(4, 4, nil)
leigenvect := mat.NewDense(4, 4, nil)
reigenvect.Apply(func(i, j int, val float64) float64 { return real(u.At(i, j)) }, reigenvect)
Expand Down
3 changes: 2 additions & 1 deletion models/protein/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (model *ProtModel) InitModel(aafreqs []float64) error {
var i, j int
var sum float64
var ok bool
var u mat.CDense

ns := 20

Expand Down Expand Up @@ -132,7 +133,7 @@ func (model *ProtModel) InitModel(aafreqs []float64) error {
}
model.reigenvect = mat.NewDense(ns, ns, nil)
model.leigenvect = mat.NewDense(20, 20, nil)
u := model.eigen.VectorsTo(nil)
model.eigen.VectorsTo(&u)
model.eval = make([]float64, ns)
for i, b := range model.eigen.Values(nil) {
model.eval[i] = real(b)
Expand Down

0 comments on commit 6c135f6

Please sign in to comment.