scalala/Scalala — Issue #44: Possible issue with Matrix/Tensor2 apply
Author: afwlehmann
Created: 2012-01-07 21:52:20+00:00
State: open

There might be a small glitch concerning Matrix's or Tensor2's apply method:

```
scala> foo(0 until 2, ::)
res1: scalala.tensor.mutable.Matrix[Int] =
1 2 3 4
5 6 7 8

scala> foo(::, 0 until 2)
res2: scalala.tensor.mutable.Matrix[Int] =
1 2
5 6
```

Up to this place, everything works just fine. But then

```
scala> foo(1, 0 until 2)
res3: scalala.tensor.mutable.Vector[Int] =
0 5
1 6
```

I would have expected a view of the first elements of `foo`'s second row.
Furthermore:

```
scala> foo(5, 0 until 2)
res4: scalala.tensor.mutable.Vector[Int] =
0 7
1 8

scala> foo(99, 0 until 2)
java.lang.ArrayIndexOutOfBoundsException: 99
at scala.runtime.ScalaRunTime$.array_apply(ScalaRunTime.scala:54)
at scalala.tensor.dense.DenseVectorRow.apply(DenseVector.scala:411)
at scalala.tensor.dense.DenseVectorRow.apply(DenseVector.scala:402)
...
```

It might as well be that this is really two issues, one between my ears and the other allowing invalid array indices :)