Change NewDense signature and behaviour

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.
This commit is contained in:
kortschak
2014-01-08 09:56:39 +10:30
parent fadcd6dd7f
commit b10f3a00f3
13 changed files with 87 additions and 112 deletions

View File

@@ -19,22 +19,22 @@ func (s *S) TestLUD(c *check.C) {
sign int
}{
{ // This is a hard coded equivalent of the approach used in the Jama LU test.
a: mustDense(NewDense(3, 3, []float64{
a: NewDense(3, 3, []float64{
0, 2, 3,
4, 5, 6,
7, 8, 9,
})),
}),
l: mustDense(NewDense(3, 3, []float64{
l: NewDense(3, 3, []float64{
1, 0, 0,
0, 1, 0,
0.5714285714285714, 0.2142857142857144, 1,
})),
u: mustDense(NewDense(3, 3, []float64{
}),
u: NewDense(3, 3, []float64{
7, 8, 9,
0, 2, 3,
0, 0, 0.2142857142857144,
})),
}),
pivot: []int{
2, // 0 0 1
0, // 1 0 0
@@ -78,22 +78,22 @@ func (s *S) TestLUDGaussian(c *check.C) {
sign int
}{
{ // This is a hard coded equivalent of the approach used in the Jama LU test.
a: mustDense(NewDense(3, 3, []float64{
a: NewDense(3, 3, []float64{
0, 2, 3,
4, 5, 6,
7, 8, 9,
})),
}),
l: mustDense(NewDense(3, 3, []float64{
l: NewDense(3, 3, []float64{
1, 0, 0,
0, 1, 0,
0.5714285714285714, 0.2142857142857144, 1,
})),
u: mustDense(NewDense(3, 3, []float64{
}),
u: NewDense(3, 3, []float64{
7, 8, 9,
0, 2, 3,
0, 0, 0.2142857142857144,
})),
}),
pivot: []int{
2, // 0 0 1
0, // 1 0 0