Archive for the ‘Examples’ Category.

Display a Matrix on the Screen

Every matrix can be visualized in a JFrame by invoking:

matrix.showGUI();

Import a Huge CSV Matrix

If you have a very large CSV file, that is bigger than the available memory, you can link to the file instead of importing the data:

Matrix hugeMatrix = MatrixFactory.linkToFile(FileFormat.CSV, new File("VeryBigFile.csv"));

However, this matrix will be read-only.

Collections

You can also create a ListMatrix instead of an ArrayList. A ListMatrix behaves like a java.List but is a Matrix at the same time:

ListMatrix S = new DefaultListMatrix();
// List methods:
S.add(0.5);
S.clear();
// Matrix methods:
S.exportToFile(someFile);
S.showGUI();
Matrix P = S.plus(5).times(2);
// but: P is not a ListMatrix anymore

The same works also for maps:


MapMatrix map = new DefaultMapMatrix();
map.put(key,o);

Create a sparse matrix

Matrix m = MatrixFactory.sparse(10, 10);

Create empty matrices

Matrix m = MatrixFactory.zeros(10, 10);