public DoubleMatrix2D getRealPart() { final DenseColumnDoubleMatrix2D R = new DenseColumnDoubleMatrix2D(rows, columns); final double[] elemsOther = R.elements(); final int columnStrideOther = R.columnStride(); final int rowStrideOther = R.rowStride(); final int zeroOther = (int) R.index(0, 0); final int zero = (int) index(0, 0); int nthreads = ConcurrencyUtils.getNumberOfThreads();
public DoubleMatrix2D assign(final float[] values) { if (values.length != size()) throw new IllegalArgumentException("Must have same length: length=" + values.length + "rows()*columns()=" + rows() * columns()); final int zero = (int) index(0, 0); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_2D())) { nthreads = Math.min(nthreads, columns); Future<?>[] futures = new Future[nthreads];
/** * Returns the right singular vectors <tt>V</tt>. * * @return <tt>V</tt> */ public DoubleMatrix2D getV() { if (wantUV == false) { throw new IllegalAccessError("Matrix V was not computed"); } else { if (V == null) { if (wantWholeUV == false) { if (columnMatrix) { V = new DenseColumnDoubleMatrix2D(mn, n).assign(elementsVt).viewDice(); } else { V = new DenseDoubleMatrix2D(n, mn).assign(elementsVt); } } else { if (columnMatrix) { V = new DenseColumnDoubleMatrix2D(n, n).assign(elementsVt).viewDice(); } else { V = new DenseDoubleMatrix2D(n, n).assign(elementsVt); } } } return V.copy(); } }
R = new DenseColumnDoubleMatrix2D(m, n); double[] elementsR = (double[]) R.elements(); for (int c = 0; c < n; c++) { return ((DenseColumnDoubleMatrix2D) R.viewPart(0, 0, n, n)).getRowMajor(); } else { return ((DenseColumnDoubleMatrix2D) R).getRowMajor(); return ((DenseColumnDoubleMatrix2D) R.viewPart(0, 0, n, n)).copy(); } else { return R.copy();
try { DenseDoubleAlgebra alg = new DenseDoubleAlgebra(); DenseColumnDoubleMatrix2D matSVD = new DenseColumnDoubleMatrix2D(sizeMax, sizeMax); double value = kernelMat[r][indexNewI] * vector1.get(keyList1.get(r)) * vector2.get(keyList2.get(indexNewI)) / (Double.MIN_NORMAL + norm1) / (Double.MIN_NORMAL + norm2); matSVD.set(r, i, value); for (int r = 0; r < matSVD.rows(); ++r) { double value = 0; matSVD.set(r, i, value); if (matSVD.rows() > 0 && matSVD.columns() > 0) { DenseDoubleSingularValueDecomposition s = alg.svd(matSVD); @SuppressWarnings("unused")
/** * Computes the 2D discrete Hartley transform (DHT) of this matrix. * */ public void dht2() { DoubleMatrix2D transpose = viewDice().copy(); int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dht2 == null) { dht2 = new DoubleDHT_2D(rows, columns); } dht2.forward((double[]) transpose.elements()); this.assign(transpose.viewDice().copy()); ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
public DoubleMatrix2D assign(final DoubleMatrix2D y, final DoubleDoubleFunction function, IntArrayList rowList, IntArrayList columnList) { checkShape(y); if (!(y instanceof DenseColumnDoubleMatrix2D)) { super.assign(y, function); final int[] rowElements = rowList.elements(); final int[] columnElements = columnList.elements(); final double[] otherElements = other.elements(); final int zeroOther = (int) other.index(0, 0); final int zero = (int) index(0, 0); final int columnStrideOther = other.columnStride(); final int rowStrideOther = other.rowStride(); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (size >= ConcurrencyUtils.getThreadsBeginN_2D())) {
if (other == this) return this; // nothing to do checkShape(other); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if (this.isNoView && other.isNoView) { // quickest return this; if (haveSharedCells(other)) { DoubleMatrix2D c = other.copy(); if (!(c instanceof DenseColumnDoubleMatrix2D)) { // should not happen super.assign(other); final int zeroOther = (int) other.index(0, 0); final int zero = (int) index(0, 0); final int columnStrideOther = other.columnStride; final int rowStrideOther = other.rowStride; final double[] otherElements = other.elements; if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_2D())) { nthreads = Math.min(nthreads, columns); Future<?>[] futures = new Future[nthreads];
public DoubleMatrix2D like(int rows, int columns) { return new DenseColumnDoubleMatrix2D(rows, columns); }
throw new IllegalArgumentException("Matrix2D inner dimensions must agree:" + this.toStringShort() + ", " + B.toStringShort()); C = new DenseColumnDoubleMatrix2D(rowsC, columnsC); } else { if (rowsA != C.rows() || columnsB != C.columns()) { throw new IllegalArgumentException("Incompatibe result matrix: " + this.toStringShort() + ", " + B.toStringShort() + ", " + C.toStringShort()); throw new IllegalArgumentException("Matrices must not be identical"); if (!(B instanceof DenseColumnDoubleMatrix2D) || !(C instanceof DenseColumnDoubleMatrix2D) || this.isView() || B.isView() || C.isView()) return super.zMult(B, C, alpha, beta, transposeA, transposeB);
double multiplicator = ((cern.jet.math.tdouble.DoublePlusMultFirst) function).multiplicator; if (multiplicator == 0) { // x[i] = 0*x[i] + y[i] return assign(y); checkShape(y); final double[] otherElements = other.elements; final int zeroOther = (int) other.index(0, 0); final int zero = (int) index(0, 0); final int columnStrideOther = other.columnStride; final int rowStrideOther = other.rowStride; int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_2D())) { nthreads = Math.min(nthreads, columns); Future<?>[] futures = new Future[nthreads];
if (Q == null) { Dplasma.plasma_Init(m, n, 1); Q = new DenseColumnDoubleMatrix2D(m, m); double[] elementsQ = (double[]) Q.elements(); for (int i = 0; i < m; i++) return ((DenseColumnDoubleMatrix2D) Q.viewPart(0, 0, m, n)).getRowMajor(); } else { return ((DenseColumnDoubleMatrix2D) Q).getRowMajor();
return super.aggregate(other, aggr, f); checkShape(other); if (size() == 0) return Double.NaN; final int zero = (int) index(0, 0); final int zeroOther = (int) other.index(0, 0); final int rowStrideOther = other.rowStride(); double a = 0; int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_2D())) { nthreads = Math.min(nthreads, columns); Future<?>[] futures = new Future[nthreads];
return this; if (multiplicator == 0) return assign(0); final int zero = (int) index(0, 0); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_2D())) { nthreads = Math.min(nthreads, columns); Future<?>[] futures = new Future[nthreads];
public void run() { int idx = zero + (firstRow - 1) * rowStride + (columns - 1) * columnStride; for (int r = firstRow; --r >= lastRow;) { double[] currentRow = values[r]; if (currentRow.length != columns) throw new IllegalArgumentException( "Must have same number of columns in every row: column=" + currentRow.length + "columns()=" + columns()); for (int i = idx, c = columns; --c >= 0;) { elements[i] = currentRow[c]; i -= columnStride; } idx -= rowStride; } } });
/** * Constructs a matrix with a copy of the given values. <tt>values</tt> is * required to have the form <tt>values[row][column]</tt> and have exactly * the same number of columns in every row. * <p> * The values are copied. So subsequent changes in <tt>values</tt> are not * reflected in the matrix, and vice-versa. * * @param values * The values to be filled into the new matrix. * @throws IllegalArgumentException * if * <tt>for any 1 <= row < values.length: values[row].length != values[row-1].length</tt> * . */ public DenseColumnDoubleMatrix2D(double[][] values) { this(values.length, values.length == 0 ? 0 : values[0].length); assign(values); }
/** * Computes the 2D discrete Hartley transform (DHT) of this matrix. * */ public void dht2() { DoubleMatrix2D transpose = viewDice().copy(); int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dht2 == null) { dht2 = new DoubleDHT_2D(rows, columns); } dht2.forward((double[]) transpose.elements()); this.assign(transpose.viewDice().copy()); ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
public DoubleMatrix2D assign(final DoubleMatrix2D y, final DoubleDoubleFunction function, IntArrayList rowList, IntArrayList columnList) { checkShape(y); if (!(y instanceof DenseColumnDoubleMatrix2D)) { super.assign(y, function); final int[] rowElements = rowList.elements(); final int[] columnElements = columnList.elements(); final double[] otherElements = other.elements(); final int zeroOther = (int) other.index(0, 0); final int zero = (int) index(0, 0); final int columnStrideOther = other.columnStride(); final int rowStrideOther = other.rowStride(); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (size >= ConcurrencyUtils.getThreadsBeginN_2D())) {
if (other == this) return this; // nothing to do checkShape(other); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if (this.isNoView && other.isNoView) { // quickest return this; if (haveSharedCells(other)) { DoubleMatrix2D c = other.copy(); if (!(c instanceof DenseColumnDoubleMatrix2D)) { // should not happen super.assign(other); final int zeroOther = (int) other.index(0, 0); final int zero = (int) index(0, 0); final int columnStrideOther = other.columnStride; final int rowStrideOther = other.rowStride; final double[] otherElements = other.elements; if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_2D())) { nthreads = Math.min(nthreads, columns); Future<?>[] futures = new Future[nthreads];
public DoubleMatrix2D like(int rows, int columns) { return new DenseColumnDoubleMatrix2D(rows, columns); }