scalala/Scalala — Issue #49: DenseVectorCol.horzcat throws DomainException when result is not square
Author: daveswartz
Created: 2012-02-05 16:39:35+00:00
State: open

The use of horzcat below when the result is not a square matrix:

````scala
val vvc: DenseMatrix[Int] =
DenseVectorCol.horzcat[Int](DenseVectorCol(1,4,7),
DenseVectorCol(2,5,8))
````

results in the exception below:

````scala
scalala.tensor.domain.DomainException: Incompatible domain: IndexDomain(3) for IndexDomain(2)
at scalala.tensor.DomainFunction$class.checkDomain(DomainFunction.scala:54)
at scalala.tensor.dense.DenseVectorCol.checkDomain(DenseVector.scala:442)
at scalala.tensor.dense.LowPriorityDenseImplicits$CanJoinDenseWithNonDense.joinAll(DenseVector.scala:111)
at scalala.tensor.dense.LowPriorityDenseImplicits$CanJoinDenseWithNonDense.joinAll(DenseVector.scala:106)
at scalala.tensor.mutable.TensorImplicitsLevel1$$anon$4.apply(Tensor.scala:198)
at scalala.tensor.mutable.TensorImplicitsLevel1$$anon$4.apply(Tensor.scala:194)
at scalala.operators.MutableNumericOps$class.$colon$eq(Ops.scala:199)
at scalala.tensor.dense.DenseVectorCol.$colon$eq(DenseVector.scala:442)
at scalala.tensor.dense.DenseVectorColConstructors$$anonfun$horzcat$4.apply(DenseVector.scala:625)
at scalala.tensor.dense.DenseVectorColConstructors$$anonfun$horzcat$4.apply(DenseVector.scala:624)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:60)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:44)
at scalala.tensor.dense.DenseVectorColConstructors$class.horzcat(DenseVector.scala:624)
at scalala.tensor.dense.DenseVectorCol$.horzcat(DenseVector.scala:644)
at .(:36)
at .()
at .(:11)
at .()
at $print()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:914)
at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:546)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:577)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:543)
at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:694)
at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:745)
at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:712)
at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:745)
at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:651)
at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:542)
at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:550)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822)
at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:851)
at xsbt.ConsoleInterface.run(ConsoleInterface.scala:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:57)
at sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:48)
at sbt.Console.console0$1(Console.scala:23)
at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala:24)
at sbt.TrapExit$.executeMain$1(TrapExit.scala:33)
at sbt.TrapExit$$anon$1.run(TrapExit.scala:42)
````

Looking at line 623 of DenseVector:

````scala
val result = DenseMatrix.zeros[V](vectors.size, size)
````

When I changed the above line to:

````scala
val result = DenseMatrix.zeros[V](size, vectors.size)
````

The result became:

````scala
res45: scalala.tensor.dense.DenseMatrix[Int] =
1 2
4 5
7 8
````

If that is the right fix, let me know how you want the patch submitted (I am new to git and github).