Пример #1
0
  /**
   * 1d inverse discrete fourier transform see matlab's fft2 for more examples. Note that this will
   * throw an exception if the input isn't a vector
   *
   * @param inputC the input to transform
   * @return the inverse fourier transform of the passed in input
   */
  public static ComplexNDArray complexInverseDisceteFourierTransform1d(ComplexNDArray inputC) {
    if (inputC.shape().length != 1)
      throw new IllegalArgumentException("Illegal input: Must be a vector");
    double len = MatrixUtil.length(inputC);
    ComplexDouble c2 = new ComplexDouble(0, -2).muli(FastMath.PI).divi(len);
    ComplexDoubleMatrix range = MatrixUtil.complexRangeVector(0, len);
    ComplexDoubleMatrix div2 = range.transpose().mul(c2);
    ComplexDoubleMatrix div3 = range.mmul(div2).negi();
    ComplexDoubleMatrix matrix = exp(div3).div(len);
    ComplexDoubleMatrix complexRet = matrix.mmul(inputC);

    return ComplexNDArray.wrap(inputC, complexRet);
  }
Пример #2
0
  /**
   * 1d inverse discrete fourier transform see matlab's fft2 for more examples. Note that this will
   * throw an exception if the input isn't a vector
   *
   * @param inputC the input to transform
   * @return the inverse fourier transform of the passed in input
   */
  public static ComplexFloatMatrix complexInverseDisceteFourierTransform1d(
      ComplexFloatMatrix inputC) {
    if (inputC.rows != 1 && inputC.columns != 1)
      throw new IllegalArgumentException("Illegal input: Must be a vector");
    float len = MatrixUtil.length(inputC);
    ComplexFloat c2 = new ComplexFloat(0, -2).muli((float) FastMath.PI).divi(len);
    ComplexFloatMatrix range = MatrixUtil.complexRangeVector(0, (int) len);
    ComplexFloatMatrix div2 = range.transpose().mul(c2);
    ComplexFloatMatrix div3 = range.mmul(div2).negi();
    ComplexFloatMatrix matrix = exp(div3).div(len);
    ComplexFloatMatrix complexRet =
        inputC.isRowVector() ? matrix.mmul(inputC) : inputC.mmul(matrix);

    return complexRet;
  }