Permalink
Browse files

stupid bug in horzcat. added test.

  • Loading branch information...
1 parent 2cd1bad commit f8b1e8046cfaacceaa9f401ccc51b3c2024300fa @dlwh committed Oct 2, 2012
@@ -200,8 +200,8 @@ object DenseVector extends VectorConstructors[DenseVector] with DenseVector_Gene
val size = vectors.head.size
if (!(vectors forall (_.size == size)))
throw new IllegalArgumentException("All vectors must have the same size!")
- val result = DenseMatrix.zeros[V](vectors.size, size)
- for ((v, col) <- vectors zip (0 until vectors.size))
+ val result = DenseMatrix.zeros[V](size, vectors.size)
+ for ((v, col) <- vectors.zipWithIndex)
result(::, col) := v
result
}
@@ -237,6 +237,14 @@ class DenseVectorTest extends FunSuite with Checkers {
assert(DenseVector.vertcat(a1, a2) === res)
}
+
+ test("horzcat") {
+ val a1 = DenseVector[Double](1, 2, 3)
+ val a2 = DenseVector[Double](2, 3, 4)
+ val res = DenseMatrix( (1.0, 2.0), (2.0, 3.0), (3.0, 4.0))
+ assert(DenseVector.horzcat(a1, a2) === res)
+ }
+
test("Negation") {
val a1 = DenseVector(1.0, 2.0, 3.0)
assert(-a1 == DenseVector(-1.0, -2.0, -3.0))

0 comments on commit f8b1e80

Please sign in to comment.