public DoubleMatrix3D getImaginaryPart() { final DenseDoubleMatrix3D Im = new DenseDoubleMatrix3D(slices, rows, columns); final double[] elemsOther = Im.elements(); final int sliceStrideOther = Im.sliceStride(); final int rowStrideOther = Im.rowStride(); final int columnStrideOther = Im.columnStride(); final int zeroOther = (int) Im.index(0, 0, 0); final int zero = (int) index(0, 0, 0); int nthreads = ConcurrencyUtils.getNumberOfThreads();
/** * Constructs a matrix with a copy of the given values. <tt>values</tt> is * required to have the form <tt>values[slice][row][column]</tt> and have * exactly the same number of rows in in every slice and exactly the same * number of columns in 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 <= slice < values.length: values[slice].length != values[slice-1].length</tt> * . * @throws IllegalArgumentException * if * <tt>for any 1 <= row < values[0].length: values[slice][row].length != values[slice][row-1].length</tt> * . */ public DenseDoubleMatrix3D(double[][][] values) { this(values.length, (values.length == 0 ? 0 : values[0].length), (values.length == 0 ? 0 : values[0].length == 0 ? 0 : values[0][0].length)); assign(values); }
if (other == this) return this; checkShape(other); if (haveSharedCells(other)) { DoubleMatrix3D c = other.copy(); if (!(c instanceof DenseDoubleMatrix3D)) { // should not happen super.assign(source); return this; } else { final int zero = (int) index(0, 0, 0); final int zeroOther = (int) other_final.index(0, 0, 0); final int sliceStrideOther = other_final.sliceStride; final int rowStrideOther = other_final.rowStride; final int columnStrideOther = other_final.columnStride; final double[] elementsOther = other_final.elements; if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_3D())) { nthreads = Math.min(nthreads, slices); Future<?>[] futures = new Future[nthreads];
public void run() { int idx; for (int s = firstSlice; s < lastSlice; s++) { double[][] currentSlice = values[s]; if (currentSlice.length != rows) throw new IllegalArgumentException( "Must have same number of rows in every slice: rows=" + currentSlice.length + "rows()=" + rows()); for (int r = 0; r < rows; r++) { idx = zero + s * sliceStride + r * rowStride; double[] currentRow = currentSlice[r]; if (currentRow.length != columns) throw new IllegalArgumentException( "Must have same number of columns in every row: columns=" + currentRow.length + "columns()=" + columns()); for (int c = 0; c < columns; c++) { elements[idx] = currentRow[c]; idx += columnStride; } } } } });
public DoubleMatrix3D assign(final double[] values) { if (values.length != size()) throw new IllegalArgumentException("Must have same length: length=" + values.length + "slices()*rows()*columns()=" + slices() * rows() * columns()); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if (this.isNoView) { System.arraycopy(values, 0, this.elements, 0, values.length); } else { final int zero = (int) index(0, 0, 0); if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_3D())) { nthreads = Math.min(nthreads, slices); Future<?>[] futures = new Future[nthreads];
/** * Computes the 3D discrete Hartley transform (DHT) of this matrix. * */ public void dht3() { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dht3 == null) { dht3 = new DoubleDHT_3D(slices, rows, columns); } if (isNoView == true) { dht3.forward(elements); } else { DoubleMatrix3D copy = this.copy(); dht3.forward((double[]) copy.elements()); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
return super.aggregate(other, aggr, f); checkShape(other); if (size() == 0) return Double.NaN; double a = 0; final int zero = (int) index(0, 0, 0); final int zeroOther = (int) other.index(0, 0, 0); final int sliceStrideOther = other.sliceStride(); final double[] elementsOther = (double[]) other.elements(); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_3D())) { nthreads = Math.min(nthreads, slices); Future<?>[] futures = new Future[nthreads]; a = f.apply(getQuick(0, 0, 0), other.getQuick(0, 0, 0)); int d = 1; // first cell already done int idx;
return this; checkShape(y); final int zero = (int) index(0, 0, 0); final int zeroOther = (int) y.index(0, 0, 0); final int sliceStrideOther = y.sliceStride(); final double[] elementsOther = (double[]) y.elements(); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_3D())) { nthreads = Math.min(nthreads, slices); Future<?>[] futures = new Future[nthreads];
checkShape(B); int r = rows - 1; int c = columns - 1; int A_index = (int) index(k, 1, 1); int B_index = (int) BB.index(k, 1, 1);
public DoubleMatrix3D like(int slices, int rows, int columns) { return new DenseDoubleMatrix3D(slices, rows, columns); }
public DoubleMatrix3D assign(final cern.colt.function.tdouble.DoubleProcedure cond, final double value) { final int zero = (int) index(0, 0, 0); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (slices * rows * columns >= ConcurrencyUtils.getThreadsBeginN_3D())) {
final double[] elems = ((DenseDoubleMatrix3D) X).elements(); double sum = 0; int nthreads = ConcurrencyUtils.getNumberOfThreads();
public DoubleMatrix3D assign(final double[] values) { if (values.length != size()) throw new IllegalArgumentException("Must have same length: length=" + values.length + "slices()*rows()*columns()=" + slices() * rows() * columns()); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if (this.isNoView) { System.arraycopy(values, 0, this.elements, 0, values.length); } else { final int zero = (int) index(0, 0, 0); if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_3D())) { nthreads = Math.min(nthreads, slices); Future<?>[] futures = new Future[nthreads];
/** * Computes the 3D discrete Hartley transform (DHT) of this matrix. * */ public void dht3() { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dht3 == null) { dht3 = new DoubleDHT_3D(slices, rows, columns); } if (isNoView == true) { dht3.forward(elements); } else { DoubleMatrix3D copy = this.copy(); dht3.forward((double[]) copy.elements()); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
return super.aggregate(other, aggr, f); checkShape(other); if (size() == 0) return Double.NaN; double a = 0; final int zero = (int) index(0, 0, 0); final int zeroOther = (int) other.index(0, 0, 0); final int sliceStrideOther = other.sliceStride(); final double[] elementsOther = (double[]) other.elements(); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_3D())) { nthreads = Math.min(nthreads, slices); Future<?>[] futures = new Future[nthreads]; a = f.apply(getQuick(0, 0, 0), other.getQuick(0, 0, 0)); int d = 1; // first cell already done int idx;
return this; checkShape(y); final int zero = (int) index(0, 0, 0); final int zeroOther = (int) y.index(0, 0, 0); final int sliceStrideOther = y.sliceStride(); final double[] elementsOther = (double[]) y.elements(); int nthreads = ConcurrencyUtils.getNumberOfThreads(); if ((nthreads > 1) && (size() >= ConcurrencyUtils.getThreadsBeginN_3D())) { nthreads = Math.min(nthreads, slices); Future<?>[] futures = new Future[nthreads];
public void run() { int i = firstSlice * sliceStride; for (int s = firstSlice; s < lastSlice; s++) { double[][] currentSlice = values[s]; if (currentSlice.length != rows) throw new IllegalArgumentException( "Must have same number of rows in every slice: rows=" + currentSlice.length + "rows()=" + rows()); for (int r = 0; r < rows; r++) { double[] currentRow = currentSlice[r]; if (currentRow.length != columns) throw new IllegalArgumentException( "Must have same number of columns in every row: columns=" + currentRow.length + "columns()=" + columns()); System.arraycopy(currentRow, 0, elements, i, columns); i += columns; } } } });