mirror of
https://github.com/gonum/gonum.git
synced 2025-10-27 17:21:18 +08:00
mat: fix typo in SVD VTo check
This commit is contained in:
@@ -228,7 +228,7 @@ func (svd *SVD) VTo(dst *Dense) {
|
|||||||
panic(badFact)
|
panic(badFact)
|
||||||
}
|
}
|
||||||
kind := svd.kind
|
kind := svd.kind
|
||||||
if kind&SVDThinU == 0 && kind&SVDFullV == 0 {
|
if kind&SVDThinV == 0 && kind&SVDFullV == 0 {
|
||||||
panic("svd: v not computed during factorization")
|
panic("svd: v not computed during factorization")
|
||||||
}
|
}
|
||||||
r := svd.vt.Rows
|
r := svd.vt.Rows
|
||||||
|
|||||||
@@ -90,6 +90,41 @@ func TestSVD(t *testing.T) {
|
|||||||
if !EqualApprox(test.a, &ans, 1e-10) {
|
if !EqualApprox(test.a, &ans, 1e-10) {
|
||||||
t.Errorf("A reconstruction mismatch.\nGot:\n%v\nWant:\n%v\n", Formatted(&ans), Formatted(test.a))
|
t.Errorf("A reconstruction mismatch.\nGot:\n%v\nWant:\n%v\n", Formatted(&ans), Formatted(test.a))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, kind := range []SVDKind{
|
||||||
|
SVDThinU, SVDFullU, SVDThinV, SVDFullV,
|
||||||
|
} {
|
||||||
|
var svd SVD
|
||||||
|
svd.Factorize(test.a, kind)
|
||||||
|
if kind&SVDThinU == 0 && kind&SVDFullU == 0 {
|
||||||
|
panicked, message := panics(func() {
|
||||||
|
var dst Dense
|
||||||
|
svd.UTo(&dst)
|
||||||
|
})
|
||||||
|
if !panicked {
|
||||||
|
t.Error("expected panic with no U matrix requested")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
want := "svd: u not computed during factorization"
|
||||||
|
if message != want {
|
||||||
|
t.Errorf("unexpected message: got:%q want:%q", message, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if kind&SVDThinV == 0 && kind&SVDFullV == 0 {
|
||||||
|
panicked, message := panics(func() {
|
||||||
|
var dst Dense
|
||||||
|
svd.VTo(&dst)
|
||||||
|
})
|
||||||
|
if !panicked {
|
||||||
|
t.Error("expected panic with no V matrix requested")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
want := "svd: v not computed during factorization"
|
||||||
|
if message != want {
|
||||||
|
t.Errorf("unexpected message: got:%q want:%q", message, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user