method not working: class scalaSci.EJML.Mat { def Nrows_=(Int): Unit: }

14 views
Skip to first unread message

dREPLACEeLETTEReEjBYeLETTEReAatGMA ILcom

unread,
Nov 5, 2013, 12:10:26 PM11/5/13
to scalalab-...@googlegroups.com
Thanks Stergios !

I have a new bug with method def Nrows_=(Int): Unit, which I need to add a row of zeros to eye0(4)+2. Ok, I will use << zeros0(1,4), but then, what is the aim of "Nrows_=" that appears when doing method completion (keystroles: key enter, key e, key dot, key tab) ?

Below, the scala session:

PATH=jdk1.7.0_45/bin:scala-2.10.3/bin:$PATH scala -classpath ScalaLab2102June12/ScalaLab210.jar:ScalaLab2102June12/lib/`ls ScalaLab2102June12/lib/*.jar | tr '\012' : ` -feature

Welcome to Scala version 2.10.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_45).
Type in expressions to have them evaluated.
Type :help for more information.

scala>  import java.util
import java.util

scala> import scalaSci.EJML.StaticMathsEJML._
import scalaSci.EJML.StaticMathsEJML._

scala>   import scalaSci.EJML._
import scalaSci.EJML._

scala>   import scalaSci.EJML.Mat
import scalaSci.EJML.Mat

scala> var e=eye0(4)+2
e: scalaSci.EJML.Mat =

3.0000  2.0000  2.0000  2.0000 
2.0000  3.0000  2.0000  2.0000 
2.0000  2.0000  3.0000  2.0000 
2.0000  2.0000  2.0000  3.0000 

scala> e.Nrows = 5
e.Nrows: Int = 5

scala> e
java.lang.IllegalArgumentException: Specified element is out of bounds: 4 0
        at org.ejml.data.DenseMatrix64F.get(DenseMatrix64F.java:298)
        at org.ejml.simple.SimpleBase.get(SimpleBase.java:518)
        at scalaSci.EJML.Mat.apply(EJMLMat.scala:461)
        at scalaSci.scalaSciMatrix$class.toDoubleArray(scalaSciMatrix.scala:2204)
        at scalaSci.EJML.Mat.toDoubleArray(EJMLMat.scala:23)
        at scalaSci.scalaSciMatrix$class.toString(scalaSciMatrix.scala:3815)
        at scalaSci.EJML.Mat.toString(EJMLMat.scala:23)
        at scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:324)
        at scala.runtime.ScalaRunTime$.stringOf(ScalaRunTime.scala:329)
        at scala.runtime.ScalaRunTime$.replStringOf(ScalaRunTime.scala:337)
        at .<init>(<console>:10)
        at .<clinit>(<console>)
        at $print(<console>)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:734)
        at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:983)
        at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:573)
        at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:604)
        at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:568)
        at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:756)
        at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:801)
        at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:713)
        at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:577)
        at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:584)
        at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:587)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:878)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:833)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:833)
        at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
        at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:833)
        at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:83)
        at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

It seems the method Nrows_= does not allocate anything.

Stergios Papadimitriou

unread,
Nov 6, 2013, 3:09:20 AM11/6/13
to scalalab-...@googlegroups.com

Hi,

from within ScalaLab that code works.

It's very complicated and unproductive to use ScalaLab libraries from Scala,
why do not use the run scripts, e.g. RunScalaLabWin64.bat, etc. , to run
ScalaLab code
from within the GUI environment?
A lot of initialization material has to be performed to use ScalaLab
libraries from Scala console,
and the facilities of the GUI are all lost.

Therefore, I do not find any utility to use ScalaLab from Scala,
however to compile a stand alone application that uses ScalaLab
libraries is anoher
different think.

Regards
Stergios

dREPLACEeLETTEReEjBYeLETTEReAatGMA ILcom

unread,
Nov 6, 2013, 4:31:49 AM11/6/13
to scalalab-...@googlegroups.com


Le mercredi 6 novembre 2013 09:09:20 UTC+1, Stergios Papadimitriou a écrit :

Hi,

from within ScalaLab that code works.

It does not work on my linux.

I typed: var e=eye0(4)+2;e.Nrows = 5;e

This is then shown:

java.lang.ArrayIndexOutOfBoundsException: 4
    at scalaSci.Mat.apply(Mat.scala:54)
    at scalaSci.scalaSciMatrix$class.toDoubleArray(scalaSciMatrix.scala:2204)
    at scalaSci.Mat.toDoubleArray(Mat.scala:13)
    [snip, see all in attached file, including starting messages of Scalalab]


 
Therefore, I do not find any utility to use ScalaLab from Scala,
however to compile a stand alone application that uses ScalaLab
libraries is anoher
different think.

I need to run scala code in Matlab, because I use EJML.Mat to accelerate matlab code.

I insert here some translations so that others are not totaly bored reading this thread:

// change function to def
// replace : by ::, except for matrix insertions for which insertIntoThis (should have been called updateIntoThis) is better. (chercher (.*,.*) puis ':' pour ratraper mes vieux outils.
// mat(:) should be translated to mat.T.toVec.T
// [mat,mat] should be translated to mat>>>mat
// [mat;mat] should be translated to mat>>mat
// mat' should be translated to mat.T
// ones/zeros/eye/diag should be translated to ones0/...
// temporary+mat should be translated to temporary++mat
// temporary-mat should be translated to temporary--mat
// use .CP/.RP and .CA/.RA for row/column prepend and append,
// .^2 should be translated to pow 2
// sum/min/max/mean/prod( ,1)/... should be translated to .sumR/minR/maxR/meanR/prodR ; sum( ,2) should be translated to .sum
// reshape(mat,a,b) should be translated to mat.T.reshape(b,a).T
// rank, trace, det should be translated to .rank, ...
// max(0,mat) should be translated to mat.filter(_>0)
// min(0,mat) should be translated to mat.filter(_<0)

permission granted to insert these in any rosetta site web.

To Stergios:
Is there anything producing standalone executables in .exe from scalalab ?
startup_and_console.txt

dREPLACEeLETTEReEjBYeLETTEReAatGMA ILcom

unread,
Nov 6, 2013, 5:36:26 AM11/6/13
to scalalab-...@googlegroups.com


Le mercredi 6 novembre 2013 10:31:49 UTC+1, dREPLACEeLETTEReEjBYeLETTEReAatGMA ILcom a écrit :

I typed: var e=eye0(4)+2;e.Nrows = 5;e

I then used shift+F6 to execute. I don't know if it is important. 
Reply all
Reply to author
Forward
0 new messages