InMemoryDataMatrix implements DataMatrix { @Override public FloatMatrix getColumnMatrixForGene(int entrezGeneId) { Integer rowIndex = entrezIdToRowIndex.get(entrezGeneId); return matrix.getColumn(rowIndex); } InMemoryDataMatrix(FloatMatrix matrix, Map<Integer, Integer> entrezIdToRowIndex); static InMemoryDataMatrix fromMap(Map<Integer, float[]> columns, Map<Integer, Integer> entrezIdToRowIndex); @Override Map<Integer, Integer> getEntrezIdToRowIndex(); @Override FloatMatrix getMatrix(); @Override int numRows(); @Override int numColumns(); @Override boolean containsGene(Integer entrezGeneId); @Override Integer getRowIndexForGene(int entrezGeneId); @Override FloatMatrix getColumnMatrixForGene(int entrezGeneId); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testGetColumnMatrixForGeneInIndex() { float[] column = {0.3f, 1.3f, 2.3f, 3.3f}; FloatMatrix geneColumn = new FloatMatrix(column); assertThat(instance.getColumnMatrixForGene(3333), equalTo(geneColumn)); System.out.println("Column matrix for gene 3333:"); for (float value : geneColumn.toArray()) { System.out.println(value); } System.out.println("Column matrix for gene 3333 multiplied by 2:"); for (float value : instance.getColumnMatrixForGene(3333).mul(2.0f).toArray()) { System.out.println(value); } System.out.printf("%nMatrix is (%d rows * %d columns:%n)", floatMatrix.rows, floatMatrix.columns); System.out.println(floatMatrix); System.out.println("Matrix as columns:"); List<FloatMatrix> columns = floatMatrix.columnsAsList(); for (int i = 0; i < columns.size(); i++) { FloatMatrix matrix = columns.get(i); System.out.printf("Column %d: ", i); for (float value : matrix.toArray()) { System.out.printf("%f ", value); } System.out.println(); } System.out.println("Matrix as rows:"); List<FloatMatrix> rows = floatMatrix.rowsAsList(); for (int i = 0; i < rows.size(); i++) { FloatMatrix matrix = rows.get(i); System.out.printf("Row %d: ", i); for (float value : matrix.toArray()) { System.out.printf("%f, ", value); } System.out.println(); } }