Examples of Groovey coding style and interface to UJMP

4.11K viewsScripting
0

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)
}[/code:1wu8betl]

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.
[/quote:1wu8betl]

Feedback, corrections, and further refinements much appreciated.

Simon

0

Simon,

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.

Dominik

You are viewing 1 out of 3 answers, click here to view all answers.

Latest Questions