📄 ocn_c06.h
字号:
//Put the result to the Worksheet "data1" the third and fourth column.
dx = x;
dy = y;
Example2:
This program reads in a sequence of complex data values and prints their inverse discrete Fourier
transform as computed by calling nag_conjugate_complex, followed by nag_fft_complex (c06ecc) and
nag_conjugate_complex again.
void test_nag_conjugate_complex()
{
#define NMAX 20
int j, n ;
double x[20] = {0.34907, 0.54890, 0.74776, 0.94459,
1.13850, 1.32850, 1.51370};
double y[20] = {-0.37168, -0.35669, -0.31175, -0.23702,
-0.13274, 0.00074, 0.16298};
n = 7;
nag_conjugate_complex(n, y);
nag_fft_complex(n, x, y);
nag_conjugate_complex(n, y);
printf("\nComponents of inverse discrete Fourier transform\n");
printf("\n Real Imag\n\n");
for (j = 0; j<n; ++j)
printf("%3ld %10.5f %10.5f\n", j, x[j], y[j]);
}
The output is following:
Components of inverse discrete Fourier transform
Real Imag
0 2.48361 -0.47100
1 0.01983 -0.56496
2 -0.14825 -0.30840
3 -0.22506 -0.17477
4 -0.28767 -0.05865
5 -0.36711 0.09756
6 -0.55180 0.49684
Return:
The function returns NAG error code or 0 if no error.
11: On entry, n must not be less than 1: n = _value_.
successfully call of the nag_conjugate_complex function.
*/
int nag_conjugate_complex(
int n, //the number of data values.
double y[] //Input:the imaginary part of the data values. Output: these values are negated.
); // forms the complex conjugate of a sequence of n data values.
/** c06gqc
forms the complex conjugates of m Hermitian sequences, each containing n data values.
Example1:
Assume "Data1" Worksheet has 4 columns, the first column contains 18 data. This piece of
code forms the complex conjugate of 3 Hermitian sequences, each containing 6 data values.
The result was put to the second column (Conjugated data values) the third column (real part)
and the fourth column (imag part).
int m = 3, n = 6;
//Attach four Datasets to these 4 columns
Dataset xx("data1",0);
Dataset yy("data1",1);
Dataset uu("data1",2);
Dataset vv("data1",3);
//Dataset cannot be the parameter of function, but vector can be.
vector x = xx, u = uu, v = vv;
//Original data written in full complex form, u is real part, v is imag part.
nag_multiple_hermitian_to_complex(m, n, x, u, v);
nag_multiple_conjugate_hermitian(m, n, x);
//Put the Conjugated data values to Worksheet "data1" the second column.
yy = x;
nag_multiple_hermitian_to_complex(m, n, x, u, v);
//Put the Conjugated data written in full complex form to the third and fourth column.
uu = u;
vv = v;
Example2:
This program reads in sequences of real data values which are assumed to be Hermitian sequences
of complex data stored in Hermitian form. The sequences are expanded into full complex form
using nag_multiple_hermitian_to_complex (c06gsc) and printed out. The sequences are then conjugated
(using nag_multiple_conjugate_hermitian) and the conjugated sequences are expanded into complex
form using nag_multiple_hermitian_to_complex (c06gsc) and printed out.
void test_nag_multiple_conjugate_hermitian()
{
int i, j, m, n;
double u[100], v[100];
double x[100] = {0.3854, 0.6772, 0.1138, 0.6751, 0.6362, 0.1424,
0.5417, 0.2983, 0.1181, 0.7255, 0.8638, 0.8723,
0.9172, 0.0644, 0.6037, 0.6430, 0.0428, 0.4815};
m = 3;
n =6;
printf("\n\nm = %2ld n = %2ld\n", m, n);
printf("\nOriginal data values\n\n");
for (j = 0; j<m; ++j)
{
printf(" ");
for (i = 0; i<n; ++i)
{
printf("%10.4f", x[j*n + i]);
if((i % 6 )== 5 && (i != n-1 ))
printf("\n " );
}
printf("\n");
}
nag_multiple_hermitian_to_complex(m, n, x, u, v);
printf("\nOriginal data written in full complex form\n\n");
for (j = 0; j<m; ++j)
{
printf("Real");
for (i = 0; i<n; ++i)
{
printf("%10.4f", u[j*n + i]);
if(i % 6 == 5 && i != n-1 )
printf("\n " );
}
printf("\nImag");
for (i = 0; i<n; ++i)
{
printf("%10.4f", v[j*n + i]);
if(i % 6 == 5 && i != n-1 )
printf("\n " );
}
printf("\n\n");
}
nag_multiple_conjugate_hermitian(m, n, x);
printf("\nConjugated data values\n\n");
for (j = 0; j<m; ++j)
{
printf(" ");
for (i = 0; i<n; ++i)
{
printf("%10.4f", x[j*n + i]);
if((i % 6 )== 5 && (i != n-1 ))
printf("\n " );
}
printf("\n");
}
nag_multiple_hermitian_to_complex(m, n, x, u, v);
printf("\nConjugated data written in full complex form\n\n");
for (j = 0; j<m; ++j)
{
printf("Real");
for (i = 0; i<n; ++i)
{
printf("%10.4f", u[j*n + i]);
if(i % 6 == 5 && i != n-1 )
printf("\n " );
}
printf("\nImag");
for (i = 0; i<n; ++i)
{
printf("%10.4f", v[j*n + i]);
if(i % 6 == 5 && i != n-1 )
printf("\n " );
}
printf("\n\n");
}
}
The output is following:
m = 3 n = 6
Original data values
0.3854 0.6772 0.1138 0.6751 0.6362 0.1424
0.5417 0.2983 0.1181 0.7255 0.8638 0.8723
0.9172 0.0644 0.6037 0.6430 0.0428 0.4815
Original data written in full complex form
Real 0.3854 0.6772 0.1138 0.6751 0.1138 0.6772
Imag 0.0000 0.1424 0.6362 0.0000 -0.6362 -0.1424
Real 0.5417 0.2983 0.1181 0.7255 0.1181 0.2983
Imag 0.0000 0.8723 0.8638 0.0000 -0.8638 -0.8723
Real 0.9172 0.0644 0.6037 0.6430 0.6037 0.0644
Imag 0.0000 0.4815 0.0428 0.0000 -0.0428 -0.4815
Conjugated data values
0.3854 0.6772 0.1138 0.6751 -0.6362 -0.1424
0.5417 0.2983 0.1181 0.7255 -0.8638 -0.8723
0.9172 0.0644 0.6037 0.6430 -0.0428 -0.4815
Conjugated data written in full complex form
Real 0.3854 0.6772 0.1138 0.6751 0.1138 0.6772
Imag 0.0000 -0.1424 -0.6362 0.0000 0.6362 0.1424
Real 0.5417 0.2983 0.1181 0.7255 0.1181 0.2983
Imag 0.0000 -0.8723 -0.8638 0.0000 0.8638 0.8723
Real 0.9172 0.0644 0.6037 0.6430 0.6037 0.0644
Imag 0.0000 -0.4815 -0.0428 0.0000 0.0428 0.4815
Return:
The function returns NAG error code or 0 if no error.
11: On entry, m must not be less than 1: m = _value_. On entry, n must not be less than 1: n = _value_.
successfully call of the nag_multiple_conjugate_hermitian function.
*/
int nag_multiple_conjugate_hermitian(
int m, // the number of Hermitian sequences to be conjugated.
int n, // the number of data values in each Hermitian sequence.
double x[] //Input:the m data sequences must be stored in x consecutively. Output:the imaginary parts are negated.
); // forms the complex conjugates of m Hermitian sequences, each containing n data values.
/** c06gsc
takes m Hermitian sequences, each containing n data values, and forms
the real and imaginary parts of the m corresponding complex sequences.
Example1:
Assume "Data1" Worksheet has 3 columns, the first column contains 18 data. This piece of
code forms the complex conjugate of 3 Hermitian sequences, each containing 6 data values.
The result was put to the second column (real part) and the third column (imag part).
int m = 3, n = 6;
//Attach 3 Datasets to these 3 columns
Dataset xx("data1",0);
Dataset uu("data1",1);
Dataset vv("data1",2);
//Dataset cannot be the parameter of function, but vector can be.
vector x = xx, u = uu, v = vv;
// Convert Hermitian form to full complex
nag_multiple_hermitian_to_complex(m, n, x, u, v);
//Put the Conjugated data written in full complex form to the third and fourth column.
uu = u;
vv = v;
Example2:
This program reads in sequences of real data values which are assumed to be Hermitian
sequences of complex data stored in Hermitian form. The sequences are then expanded
into full complex form using_nag_multiple_hermitian_to_complex and printed.
void test_nag_multiple_hermitian_to_complex()
{
#define MMAX 5
#define NMAX 20
int i, j, m, n;
double u[100], v[100];
double x[100] = {0.3854, 0.6772, 0.1138, 0.6751, 0.6362, 0.1424,
0.5417, 0.2983, 0.1181, 0.7255, 0.8638, 0.8723,
0.9172, 0.0644, 0.6037, 0.6430, 0.0428, 0.4815};
m = 3;
n = 6;
printf("\nOriginal data values\n\n");
for (j = 0; j<m; ++j)
{
printf(" ");
for (i = 0; i<n; ++i)
{
printf("%10.4f", x[j*n + i]);
if((i % 6 )== 5 && (i != n-1 ))
printf("\n " );
}
printf("\n");
}
// Convert Hermitian form to full complex
nag_multiple_hermitian_to_complex(m, n, x, u, v);
printf("\nOriginal data written in full complex form\n\n");
for (j = 0; j<m; ++j)
{
printf("Real");
for (i = 0; i<n; ++i)
{
printf("%10.4f", u[j*n + i]);
if(i % 6 == 5 && i != n-1 )
printf("\n " );
}
printf("\nImag");
for (i = 0; i<n; ++i)
{
printf("%10.4f", v[j*n + i]);
if(i % 6 == 5 && i != n-1 )
printf("\n " );
}
printf("\n\n");
}
}
The output is following:
m = 3 n = 6
Original data values
0.3854 0.6772 0.1138 0.6751 0.6362 0.1424
0.5417 0.2983 0.1181 0.7255 0.8638 0.8723
0.9172 0.0644 0.6037 0.6430 0.0428 0.4815
Original data written in full complex form
Real 0.3854 0.6772 0.1138 0.6751 0.1138 0.6772
Imag 0.0000 0.1424 0.6362 0.0000 -0.6362 -0.1424
Real 0.5417 0.2983 0.1181 0.7255 0.1181 0.2983
Imag 0.0000 0.8723 0.8638 0.0000 -0.8638 -0.8723
Real 0.9172 0.0644 0.6037 0.6430 0.6037 0.0644
Imag 0.0000 0.4815 0.0428 0.0000 -0.0428 -0.4815
Return:
The function returns NAG error code or 0 if no error.
11: On entry, m must not be less than 1: m = _value_. On entry, n must not be less than 1: n = _value_.
successfully call of the nag_multiple_hermitian_to_complex function.
*/
int nag_multiple_hermitian_to_complex(
int m, //the number of Hermitian sequences to be converted into complex form.
int n, //the number of data values, in each sequence.
const double x[], //the data sequences must be stored in x consecutively.
double u[], //the real part of the m sequences of length n are stored consecutively in u.
double v[] //the imaginary part of the m sequences of length n are stored consecutively v.
); // takes m Hermitian sequences, each containing n data values, and forms the real and imaginary parts of the m corresponding complex sequences.
/** c06gzc
calculates the trigonometric coefficients required for the computation of discrete Fourier transforms.
Example1:
Assume "Data1" Worksheet has 2 columns, the first column contains 18 data. This piece of
code calculates the trigonometric coefficients required for the computation of discrete
Fourier transforms. The result was put to the second column.
double trig[40];
int m = 3, n = 6;
//Attach 2 Datasets to these 2 columns
Dataset xx("data1",0);
Dataset dx("data1",1);
x = xx;
nag_fft_init_trig(n, trig);
nag_fft_multiple_real(m, n, x, trig);
//Put the result to the second column.
dx = x;
Example2:
The program reads in 3 real data sequences and prints their discrete Fourier transforms in Hermitian
format as calculated by nag_fft_multiple_real (c06fpc). A call is made to nag_fft_init_trig to initialise
the array trig prior to calling nag_fft_multiple_real (c06fpc). The transforms are then printed out
in full complex form after a call to nag_multiple_hermitian_to_complex (c06gsc).
void test_nag_fft_init_trig()
{
double trig[40];
int i, j, m, n;
double u[100], v[100];
double x[100] = {0.3854, 0.6772, 0.1138, 0.6751, 0.6362, 0.1424,
0.5417, 0.2983, 0.1181, 0.7255, 0.8638, 0.8723,
0.9172, 0.0644, 0.6037, 0.6430, 0.0428, 0.4815};
m = 3;
n = 6;
printf("\nOriginal data values\n\n");
for (j = 0; j<m; ++j)
{
printf(" ");
for (i = 0; i<n; ++i)
{
printf("%10.4f", x[j*n + i]);
if((i % 6 )== 5 && (i != n-1 ))
printf("\n " );
}
printf("\n");
}
nag_fft_init_trig(n, trig);
nag_fft_multiple_real(m, n, x, trig);
printf("\nDiscrete Fourier transforms in Hermitian format\n\n");
for (j = 0; j<m; ++j)
{
printf(" ");
for (i = 0; i<n; ++i)
{
printf("%10.4f", x[j*n + i]);
if((i % 6 )== 5 && (i != n-1 ))
printf("\n " );
}
printf("\n");
}
nag_multiple_hermitian_to_complex(m, n, x, u, v);
printf("\nFourier transforms in full complex form\n\n");
for (j = 0; j<m; ++j)
{
printf("Real");
for (i = 0; i<n; ++i)
{
printf("%10.4f", u[j*n + i]);
if(i % 6 == 5 && i != n-1 )
printf("\n " );
}
printf("\nImag");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -