/*------------------------------------------------------------------------------* * File Name: OCN_c01.h * * Creation: TCZ 5/22/2001 * * Purpose: Origin C Header for NAG functions * * Copyright (c) OriginLab Corp. 2001 * * All Rights Reserved * * * * Modification Log: * *------------------------------------------------------------------------------*/ #ifndef _O_NAG_C06_H #define _O_NAG_C06_H //#importdll "ONAG" // NAG DLL prepared by OriginLab #pragma dll(ONAG) #include /* begin proto */ /** c06eac calculates the discrete Fourier transforms of a sequence of n real data values. Example1: This piece of code reads in a sequence of real data values from a worksheet column, and prints their discrete Fourier transform (as computed by nag fft real), after expanding it from Hermitian form into a full complex sequence. Assume "Data1" Worksheet has 3 columns, the first column contain 7 data, and we want to put result complex form real part in the second column and imag part in the third column. int n = 7, j, success, n2, nj; //Attach two Datasets to these 2 columns Dataset xx("data1",0); Dataset aa("data1",1); Dataset bb("data1",2); //Because Dataset cannot be the parameter of function, but vector can be. vector x = xx, a = aa, b = bb; success = nag_fft_real(n, x); if(success == 0) { a[0] = x[0]; b[0] = 0.0; n2 = (n-1)/2; for (j = 1; j<=n2; j++) { nj = n - j; a[j] = x[j]; a[nj] = x[j]; b[j] = x[nj]; b[nj] = -x[nj]; } if (n % 2==0) { a[n2+1] = x[n2+1]; b[n2+1] = 0.0; } } //write the result to worksheet. aa = a; bb = b; Example2: This program reads in a sequence of real data values, and prints their discrete Fourier transform (as computed by nag fft real), after expanding it from Hermitian form into a full complex sequence. It then performs an inverse transform using nag conjugate hermitian (c06gbc) and nag fft hermitian (c06ebc), and prints the sequence so obtained alongside the original data values. void test_nag_fft_real() { int j, n = 7, n2, nj; double a[20], b[20], xx[20]; double x[20] = {0.34907, 0.54890, 0.74776, 0.94459, 1.13850, 1.32850, 1.51370}; int success; for (j = 0; j