public double[][] getArray() { double[][] array = new double[sizeOfRows()][sizeOfColumns()]; for (Iterator<MatrixElementI> e = elements(); e.hasNext(); ) { MatrixElementI elem = e.next(); array[elem.getRowIndex()][elem.getColumnIndex()] = elem.getValue(); } return array; }
public CompressedColumnMatrix(MatrixI matrix, int fillInSpace) { _sizeOfRows = matrix.sizeOfRows(); _sizeOfColumns = matrix.sizeOfColumns(); _sizeOfElements = matrix.sizeOfElements(); _fillInSpace = fillInSpace; resizeColumns(_sizeOfColumns); resizeElements(_sizeOfElements + _sizeOfColumns * fillInSpace); int k = 0; for (int j = 0; j < _sizeOfColumns; j++) { _columnBegin[j] = k; for (Iterator<MatrixElementI> e = matrix.columnElements(j); e.hasNext(); ) { MatrixElementI elem = e.next(); int i = elem.getRowIndex(); double v = elem.getValue(); _columnSize[j]++; _values[k] = v; _rowIndex[k++] = i; } k += _fillInSpace; } }