Chai Xiangyu | Research, Develop, Projects, Blogs Algorithm Armadillo使用介绍(十二):fft / ifft

Armadillo使用介绍(十二):fft / ifft

fft / ifft

用途:fft / ifft函数用于一维快速傅里叶变换/快速傅里叶逆变换
该函数重载有cx_mat Y = fft( X )、cx_mat Y = fft( X, n )、cx_mat Z = ifft( cx_mat Y )、cx_mat Z = ifft( cx_mat Y, n )
类型:普通函数
隶属:Signal & Image Processing

1、fft(): fast Fourier transform of a vector or matrix (real or complex)

2、ifft(): inverse fast Fourier transform of a vector or matrix (complex only)

3、If given a matrix, the transform is done on each column vector of the matrix

4、The optional n argument specifies the transform length:
    if n is larger than the length of the input vector, a zero-padded version of the vector is used
    if n is smaller than the length of the input vector, only the first n elements of the vector are used

5、If n is not specified, the transform length is the same as the length of the input vector

6、注意: the transform is fastest when the transform length is a power of 2, eg. 64, 128, 256, 512, 1024, ...

7、The implementation of the transform in this version is preliminary; it is not yet fully optimised

示例代码如下:

    vec X = randu<vec>(10);
    cx_vec Y = fft(X, 8);
    cx_vec Z = ifft(Y, 8);

    X.print("X:");
    Y.print("Y:");
    Z.print("Z:");

运行结果:

Armadillo version: 9.900.1 (Nocturnal Misbehaviour)
X:
   0.0013
   0.1933
   0.5850
   0.3503
   0.8228
   0.1741
   0.7105
   0.3040
   0.0914
   0.1473
Y:
  (+3.141e+000,+0.000e+000)
  (-8.408e-001,+7.916e-002)
  (-4.714e-001,+2.868e-001)
  (-8.024e-001,-1.718e-001)
  (+1.098e+000,+0.000e+000)
  (-8.024e-001,+1.718e-001)
  (-4.714e-001,-2.868e-001)
  (-8.408e-001,-7.916e-002)
Z:
  (+1.268e-003,+0.000e+000)
  (+1.933e-001,-8.132e-019)
  (+5.850e-001,+0.000e+000)
  (+3.503e-001,-1.789e-018)
  (+8.228e-001,+0.000e+000)
  (+1.741e-001,+9.595e-018)
  (+7.105e-001,+0.000e+000)
  (+3.040e-001,-6.993e-018)
请按任意键继续. . .

Leave a Reply

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Related Post