📄 ocn_f.h
字号:
362: More than _value_ iterations are required to isolate all the eigenvalues.
11: On entry, n must not be less than 1: n = _value_.
17: On entry, tda = _value_ while n = _value_. These parameters must satisfy tda = n.
73: Memory allocation failed.
successfully call of the nag_real_symm_eigenvalues function.
*/
int nag_real_symm_eigenvalues(
int n, // the order of the matrix A.
double a[], // Input: the lower triangle of the n by n symmetric matrix A. The elements of the array above the diagonal need not be set. Output: the elements of A below the diagonal are overwritten, and the rest of the array is unchanged.
int tda, // the second dimension of the array a as declared in the function from which nag real symm eigenvalues is called.
double r[] // the eigenvalues in ascending order.
);
/** f02abc
calculates all the eigenvalues and eigenvectors of a real
symmetric matrix.
Example:
To calculate all the eigenvalues and eigenvectors of the real symmetric matrix
.
..
0.5 0.0 2.3 -2.6
0.0 0.5 -1.4 -0.7
2.3 -1.4 0.5 0.0
-2.6 -0.7 0.0 0.5
.
..
.
void test_nag_real_symm_eigensystem()
{
int i, j, n;
matrix a, v;
a.SetSize(8,8);
double r[8];
v.SetSize(8,8);
n = 4;
a[0][0] = 0.5;
a[0][1] = 0.0;
a[0][2] = 2.3;
a[0][3] = -2.6;
a[1][0] = 0.0;
a[1][1] = 0.5;
a[1][2] = -1.4;
a[1][3] = -0.7;
a[2][0] = 2.3;
a[2][1] = -1.4;
a[2][2] = 0.5;
a[2][3] = 0.0;
a[3][0] = -2.6;
a[3][1] = -0.7;
a[3][2] = 0.0;
a[3][3] = 0.5;
nag_real_symm_eigensystem(n, a, 8, r, v, 8);
printf("Eigenvalues\n");
for (i=0; i<n; i++)
{
printf("%9.4f", r[i]);
if(i%8==7 || i==n-1)
printf("\n");
}
printf("Eigenvectors\n");
for ( i=0; i<n; i++)
for (j=0; j<n; j++)
{
printf("%9.4f", v[i][j]);
if(j%8==7 || j==n-1)
printf("\n");
}
}
The output is following:
Eigenvalues
-3.0000 -1.0000 2.0000 4.0000
Eigenvectors
0.7000 0.1000 0.1000 -0.7000
-0.1000 0.7000 0.7000 0.1000
-0.5000 0.5000 -0.5000 -0.5000
0.5000 0.5000 -0.5000 0.5000
Parameters:
Return:
This function returns NAG error code, 0 if no error.
362: More than _value_ iterations are required to isolate all the eigenvalues.
11: On entry, n must not be less than 1: n = _value_.
17: On entry, tda = _value_ while n = _value_. These parameters must satisfy tda = n. On entry, tdv = _value_ while n = _value_. These parameters must satisfy tdv = n.
73: Memory allocation failed.
successfully call of the nag_real_symm_eigensystem function.
*/
int nag_real_symm_eigensystem(
int n, // the order of the matrix A.
double a[], // the lower triangle of the n by n symmetric matrix A. The elements of the array above the diagonal need not be set.
int tda, // the second dimension of the array a as declared in the function from which nag real symm eigensystem is called.
double r[], // the eigenvalues in ascending order.
double v[], // the normalised eigenvectors, stored by columns; the ith column corresponds to the ith eigenvalue. The eigenvectors are normalised so that the sum of squares of the elements is equal to 1.
int tdv // the second dimension of the array v as declared in the function from which nag real symm eigensystem is called.
);
/** f02adc
calculates all the eigenvalues of Ax = lamdaBx, where A is a real
symmetric matrix and B is a real symmetric positive-definite matrix.
Example:
To calculate all the eigenvalues of the general symmetric
eigenproblem Ax = lamdaBx where A is the symmetric matrix
.
..
0.5 1.5 6.6 4.8
1.5 6.5 16.2 8.6
6.6 16.2 37.6 9.8
4.8 8.6 9.8 -17.1
.
..
and B is the symmetric positive-de.nite matrix
.
..
1 3 4 1
3 13 16 11
4 16 24 18
1 11 18 27
.
..
.
void test_nag_real_symm_general_eigenvalues()
{
int i, j, n;
matrix a, b;
a.SetSize(8,8);
b.SetSize(8,8);
double r[8];
n = 4;
a[0][0] = 0.5;
a[0][1] = 1.5;
a[0][2] = 6.6;
a[0][3] = 4.8;
a[1][0] = 1.5;
a[1][1] = 6.5;
a[1][2] = 16.2;
a[1][3] = 8.6;
a[2][0] = 6.6;
a[2][1] = 16.2;
a[2][2] = 37.6;
a[2][3] = 9.8;
a[3][0] = 4.8;
a[3][1] = 8.6;
a[3][2] = 9.8;
a[3][3] = -17.1;
b[0][0] = 1.0;
b[0][1] = 3.0;
b[0][2] = 4.0;
b[0][3] = 1.0;
b[1][0] = 3.0;
b[1][1] = 13.0;
b[1][2] = 16.0;
b[1][3] = 11.0;
b[2][0] = 4.0;
b[2][1] = 16.0;
b[2][2] = 24.0;
b[2][3] = 18.0;
b[3][0] = 1.0;
b[3][1] = 11.0;
b[3][2] = 18.0;
b[3][3] = 27.0;
nag_real_symm_general_eigenvalues(n, a, 8, b, 8, r);
printf("Eigenvalues\n");
for (i=0; i<n; i++)
{
printf("%9.4f",r[i]);
if(i%8==7 || i==n-1)
printf("\n");
}
}
The output is following:
Eigenvalues
-3.0000 -1.0000 2.0000 4.0000
Parameters:
Return:
This function returns NAG error code, 0 if no error.
358: The matrix B is not positive-de.nite, possibly due to rounding errors.
362: More than _value_ iterations are required to isolate all the eigenvalues.
11: On entry, n must not be less than 1: n = _value_.
17: On entry, tda = _value_ while n = _value_. These parameters must satisfy tda = n. On entry, tdb = _value_ while n = _value_. These parameters must satisfy tdb = n.
73: Memory allocation failed.
successfully call of the nag_real_symm_general_eigenvalues function.
*/
int nag_real_symm_general_eigenvalues(
int n, // the order of the matrices A and B.
double a[], // Input: the upper triangle of the n by n symmetric matrix A. The elements of the array below the diagonal need not be set. Output: the lower triangle of the array is overwritten. The rest of the array is unchanged.
int tda, // the second dimension of the array a as declared in the function from which nag real symm general eigenvalues is called.
double b[], // Input: the upper triangle of the n by n symmetric positive-de.nite matrix B. The elements of the array below the diagonal need not be set. Output: the elements below the diagonal are overwritten. The rest of the array is unchanged.
int tdb, // the second dimension of the array b as declared in the function from which nag real symm general eigenvalues is called.
double r[] // the eigenvalues in ascending order.
);
/** f02aec
calculates all the eigenvalues and eigenvectors of Ax = lamdaBx, where A
is a real symmetric matrix and B is a real symmetric positive-definite matrix.
Example:
To calculate all the eigenvalues and eigenvectors of the general
symmetric eigenproblem Ax = lamdaBx where A is the symmetric matrix
.
..
0.5 1.5 6.6 4.8
1.5 6.5 16.2 8.6
6.6 16.2 37.6 9.8
4.8 8.6 9.8 -17.1
.
..
and B is the symmetric positive-de.nite matrix
.
..
1 3 4 1
3 13 16 11
4 16 24 18
1 11 18 27
.
..
.
void test_nag_real_symm_general_eigensystem()
{
int i, j, n;
matrix a, b, v;
a.SetSize(8,8);
b.SetSize(8,8);
v.SetSize(8,8);
double r[8];
n = 4;
a[0][0] = 0.5;
a[0][1] = 1.5;
a[0][2] = 6.6;
a[0][3] = 4.8;
a[1][0] = 1.5;
a[1][1] = 6.5;
a[1][2] = 16.2;
a[1][3] = 8.6;
a[2][0] = 6.6;
a[2][1] = 16.2;
a[2][2] = 37.6;
a[2][3] = 9.8;
a[3][0] = 4.8;
a[3][1] = 8.6;
a[3][2] = 9.8;
a[3][3] = -17.1;
b[0][0] = 1.0;
b[0][1] = 3.0;
b[0][2] = 4.0;
b[0][3] = 1.0;
b[1][0] = 3.0;
b[1][1] = 13.0;
b[1][2] = 16.0;
b[1][3] = 11.0;
b[2][0] = 4.0;
b[2][1] = 16.0;
b[2][2] = 24.0;
b[2][3] = 18.0;
b[3][0] = 1.0;
b[3][1] = 11.0;
b[3][2] = 18.0;
b[3][3] = 27.0;
nag_real_symm_general_eigensystem(n, a, 8, b, 8, r, v, 8);
printf("Eigenvalues\n");
for (i=0; i<n; i++)
{
printf("%9.4f",r[i]);
if(i%8==7 || i==n-1)
printf("\n");
}
printf("Eigenvectors\n");
for (i=0; i<n; i++)
{
for (j=0; j<n; j++)
{
printf("%9.4f",v[i][j]);
if(j%8==7 || j==n-1)
printf("\n");
}
}
}
The output is following:
Eigenvalues
-3.0000 -1.0000 2.0000 4.0000
Eigenvectors
-4.3500 -2.0500 -3.9500 2.6500
0.0500 0.1500 0.8500 0.0500
1.0000 0.5000 0.5000 -1.0000
-0.5000 -0.5000 -0.5000 0.5000
Parameters:
Return:
This function returns NAG error code, 0 if no error.
358: The matrix B is not positive-de.nite, possibly due to rounding errors.
362: More than _value_ iterations are required to isolate all the eigenvalues.
11: On entry, n must not be less than 1: n = _value_.
17: On entry, tda = _value_ while n = _value_. These parameters must satisfy tda = n. On entry, tdb = _value_ while n = _value_. These parameters must satisfy tdb = n. On entry, tdv = _value_ while n = _value_. These parameters must satisfy tdv = n.
73: Memory allocation failed.
successfully call of the nag_real_symm_general_eigensystem function.
*/
int nag_real_symm_general_eigensystem(
int n, // the order of the matrices A and B.
double a[], // Input: the upper triangle of the n by n symmetric matrix A. The elements of the array below the diagonal need not be set. Output: the lower triangle of the array is overwritten. The rest of the array is unchanged.
int tda, // the second dimension of the array a as declared in the function from which nag real symm general eigensystem is called.
double b[], // Input: the upper triangle of the n by n symmetric positive-de.nite matrix B. The elements of the array below the diagonal need not be set. Output: the elements below the diagonal are overwritten. The rest of the array is unchanged.
int tdb, // the second dimension of the array b as declared in the function from which nag real symm general eigensystem is called.
double r[], // the eigenvalues in ascending order.
double v[], // the normalised eigenvectors, stored by columns; the ith column corresponds to the ith eigenvalue. The eigenvectors x are normalised so that xTBx = 1.
int tdv // the second dimension of the array v as declared in the function from which nag real symm general eigensystem is called.
);
/** f02afc
calculates all the eigenvalues of a real unsymmetric matrix.
Example:
To calculate all the eigenvalues of the real matrix.
.
..
1.5 0.1 4.5 -1.5
-22.5 3.5 12.5 -2.5
-2.5 0.3 4.5 -2.5
-2.5 0.1 4.5 2.5
.
..
.
void test_nag_real_eigenvalues()
{
int i, j, n;
matrix a;
a.SetSize(4,4);
matrix<complex> r;
r.SetSize(1,4);
int iter[4];
n = 4;
a[0][0] = 1.5;
a[0][1] = 0.1;
a[0][2] = 4.5;
a[0][3] = -1.5;
a[1][0] = -22.5;
a[1][1] = 3.5;
a[1][2] = 12.5;
a[1][3] = -2.5;
a[2][0] = -2.5;
a[2][1] = 0.3;
a[2][2] = 4.5;
a[2][3] = -2.5;
a[3][0] = -2.5;
a[3][1] = 0.1;
a[3][2] = 4.5;
a[3][3] = 2.5;
nag_real_eigenvalues(n, a, 4, r, iter);
printf("Eigenvalues\n");
for (i=0; i<n; i++)
{
complex temp = r[0][i];
printf("( %7.3f , %7.3f ) \n", temp.m_re, temp.m_im);
}
}
The output is following:
Eigenvalues
( 3.000 , 4.000 )
( 3.000 , -4.000 )
( 4.000 , 0.000 )
( 2.000 , 0.000 )
Parameters:
Return:
This function returns NAG error code, 0 if no error.
362: More than _value_ iterations are required to isolate all the eigenvalues.
11: On entry, n must not be less than 1: n = _value_.
17: On entry, tda = _value_ while n = value. These parameters must satisfy tda = n.
73: Memory allocation failed.
successfully call of the nag_real_eigenvalues function.
*/
int nag_real_eigenvalues(
int n, // the order of the matrix A.
double a[], // Input: the n by n matrix A. Output: the array is overwritten.
int tda, // the second dimension of the array a as declared in the function from which nag real eigenvalues is called.
complex r[], // the eigenvalues.
int iter[] // contains the number of iterations used to find the ith eigenvalue. If iter[i - 1] is negative, the ith eigenvalue is the second of a pair found simultaneously.
);
/** f02agc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -