Skip to content

Commit

Permalink
diff/fd: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Jul 31, 2017
1 parent f99e3ef commit 279400f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion diff/fd/hessian_test.go
Expand Up @@ -63,7 +63,7 @@ func TestHessian(t *testing.T) {
2, 5, -3,
1, -3, 6,
}),
b: mat.NewVector(3, []float64{3, -2, -1}),
b: mat.NewVecDense(3, []float64{3, -2, -1}),
c: 5,
},
x: []float64{-1.6, -3, 2},
Expand Down
10 changes: 5 additions & 5 deletions diff/fd/simplefunctions_test.go
Expand Up @@ -57,20 +57,20 @@ func (l LinearFunc) Hess(dst mat.MutableSymmetric, x []float64) {
// QuadFunc is a quadratic function returning 0.5*x'*a*x + b*x + c.
type QuadFunc struct {
a *mat.SymDense
b *mat.Vector
b *mat.VecDense
c float64
}

func (q QuadFunc) Func(x []float64) float64 {
v := mat.NewVector(len(x), x)
var tmp mat.Vector
v := mat.NewVecDense(len(x), x)
var tmp mat.VecDense
tmp.MulVec(q.a, v)
return 0.5*mat.Dot(&tmp, v) + mat.Dot(q.b, v) + q.c
}

func (q QuadFunc) Grad(grad, x []float64) {
var tmp mat.Vector
v := mat.NewVector(len(x), x)
var tmp mat.VecDense
v := mat.NewVecDense(len(x), x)
tmp.MulVec(q.a, v)
for i := range grad {
grad[i] = tmp.At(i, 0) + q.b.At(i, 0)
Expand Down

0 comments on commit 279400f

Please sign in to comment.