/** * 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 DenseDoubleMatrix2D(double[][] values) { this(values.length, values.length == 0 ? 0 : values[0].length); assign(values); }
/** * 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 DenseDoubleMatrix2D(double[][] values) { this(values.length, values.length == 0 ? 0 : values[0].length); assign(values); }
/** * Returns the left singular vectors <tt>U</tt>. * * @return <tt>U</tt> */ public DoubleMatrix2D getU() { if (wantUV == false) { throw new IllegalAccessError("Matrix U was not computed"); } else { if (U == null) { if (wantWholeUV == false) { if (columnMatrix) { U = new DenseColumnDoubleMatrix2D(m, mn).assign(elementsU); } else { U = new DenseDoubleMatrix2D(mn, m).assign(elementsU).viewDice(); } } else { if (columnMatrix) { U = new DenseColumnDoubleMatrix2D(m, m).assign(elementsU); } else { U = new DenseDoubleMatrix2D(m, m).assign(elementsU).viewDice(); } } } return U.copy(); } }
/** * Returns the left singular vectors <tt>U</tt>. * * @return <tt>U</tt> */ public DoubleMatrix2D getU() { if (wantUV == false) { throw new IllegalAccessError("Matrix U was not computed"); } else { if (U == null) { if (wantWholeUV == false) { if (columnMatrix) { U = new DenseColumnDoubleMatrix2D(m, mn).assign(elementsU); } else { U = new DenseDoubleMatrix2D(mn, m).assign(elementsU).viewDice(); } } else { if (columnMatrix) { U = new DenseColumnDoubleMatrix2D(m, m).assign(elementsU); } else { U = new DenseDoubleMatrix2D(m, m).assign(elementsU).viewDice(); } } } return U.copy(); } }
/** * 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(); } }
/** * 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(); } }
/** * Computes the 2D discrete Hartley transform (DHT) of this matrix. * */ public void dht2() { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dht2 == null) { dht2 = new DoubleDHT_2D(rows, columns); } if (isNoView == true) { dht2.forward(elements); } else { DoubleMatrix2D copy = this.copy(); dht2.forward((double[]) copy.elements()); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D inverse of the discrete cosine transform (DCT-III) of * this matrix. * * @param scale * if true then scaling is performed * */ public void idct2(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dct2 == null) { dct2 = new DoubleDCT_2D(rows, columns); } if (isNoView == true) { dct2.inverse(elements, scale); } else { DoubleMatrix2D copy = this.copy(); dct2.inverse((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D inverse of the discrete sine transform (DST-III) of this * matrix. * * @param scale * if true then scaling is performed * */ public void idst2(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dst2 == null) { dst2 = new DoubleDST_2D(rows, columns); } if (isNoView == true) { dst2.inverse(elements, scale); } else { DoubleMatrix2D copy = this.copy(); dst2.inverse((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D discrete Hartley transform (DHT) of this matrix. * */ public void dht2() { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dht2 == null) { dht2 = new DoubleDHT_2D(rows, columns); } if (isNoView == true) { dht2.forward(elements); } else { DoubleMatrix2D copy = this.copy(); dht2.forward((double[]) copy.elements()); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D discrete sine transform (DST-II) of this matrix. * * @param scale * if true then scaling is performed * */ public void dst2(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dst2 == null) { dst2 = new DoubleDST_2D(rows, columns); } if (isNoView == true) { dst2.forward(elements, scale); } else { DoubleMatrix2D copy = this.copy(); dst2.forward((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D discrete cosine transform (DCT-II) of this matrix. * * @param scale * if true then scaling is performed * */ public void dct2(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dct2 == null) { dct2 = new DoubleDCT_2D(rows, columns); } if (isNoView == true) { dct2.forward(elements, scale); } else { DoubleMatrix2D copy = this.copy(); dct2.forward((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D discrete sine transform (DST-II) of this matrix. * * @param scale * if true then scaling is performed * */ public void dst2(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dst2 == null) { dst2 = new DoubleDST_2D(rows, columns); } if (isNoView == true) { dst2.forward(elements, scale); } else { DoubleMatrix2D copy = this.copy(); dst2.forward((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D inverse of the discrete Hartley transform (IDHT) of this * matrix. * * @param scale * if true then scaling is performed * */ public void idht2(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dht2 == null) { dht2 = new DoubleDHT_2D(rows, columns); } if (isNoView == true) { dht2.inverse(elements, scale); } else { DoubleMatrix2D copy = this.copy(); dht2.inverse((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D inverse of the discrete Hartley transform (IDHT) of this * matrix. * * @param scale * if true then scaling is performed * */ public void idht2(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dht2 == null) { dht2 = new DoubleDHT_2D(rows, columns); } if (isNoView == true) { dht2.inverse(elements, scale); } else { DoubleMatrix2D copy = this.copy(); dht2.inverse((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D discrete cosine transform (DCT-II) of this matrix. * * @param scale * if true then scaling is performed * */ public void dct2(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dct2 == null) { dct2 = new DoubleDCT_2D(rows, columns); } if (isNoView == true) { dct2.forward(elements, scale); } else { DoubleMatrix2D copy = this.copy(); dct2.forward((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D inverse of the discrete cosine transform (DCT-III) of * this matrix. * * @param scale * if true then scaling is performed * */ public void idct2(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dct2 == null) { dct2 = new DoubleDCT_2D(rows, columns); } if (isNoView == true) { dct2.inverse(elements, scale); } else { DoubleMatrix2D copy = this.copy(); dct2.inverse((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
/** * Computes the 2D inverse of the discrete sine transform (DST-III) of this * matrix. * * @param scale * if true then scaling is performed * */ public void idst2(boolean scale) { int oldNthreads = ConcurrencyUtils.getNumberOfThreads(); ConcurrencyUtils.setNumberOfThreads(ConcurrencyUtils.nextPow2(oldNthreads)); if (dst2 == null) { dst2 = new DoubleDST_2D(rows, columns); } if (isNoView == true) { dst2.inverse(elements, scale); } else { DoubleMatrix2D copy = this.copy(); dst2.inverse((double[]) copy.elements(), scale); this.assign((double[]) copy.elements()); } ConcurrencyUtils.setNumberOfThreads(oldNthreads); }
DoubleMatrix2D copy = this.copy(); fft2.realForward((double[]) copy.elements()); this.assign((double[]) copy.elements());
DoubleMatrix2D copy = this.copy(); fft2.realInverse((double[]) copy.elements(), scale); this.assign((double[]) copy.elements());