📄 ocn_f06.h
字号:
}
printf("\n"); //output vec_output
printf("Result vector=\n");
for(i=0;i<nRows;i++)
{
printf(" ");
printf("(%f,%fi)\n",vec_output[i].m_re,vec_output[i].m_im);
}
}
The output is as following:
Compute a matrix-vector product for complex band matrix M*V:
M=
(1.000000,1.200000i) (2.000000,2.100000i) (3.000000,1.000000i) (0.000000,0.000000i)
(4.000000,2.600000i) (5.000000,1.200000i) (6.000000,2.600000i) (7.000000,4.100000i)
(0.000000,0.000000i) (8.000000,1.000000i) (9.000000,0.000000i) (10.000000,2.000000i)
V=
(11.000000,2.000000i)
(12.000000,0.000000i)
(13.000000,2.000000i)
(14.000000,1.800000i)
Result vector=
(69.600000,59.400000i)
(262.220000,166.800000i)
(349.400000,76.000000i)
Parameters:
trans=NoTranspose, return (alpha*Ax+beta*y) in array y[];
trans=Transpose, return (alpha*transpose(A)*x+beta*y) in array y[];
trans=ConjugateTranspose, return (alpha*ConjugateTranspose(A)*x+beta*y) in array y[].
Return: NULL
*/
void zgbmv(
MatrixTranspose trans,
int m, //the number of rows of A
int n, // the number of columns of A
int kl, //the subdiagonals of matrix A
int ku, // the superdiagonals of matrix A
complex alpha,
const complex a[], //the m by n general complex matrix A
int tda, //the last dimension of A
const complex x[], //complex vector x
int incx, //the spacing which the elements of the vector x occur
complex beta,
complex y[], //Input:complex vector y; Output: alpha*trans(A)*x+beta*y
int incy // the spacing which the elements of the vector y occur
);
/** f06pcc
Compute a matrix-vector product for real symmetric matrix
Example:
This example computes the matrix-vector product for a real symmetric matrix
1.000000 2.000000 3.000000 4.000000
2.000000 6.000000 7.000000 8.000000
2.000000 7.000000 9.000000 10.000000
4.000000 8.000000 10.000000 11.000000
and a real vector
12.000000
13.000000
14.000000
15.000000
void test_f06pcc() //test for function dsymv(f06pcc)
{
int nColRow=4;
matrix<double> mat_input={{1,2,3,4},
{2,6,7,8},
{2,7,9,10},
{4,8,10,11}};
vector<double> vec_input={12,13,14,15};
vector<double> vec_output(nColRow);
vec_output=0;
dsymv(UpperTriangle,nColRow,1,mat_input,nColRow,vec_input,1,1,vec_output,1);
printf("Compute a matrix-vector product for real symmetric matrix M*V:\n");
printf("M=\n"); //output mat_input
for(int i=0;i<nColRow;i++)
{
printf(" ");
for(int j=0;j<nColRow;j++)
printf("%f ",mat_input[i][j]);
printf("\n");
}
printf("\n"); //output vec_input
printf("V=\n");
for(i=0;i<nColRow;i++)
{
printf(" ");
printf("%f\n",vec_input[i]);
}
printf("\n"); //output vec_output
printf("Result vector=\n");
for(i=0;i<nColRow;i++)
{
printf(" ");
printf("%f\n",vec_output[i]);
}
}
The output is as following:
Compute a matrix-vector product for real symmetric matrix M*V:
M=
1.000000 2.000000 3.000000 4.000000
2.000000 6.000000 7.000000 8.000000
2.000000 7.000000 9.000000 10.000000
4.000000 8.000000 10.000000 11.000000
V=
12.000000
13.000000
14.000000
15.000000
Result vector=
140.000000
320.000000
403.000000
457.000000
Parameters:
uplo specify whether the upper (uplo=UpperTriangle) or lower (uplo=LowerTriangle) triangle is being reference.
Return: NULL
*/
void dsymv(
MatrixTriangle uplo,
int n, //the order of symmetric matrix A
double alpha,
const double a[], //the real symmetric matrix of order n
int tda, //the last dimension of A
const double x[], // vector x
int incx, //the spacing which the elements of vector x occur
double beta,
double y[], //Input: vector y; Output: alpha*Ax+beta*y
int incy
);
/** f06scc
Compute a matrix-vector product for complex Hermitian matrix
Example:
This example computes the matrix-vector product for a complex Hermitian matrix
(1.000000,0.000000i) (2.000000,2.100000i) (3.000000,1.000000i) (4.000000,1.300000i)
(2.000000,-2.100000i) (5.000000,0.000000i) (6.000000,2.600000i) (7.000000,4.100000i)
(3.000000,-1.000000i) (6.000000,-2.600000i) (9.000000,0.000000i) (10.000000,2.000000i)
(4.000000,-1.300000i) (7.000000,-4.100000i) (10.000000,-2.000000i) (11.000000,0.000000i)
and a complex vector
(11.000000,2.000000i)
(12.000000,0.000000i)
(13.000000,2.000000i)
(14.000000,1.800000i)
void test_f06scc() //test for function zhemv(f06scc)
{
int nRowCol=4;
matrix<complex> mat_input={{1,2+2.1i,3+1.0i,4+1.3i},
{2-2.1i,5,6+2.6i,7+4.1i},
{3-1.0i,6-2.6i,9,10+2i},
{4-1.3i,7-4.1i,10-2i,11}};
vector<complex> vec_input={11+2i,12,13+2i,14+1.8i};
vector<complex> vec_output(nRowCol);
vec_output=0;
zhemv(UpperTriangle,nRowCol,1,mat_input,nRowCol,vec_input,1,1,vec_output,1);
printf("Compute a matrix-vector product for complex Hermitian matrix M*V:\n");
printf("M=\n"); //output mat_input
for(int i=0;i<nRowCol;i++)
{
printf(" ");
for(int j=0;j<nRowCol;j++)
printf("(%f,%fi) ",mat_input[i][j].m_re,mat_input[i][j].m_im);
printf("\n");
}
printf("\n"); //output vec_input
printf("V=\n");
for(i=0;i<nRowCol;i++)
{
printf(" ");
printf("(%f,%fi)\n",vec_input[i].m_re,vec_input[i].m_im);
}
printf("\n"); //output vec_output
printf("Result vector=\n");
for(i=0;i<nRowCol;i++)
{
printf(" ");
printf("(%f,%fi)\n",vec_output[i].m_re,vec_output[i].m_im);
}
}
The output is as following:
Compute a matrix-vector product for complex Hermitian matrix M*V:
M=
(1.000000,0.000000i) (2.000000,2.100000i) (3.000000,1.000000i) (4.000000,1.300000i)
(2.000000,-2.100000i) (5.000000,0.000000i) (6.000000,2.600000i) (7.000000,4.100000i)
(3.000000,-1.000000i) (6.000000,-2.600000i) (9.000000,0.000000i) (10.000000,2.000000i)
(4.000000,-1.300000i) (7.000000,-4.100000i) (10.000000,-2.000000i) (11.000000,0.000000i)
V=
(11.000000,2.000000i)
(12.000000,0.000000i)
(13.000000,2.000000i)
(14.000000,1.800000i)
Result vector=
(125.660000,71.600000i)
(249.620000,96.700000i)
(360.400000,27.800000i)
(418.600000,-41.700000i)
Parameters:
uplo specify whether the upper (uplo=UpperTriangle) or lower (uplo=LowerTriangle) triangle is being reference.
Return: NULL
*/
void zhemv(
MatrixTriangle uplo,
int n, // the order of complex Hermitian matrix A
complex alpha,
const complex a[], // order n complex Hermitian matrix A
int tda, // the last dimension of A
const complex x[], //complex vector
int incx, //the spacing which the elements of the vector x occur
complex beta,
complex y[], //Input: complex vector y; Output: alpha*Ax+beta*y
int incy // the spacing which the elements of the vector y occuur
);
/** f06pdc
Compute a matrix-vector product for symmetric band matrix
Example:
This example computes the matrix-vector product for a symmetric band matrix
1.000000 2.000000 3.000000 0.000000
2.000000 5.000000 6.000000 7.000000
3.000000 6.000000 9.000000 10.000000
0.000000 7.000000 10.000000 11.000000
and a real vector
11.000000
12.000000
13.000000
14.000000
void test_f06pdc() //test for function dsbmv(f06pdc)
{
int nRowCol=4;
matrix<double> mat_input={{1,2,3,0},
{2,5,6,7},
{3,6,9,10},
{0,7,10,11}};
int k_nzero=2;
matrix<double> mat_input_band={{1,2,3},
{5,6,7},
{9,10,0},
{11,0,0}};
vector<double> vec_input={11,12,13,14};
vector<double> vec_output(nRowCol);
vec_output=0;
dsbmv(UpperTriangle,nRowCol,k_nzero,1,mat_input_band,k_nzero+1,vec_input,1,1,vec_output,1);
printf("Compute a matrix-vector product for real symmetric band matrix M*V:\n");
printf("M=\n"); //output mat_input
for(int i=0;i<nRowCol;i++)
{
printf(" ");
for(int j=0;j<nRowCol;j++)
printf("%f ",mat_input[i][j]);
printf("\n");
}
printf("\n"); //output vec_input
printf("V=\n");
for(i=0;i<nRowCol;i++)
{
printf(" ");
printf("%f\n",vec_input[i]);
}
printf("\n"); //output vec_output
printf("Result vector=\n");
for(i=0;i<nRowCol;i++)
{
printf(" ");
printf("%f\n",vec_output[i]);
}
}
The output is as following:
Compute a matrix-vector product for real symmetric band matrix M*V:
M=
1.000000 2.000000 3.000000 0.000000
2.000000 5.000000 6.000000 7.000000
3.000000 6.000000 9.000000 10.000000
0.000000 7.000000 10.000000 11.000000
V=
11.000000
12.000000
13.000000
14.000000
Result vector=
74.000000
258.000000
362.000000
368.000000
Parameters:
uplo specify whether the upper (uplo=UpperTriangle) or lower (uplo=LowerTriangle) triangle is being reference.
Return: NULL
*/
void dsbmv(
MatrixTriangle uplo,
int n, // the order of symmetric band matrix A
int k, // the subdiagonals (superdiagonals) of A
double alpha,
const double a[], //the symmetric band matrix A
int tda, //the last dimension of A
const double x[], //vector x
int incx, //the spacing which the elements of vector x occur
double beta,
double y[], //Input: vector y; Output: alpha*Ax+beta*y
int incy //the spacing which the elements of vector y occur
);
/** f06sdc
Compute a matrix-vector product for complex Hermitian band matrix
Example:
This example computes the matrix-vector product for a complex Hermitian band matrix
(1.000000,0.000000i) (2.000000,2.100000i) (0.000000,0.000000i) (0.000000,0.000000i)
(2.000000,-2.100000i) (5.000000,0.000000i) (6.000000,2.600000i) (0.000000,0.000000i)
(0.000000,0.000000i) (6.000000,-2.600000i) (9.000000,0.000000i) (10.000000,2.000000i)
(0.000000,0.000000i) (0.000000,0.000000i) (10.000000,-2.000000i) (11.000000,0.000000i)
and a complex vector
(11.000000,2.000000i)
(12.000000,0.000000i)
(13.000000,2.000000i)
(14.000000,1.800000i)
void test_f06sdc() //test for function zhbmv(f06sdc)
{
int nRowCol=4;
matrix<complex> mat_input={{1,2+2.1i,0,0},
{2-2.1i,5,6+2.6i,0},
{0,6-2.6i,9,10+2i},
{0,0,10-2i,11}};
int k_nzero=1;
matrix<complex> mat_input_band={{1,2+2.1i},
{5,6+2.6i},
{9,10+2i},
{11,0}};
vector<complex> vec_input={11+2i,12,13+2i,14+1.8i};
vector<complex> vec_output(nRowCol);
vec_output=0;
zhbmv(UpperTriangle,nRowCol,k_nzero,1,mat_input_band,k_nzero+1,vec_input,1,1,vec_output,1);
printf("Compute a matrix-vector product for complex Hermitian band matrix M*V:\n");
printf("M=\n"); //output mat_input
for(int i=0;i<nRowCol;i++)
{
printf(" ");
for(int j=0;j<nRowCol;j++)
printf("(%f,%fi) ",mat_input[i][j].m_re,mat_input[i][j].m_im);
printf("\n");
}
printf("\n"); //output vec_input
printf("V=\n");
for(i=0;i<nRowCol;i++)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -