Examples of Groovey coding style and interface to UJMP

3.27K viewsScripting

I hope the attached may be of some interest to others.

It demonstrates some features of Groovey coding, such as closures – which avoid the need to write all those tedious loops when scanning the children of classes such as Matrices and Categories. Example:
[code:1wu8betl]def int matrixIndexFromName(String mName)
def listOfMatrices = []
matrices.each{listOfMatrices.add( it.name )}
// or [I]matrices.each{listOfMatrices << it.name }[/I]
int i = listOfMatrices.indexOf(mName)

It uses Java Swing to get user input.

It also includes a primitive interface to Universal Java Matrix Package (UJMP), which enables a Quantrix matrix to be be imported and processed using matrix algebra operations. To use this capability you need to download the UJMP code ([url:1wu8betl]http://www.ujmp.org/[/url:1wu8betl]) and put in the ScriptingLibs directory per:
[quote="Ben G":1wu8betl]Dominik:

External JARs can be imported as of 4.0.42. For security reasons, we decided to use a single blessed location for external libraries rather than making the entire class path available to scripting. To install a library for use with scripting, follow these steps:

1) Open the folder on your hard drive where Quantrix is installed, and within that folder create a subfolder called “”ScriptingLibs””.

2) Place any JARs you need to use within the ScriptingLibs folder.

3) Restart Quantrix if necessary. In your script, import the classes you would like to use as you would in normal Groovy or Java source.

Feedback, corrections, and further refinements much appreciated.



Hi Simon,

Thank you for your hints.

I could resolve my issues now and your model is working fine. The reason for the error message and the missing GUI window was the “jdmp-complete-0.1.1.jar” (a data mining java library from the UJMP developers) file I had previously added to the ScriptingLibs folder as well. You can’t have both libraries of them in the ScriptingLibs folder in Quantrix the same time.

The addition of the UJMP library to Quantrix scripting will allow us now to develop sophisticated applications using Linear Algebra.

Thanks again and have a nice weekend!



I’m not aware that you need to add anything else. I do have JRE 1.6 on my machine but I don’t think you should need that to run the code.

I’d suggest copying the Action script (for the UMJP demo) into the scripting console and executing it line by line to see where it fails. It sounds like the MatrixFactory method is working to create the UJMP matrix, and then the script is failing on either the showGUI() or reshape() – which seems very odd…

Please let me know if you can find anything else.



Many thanks for this excellent post!

The two scripts regarding UJMP are both not working on my notebook.

1. Script “UJMP Tutorial demo”
The matrix m6 is not shown (nothing appears on the screen -> “m6.showGUI()” seems not to work)

2. Script “Convert matrix to UJMP”
Throws an error message. See the attached file.

I have added the “ujmp-complete-0.2.5.jar” to the ScriptingLibs folder. Do have to change some properties elsewhere?

Any help is appreciated very much.