mirror of
https://github.com/gonum/gonum.git
synced 2025-10-06 07:37:03 +08:00
diff/fd: fix build
This commit is contained in:
@@ -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},
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user