/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override final public void identity() { // First get rid of any values already in there for (int i = 0; i < numRows; ++i) { rows[i].clear(); } // Kill compressed representation if there ... update to new values int diagLen = (numRows <= numCols) ? numRows : numCols; values = new double[diagLen]; Arrays.fill(values, 1); firstIndicesForRows = getZeroToNMinusOneArray(numRows + 1); columnIndices = getZeroToNMinusOneArray(diagLen); // We just need to update the first indices for the rows if this is a // tall rectangle matrix for (int i = diagLen; i < numRows + 1; ++i) { firstIndicesForRows[i] = diagLen; } }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override final public void identity() { // First get rid of any values already in there for (int i = 0; i < numRows; ++i) { rows[i].clear(); } // Kill compressed representation if there ... update to new values int diagLen = (numRows <= numCols) ? numRows : numCols; values = new double[diagLen]; Arrays.fill(values, 1); firstIndicesForRows = getZeroToNMinusOneArray(numRows + 1); columnIndices = getZeroToNMinusOneArray(diagLen); // We just need to update the first indices for the rows if this is a // tall rectangle matrix for (int i = diagLen; i < numRows + 1; ++i) { firstIndicesForRows[i] = diagLen; } }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override final public void identity() { // First get rid of any values already in there for (int i = 0; i < numRows; ++i) { rows[i].clear(); } // Kill compressed representation if there ... update to new values int diagLen = (numRows <= numCols) ? numRows : numCols; values = new double[diagLen]; Arrays.fill(values, 1); firstIndicesForRows = getZeroToNMinusOneArray(numRows + 1); columnIndices = getZeroToNMinusOneArray(diagLen); // We just need to update the first indices for the rows if this is a // tall rectangle matrix for (int i = diagLen; i < numRows + 1; ++i) { firstIndicesForRows[i] = diagLen; } }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override public final void plusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); if (!isCompressed()) { compress(); } // Count the number of new values to add. int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.OR); // Now start up the values for the sum matrix double[] newVals = new double[nnz]; int[] newFirstIdxsForRows = new int[firstIndicesForRows.length]; int[] newColIdxs = new int[nnz]; // Now do the logic for adding plusEqualsScaled(newColIdxs, newFirstIdxsForRows, newVals, other, 1); // Now store the new values in me values = newVals; columnIndices = newColIdxs; firstIndicesForRows = newFirstIdxsForRows; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override public void scaledPlusEquals( final DiagonalMatrix other, final double scaleFactor) { this.assertSameDimensions(other); if (!isCompressed()) { compress(); } // Count the number of new values to add. int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.OR); // Now start up the values for the sum matrix double[] newVals = new double[nnz]; int[] newFirstIdxsForRows = new int[firstIndicesForRows.length]; int[] newColIdxs = new int[nnz]; // Now do the logic for adding plusEqualsScaled(newColIdxs, newFirstIdxsForRows, newVals, other, 1); // Now store the new values in me values = newVals; columnIndices = newColIdxs; firstIndicesForRows = newFirstIdxsForRows; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override public final void plusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); if (!isCompressed()) { compress(); } // Count the number of new values to add. int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.OR); // Now start up the values for the sum matrix double[] newVals = new double[nnz]; int[] newFirstIdxsForRows = new int[firstIndicesForRows.length]; int[] newColIdxs = new int[nnz]; // Now do the logic for adding plusEqualsScaled(newColIdxs, newFirstIdxsForRows, newVals, other, 1); // Now store the new values in me values = newVals; columnIndices = newColIdxs; firstIndicesForRows = newFirstIdxsForRows; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override public final void minusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); if (!isCompressed()) { compress(); } // Count the number of new values to add. int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.OR); // Initialize the new matrix storage double[] newVals = new double[nnz]; int[] newFirstIdxsForRows = new int[firstIndicesForRows.length]; int[] newColIdxs = new int[nnz]; // Actually do the computation plusEqualsScaled(newColIdxs, newFirstIdxsForRows, newVals, other, -1); // Store the results values = newVals; columnIndices = newColIdxs; firstIndicesForRows = newFirstIdxsForRows; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override public void scaledPlusEquals( final DiagonalMatrix other, final double scaleFactor) { this.assertSameDimensions(other); if (!isCompressed()) { compress(); } // Count the number of new values to add. int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.OR); // Now start up the values for the sum matrix double[] newVals = new double[nnz]; int[] newFirstIdxsForRows = new int[firstIndicesForRows.length]; int[] newColIdxs = new int[nnz]; // Now do the logic for adding plusEqualsScaled(newColIdxs, newFirstIdxsForRows, newVals, other, 1); // Now store the new values in me values = newVals; columnIndices = newColIdxs; firstIndicesForRows = newFirstIdxsForRows; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override public final void plusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); if (!isCompressed()) { compress(); } // Count the number of new values to add. int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.OR); // Now start up the values for the sum matrix double[] newVals = new double[nnz]; int[] newFirstIdxsForRows = new int[firstIndicesForRows.length]; int[] newColIdxs = new int[nnz]; // Now do the logic for adding plusEqualsScaled(newColIdxs, newFirstIdxsForRows, newVals, other, 1); // Now store the new values in me values = newVals; columnIndices = newColIdxs; firstIndicesForRows = newFirstIdxsForRows; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override public final void minusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); if (!isCompressed()) { compress(); } // Count the number of new values to add. int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.OR); // Initialize the new matrix storage double[] newVals = new double[nnz]; int[] newFirstIdxsForRows = new int[firstIndicesForRows.length]; int[] newColIdxs = new int[nnz]; // Actually do the computation plusEqualsScaled(newColIdxs, newFirstIdxsForRows, newVals, other, -1); // Store the results values = newVals; columnIndices = newColIdxs; firstIndicesForRows = newFirstIdxsForRows; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override public final void minusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); if (!isCompressed()) { compress(); } // Count the number of new values to add. int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.OR); // Initialize the new matrix storage double[] newVals = new double[nnz]; int[] newFirstIdxsForRows = new int[firstIndicesForRows.length]; int[] newColIdxs = new int[nnz]; // Actually do the computation plusEqualsScaled(newColIdxs, newFirstIdxsForRows, newVals, other, -1); // Store the results values = newVals; columnIndices = newColIdxs; firstIndicesForRows = newFirstIdxsForRows; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. */ @Override public void scaledPlusEquals( final DiagonalMatrix other, final double scaleFactor) { this.assertSameDimensions(other); if (!isCompressed()) { compress(); } // Count the number of new values to add. int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.OR); // Now start up the values for the sum matrix double[] newVals = new double[nnz]; int[] newFirstIdxsForRows = new int[firstIndicesForRows.length]; int[] newColIdxs = new int[nnz]; // Now do the logic for adding plusEqualsScaled(newColIdxs, newFirstIdxsForRows, newVals, other, 1); // Now store the new values in me values = newVals; columnIndices = newColIdxs; firstIndicesForRows = newFirstIdxsForRows; }
int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.AND);
int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.AND);
int nnz = getNumNonZeroWhenCombinedWith(getZeroToNMinusOneArray( other.getNumRows()), getZeroToNMinusOneArray(other.getNumRows() + 1), Combiner.AND);