mirror of
https://github.com/gonum/gonum.git
synced 2025-10-15 03:30:39 +08:00

This is an API breaking change. NewDense now panics if len(mat) != r*c, unless mat == nil. When mat is nil a new, correctly sized slice is allocated.
27 lines
523 B
Go
27 lines
523 B
Go
// Copyright ©2013 The gonum Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package mat64
|
|
|
|
import (
|
|
check "launchpad.net/gocheck"
|
|
)
|
|
|
|
func (s *S) TestQRD(c *check.C) {
|
|
for _, t := range []struct {
|
|
a *Dense
|
|
}{
|
|
{
|
|
a: NewDense(4, 3, []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
|
|
},
|
|
} {
|
|
qf := QR(DenseCopyOf(t.a))
|
|
r := qf.R()
|
|
q := qf.Q()
|
|
|
|
q.Mul(q, r)
|
|
c.Check(t.a.EqualsApprox(q, 1e-12), check.Equals, true)
|
|
}
|
|
}
|