Skip to content

select on multi-dimensional arrays not supported #15

@bigerl

Description

@bigerl

The current implementation doesn't support select on sparse non-2D-matrices.
This limits the usability of 3 and higher dimensional matrices significantly.

The following test code illustrates the problem:

	public void test3DSelect() {
		long n = 1000;
		// init sparse 3D matrix
		SparseMatrix tensor = Matrix.Factory.sparse(ValueType.BOOLEAN, n, n, n);
		tensor.setAsBoolean(true, 1L, 3L, 5L);
		tensor.setAsBoolean(true, 30L, 3L, 5L);
		tensor.setAsBoolean(true, 700L, 3L, 5L);
		
		// define selections to execute
		String[] selectStrings = new String[]{"*;3;5", "1;*;5", "1;3;*"};
		
		// select
		for (String selectString : selectStrings) {
			System.out.println("selection: " + selectString);
			
			// select a 1D vector
			Matrix select = tensor.select(Ret.LINK, selectString); // Exception is thrown here
			Iterable<long[]> result = select.nonZeroCoordinates();
			// take only non-zero values
			Iterator<long[]> resultIt = result.iterator();
			// print result
			while(resultIt.hasNext()){
				long[] entry = resultIt.next();
				for (int i = 0; i < entry.length; i++) {
					System.out.print(entry[i] + " ");
				}
				System.out.print("\n");
			}
		}
	} 

This code throws a RuntimeException("only supported for 2d matrices") at org.ujmp.core.objectmatrix.calculation.Selection.createAnnotation():82.
The whole method createAnnotation() is widely commented out. If I comment line 82 out that throws the exception the both programs runs but returns false results.

With select on sparse 3D+ matrices ujmp would be awesome. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions