📄 ocn_f06.h
字号:
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 band matrix M*V:
M=
(1.000000,1.200000i) (2.000000,2.100000i) (4.000000,0.500000i) (1.000000,0.000000i)
(0.000000,0.000000i) (5.000000,1.200000i) (6.000000,2.600000i) (2.000000,1.000000i)
(0.000000,0.000000i) (0.000000,0.000000i) (9.000000,0.000000i) (10.000000,2.000000i)
(0.000000,0.000000i) (0.000000,0.000000i) (0.000000,0.000000i) (11.000000,4.000000i)
V=
(11.000000,2.000000i)
(12.000000,0.000000i)
(13.000000,2.000000i)
(14.000000,1.800000i)
Result vector=
(97.600000,56.700000i)
(159.000000,77.800000i)
(253.400000,64.000000i)
(146.800000,75.800000i)
Parameters:
trans=NoTranspose, return A*x in array x[];
trans=Transpose, return transpose(A)*x in array x[];
trans=ConjugateTranspose, return ConjugateTranspose(A)*x in array x[].
uplo specify whether the upper (uplo=UpperTriangle) or lower (uplo=LowerTriangle) triangle is being reference.
diag specify whether or not the matrix is unit triangular. if diag=UnitTriangular, the diagonal elements are not referenced.
Return: NULL
*/
void ztrmv(
MatrixTriangle uplo,
MatrixTranspose trans,
MatrixUnitTriangular diag,
int n, //the order of the complex triangular matrix A
const complex a[], //order n complex triangular matrix A
int tda, //the last dimension of A
complex x[], // Input: the complex vector x; Output: the product of A and x
int incx //the spacing which the elemnets of x occur
);
/** f06pgc
Compute a matrix-vector product for real triangular band matrix
Example:
This example computes the matrix-vector product for a real triangular band matrix
1.000000 2.000000 3.000000 0.000000
0.000000 5.000000 6.000000 7.000000
0.000000 0.000000 9.000000 10.000000
0.000000 0.000000 0.000000 11.000000
and a real vector
11.000000
12.000000
13.000000
14.000000
void test_f06pgc() //test for function dtbmv(f06pgc)
{
int nRowCol=4;
matrix<double> mat_input={{1,2,3,0},
{0,5,6,7},
{0,0,9,10},
{0,0,0,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=vec_input;
dtbmv(UpperTriangle,NoTranspose,NotUnitTriangular,nRowCol,k_nzero,
mat_input_band,k_nzero+1,vec_output,1);
printf("Compute a matrix-vector product for real tringular 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 tringular band matrix M*V:
M=
1.000000 2.000000 3.000000 0.000000
0.000000 5.000000 6.000000 7.000000
0.000000 0.000000 9.000000 10.000000
0.000000 0.000000 0.000000 11.000000
V=
11.000000
12.000000
13.000000
14.000000
Result vector=
74.000000
236.000000
257.000000
154.000000
Parameters:
trans=NoTranspose, return A*x in array x[];
trans=Transpose, return transpose(A)*x in array x[];
trans=ConjugateTranspose, return ConjugateTranspose(A)*x in array x[].
uplo specify whether the upper (uplo=UpperTriangle) or lower (uplo=LowerTriangle) triangle is being reference.
diag specify whether or not the matrix is unit triangular. if diag=UnitTriangular, the diagonal elements are not referenced.
Return: NULL
*/
void dtbmv(
MatrixTriangle uplo,
MatrixTranspose trans,
MatrixUnitTriangular diag,
int n, //the order of A
int k, //the subdiagonals(superdiagonals) of A
const double a[], //the real triangular band matrix A
int tda, //the last dimension of A
double x[], //Input: the vector x; Output: the product of A and x
int incx //the spacing which the elements of vector x occur
);
/** f06sgc
Compute a matrix-vector product for complex triangular band matrix
Example:
This example computes the matrix-vector product for a complex triangular band matrix
(1.000000,1.200000i) (2.000000,2.100000i) (0.000000,0.000000i) (0.000000,0.000000i)
(0.000000,0.000000i) (5.000000,1.200000i) (6.000000,2.600000i) (0.000000,0.000000i)
(0.000000,0.000000i) (0.000000,0.000000i) (9.000000,0.000000i) (10.000000,2.000000i)
(0.000000,0.000000i) (0.000000,0.000000i) (0.000000,0.000000i) (11.000000,4.000000i)
and a complex vector
(11.000000,2.000000i)
(12.000000,0.000000i)
(13.000000,2.000000i)
(14.000000,1.800000i)
void test_f06sgc() //test for function ztbmv(f06sgc)
{
int nRowCol=4;
matrix<complex> mat_input={{1+1.2i,2+2.1i,0,0},
{0,5+1.2i,6+2.6i,0},
{0,0,9,10+2i},
{0,0,0,11+4i}};
int k_nzero=1;
matrix<complex> mat_input_band={{1+1.2i,2+2.1i},
{5+1.2i,6+2.6i},
{9,10+2i},
{11+4i,0}};
vector<complex> vec_input={11+2i,12,13+2i,14+1.8i};
vector<complex> vec_output(nRowCol);
vec_output=vec_input;
ztbmv(UpperTriangle,NoTranspose,NotUnitTriangular,nRowCol,k_nzero,
mat_input_band,k_nzero+1,vec_output,1);
printf("Compute a matrix-vector product for complex triangular 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++)
{
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 triangular band matrix M*V:
M=
(1.000000,1.200000i) (2.000000,2.100000i) (0.000000,0.000000i) (0.000000,0.000000i)
(0.000000,0.000000i) (5.000000,1.200000i) (6.000000,2.600000i) (0.000000,0.000000i)
(0.000000,0.000000i) (0.000000,0.000000i) (9.000000,0.000000i) (10.000000,2.000000i)
(0.000000,0.000000i) (0.000000,0.000000i) (0.000000,0.000000i) (11.000000,4.000000i)
V=
(11.000000,2.000000i)
(12.000000,0.000000i)
(13.000000,2.000000i)
(14.000000,1.800000i)
Result vector=
(32.600000,40.400000i)
(132.800000,60.200000i)
(253.400000,64.000000i)
(146.800000,75.800000i)
Parameters:
trans=NoTranspose, return A*x in array x[];
trans=Transpose, return transpose(A)*x in array x[];
trans=ConjugateTranspose, return ConjugateTranspose(A)*x in array x[].
uplo specify whether the upper (uplo=UpperTriangle) or lower (uplo=LowerTriangle) triangle is being reference.
diag specify whether or not the matrix is unit triangular. if diag=UnitTriangular, the diagonal elements are not referenced.
Return: NULL
*/
void ztbmv(
MatrixTriangle uplo,
MatrixTranspose trans,
MatrixUnitTriangular diag,
int n,
int k,
const complex a[],
int tda,
complex x[],
int incx
);
/** f06phc
Compute a matrix-vector product for real triangular packed matrix
Example:
This example computes the matrix-vector product for a real triangular packed matrix
1.000000 2.000000 3.000000 4.000000
0.000000 6.000000 7.000000 8.000000
0.000000 0.000000 9.000000 10.000000
0.000000 0.000000 0.000000 11.000000
and a real vector
12.000000
13.000000
14.000000
15.000000
void test_f06phc() //test for function dtpmv(f06phc)
{
int nColRow=4;
matrix<double> mat_input_pack={1,2,3,4,
6,7,8,
9,10,
11};
matrix<double> mat_input={{1,2,3,4},
{0,6,7,8},
{0,0,9,10},
{0,0,0,11}};
vector<double> vec_input={12,13,14,15};
vector<double> vec_output(nColRow);
vec_output=vec_input;
dtpmv(UpperTriangle,NoTranspose,NotUnitTriangular,nColRow,
mat_input_pack,vec_output,1);
printf("Compute a matrix-vector product for real tringular packed 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 tringular packed matrix M*V:
M=
1.000000 2.000000 3.000000 4.000000
0.000000 6.000000 7.000000 8.000000
0.000000 0.000000 9.000000 10.000000
0.000000 0.000000 0.000000 11.000000
V=
12.000000
13.000000
14.000000
15.000000
Result vector=
140.000000
296.000000
276.000000
165.000000
Parameters:
trans=NoTranspose, return A*x in array x[];
trans=Transpose, return transpose(A)*x in array x[];
trans=ConjugateTranspose, return ConjugateTranspose(A)*x in array x[].
uplo specify whether the upper (uplo=UpperTriangle) or lower (uplo=LowerTriangle) triangle is being reference.
diag specify whether or not the matrix is unit triangular. if diag=UnitTriangular, the diagonal elements are not referenced.
Return: NULL
*/
void dtpmv(
MatrixTriangle uplo,
MatrixTranspose trans,
MatrixUnitTriangular diag,
int n, //the order of A
const double ap[], //the real triangular packed matrix A
double x[], //Input: the vector x; Output: the product of A and x
int incx //the spacing which the elements of x occur
);
/** f06shc
Compute a matrix-vector product for complex triangular packed matrix
Example:
This example computes the matrix-vector product for a complex triangular packed matrix
(1.000000,1.200000i) (2.000000,2.100000i) (0.000000,0.000000i) (0.000000,0.000000i)
(0.000000,0.000000i) (5.000000,1.200000i) (6.000000,2.600000i) (0.000000,0.000000i)
(0.000000,0.000000i) (0.000000,0.000000i) (9.000000,0.000000i) (10.000000,2.000000i)
(0.000000,0.000000i) (0.000000,0.000000i) (0.000000,0.000000i) (11.000000,4.000000i)
and a complex vector
(11.000000,2.000000i)
(12.000000,0.000000i)
(13.000000,2.000000i)
(14.000000,1.800000i)
void test_f06shc() //test for function ztpmv(f06shc)
{
int nRowCol=4;
matrix<complex> mat_input_pack={1+1.2i,2+2.1i,0,0,
5+1.2i,6+2.6i,0,
9,10+2i,
11+4i};
matrix<complex> mat_input={{1+1.2i,2+2.1i,0,0},
{0,5+1.2i,6+2.6i,0},
{0,0,9,10+2i},
{0,0,0,11+4i}};
vector<complex> vec_input={11+2i,12,13+2i,14+1.8i};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -