⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ocn_f06.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 5 页
字号:
    vector<complex> vec_output(nRowCol);
    vec_output=vec_input;

    ztpmv(UpperTriangle,NoTranspose,NotUnitTriangular,nRowCol,
             mat_input_pack,vec_output,1);

    printf("Compute a matrix-vector product for complex tringular packed 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 tringular packed 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  ztpmv(
MatrixTriangle uplo, 
MatrixTranspose trans, 
MatrixUnitTriangular diag, 
int n, //the order of A
const complex ap[], //the complex triangular packed matrix A 
complex x[], //Input: the vector x; Output: the product of A and x
int incx //the spacing which the elements of x occur
);

/** f06pjc
       Solve a system of equations for real triangular coefficient matrix
Example:
	This example solve a system of equations Ax=b, where matrix A is
       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 the vector b is
       12.000000
       13.000000
       14.000000
       15.000000


void test_f06pjc()         //test for function dtrsv(f06pjc)
{
    int nColRow=4;

    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;
    vec_output=vec_input;
    
    dtrsv(UpperTriangle,NoTranspose,NotUnitTriangular,nColRow,
            mat_input,nColRow,vec_output,1);

    printf("Solve a system of equations for real triangular matrix M*X=B:\n");

    printf("M=\n");                     //output mat_inputM
    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_inputB
    printf("B=\n");
    for(i=0;i<nColRow;i++)
    {
      printf("       ");
      printf("%f\n",vec_input[i]);
    }

    printf("\n");                       //output vec_outputX
    printf("Result vector=\n");
    for(i=0;i<nColRow;i++)
    {
      printf("       ");
      printf("%f\n",vec_output[i]);
    }
}


   The output is as following:
Solve a system of equations for real triangular matrix M*X=B:
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    

B=
       12.000000
       13.000000
       14.000000
       15.000000

Result vector=
       5.821549
       0.301347
       0.040404
       1.363636

Parameters:
	trans=NoTranspose, solve the equations A*x=b;
	trans=Transpose, solve the equations Transpose(A)*x=b;
	trans=ConjugateTranspose, solve the equations ConjugateTranspose(A)*x=b.
	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  dtrsv(
MatrixTriangle uplo, 
MatrixTranspose trans, 
MatrixUnitTriangular diag, 
int n, //the order of A
const double a[], //the order n real triangular coefficient matrix
int tda, //the last dimension of A
double x[],//Input: the vector b; Output: the solution of the equations, vector x
int incx // the spacing which the elements of vecter x occur
);

/** f06sjc
       Solve a system of equations for complex triangular coefficient matrix
Example:
	This example solve a system of equations Ax=b, where matrix A is
       (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)    


    and the vector b is
       (11.000000,2.000000i)
       (12.000000,0.000000i)
       (13.000000,2.000000i)
       (14.000000,1.800000i)

void test_f06sjc()      //test for function ztrsv(f06sjc)
{
   int nRowCol=4;

   matrix<complex> mat_input={{1+1.2i,2+2.1i,4+0.5i,1},
                              {0,5+1.2i,6+2.6i,2+1i},
                               {0,0,9,10+2i},
                               {0,0,0,11+4i}};

   vector<complex> vec_input={11+2i,12,13+2i,14+1.8i};

   vector<complex> vec_output(nRowCol);
   vec_output=vec_input;

   ztrsv(UpperTriangle,NoTranspose,NotUnitTriangular,nRowCol,
            mat_input,nRowCol,vec_output,1);

   printf("Solve a system of equations for complex triangular matrix M*X=B:\n");

   printf("M=\n");                     //output mat_inputM
   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_inputB
   printf("B=\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_outputX
   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:
Solve a system of equations for complex triangular matrix M*X=B:
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)    

B=
       (11.000000,2.000000i)
       (12.000000,0.000000i)
       (13.000000,2.000000i)
       (14.000000,1.800000i)

Result vector=
       (1.498443,-2.397366i)
       (1.702533,-0.884189i)
       (0.078345,0.254339i)
       (1.176642,-0.264234i)

Parameters:
	trans=NoTranspose, solve the equations A*x=b;
	trans=Transpose, solve the equations Transpose(A)*x=b;
	trans=ConjugateTranspose, solve the equations ConjugateTranspose(A)*x=b.
	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  ztrsv(
MatrixTriangle uplo, 
MatrixTranspose trans, 
MatrixUnitTriangular diag, 
int n, // the order of A
const complex a[], //the order n complex triangular coefficient matrix A
int tda, // the last dimension of A
complex x[], //Input: the vctor b; Output: the solution of the equations, vector x
int incx //the spacing which the elements of vector x occur
);

/** f06pkc
       Solve a system of equations for real triangular band coefficient matrix
Example:
	This example solve a system of equations Ax=b, where matrix A is
       1.000000    2.000000    0.000000    0.000000    
       0.000000    1.000000    2.000000    0.000000    
       0.000000    0.000000    1.000000    2.000000    
       0.000000    0.000000    0.000000    1.000000   
       
    and the vector b is
       2.000000
       2.000000
       2.000000
       2.000000

void test_f06pkc()              //test for function dtbsv(f06pkc)
{
   int nRowCol=4;

   matrix<double> mat_input={{1,2,0,0},
                             {0,1,2,0},
                             {0,0,1,2},
                             {0,0,0,1}};
   int k_nzero=1;
   matrix<double> mat_input_band={{1,2},
                                 {1,2},
                                 {1,2},
                                 {1,0}};

   vector<double> vec_input={2,2,2,2};

   vector<double> vec_output(nRowCol);
   vec_output=vec_input;

   dtbsv(UpperTriangle,NoTranspose,NotUnitTriangular,nRowCol,k_nzero,
            mat_input_band,k_nzero+1,vec_output,1);
            

   printf("Solve a system of equations for real triangular band matrix M*X=B:\n");

   printf("M=\n");                     //output mat_inputM
   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_inputB
   printf("B=\n");
   for(i=0;i<nRowCol;i++)
   {
      printf("       ");
      printf("%f\n",vec_input[i]);
   }

   printf("\n");                       //output vec_outputX
   printf("Result vector=\n");
   for(i=0;i<nRowCol;i++)
   {
      printf("       ");
      printf("%f\n",vec_output[i]);
   }
   
}


   The output is as following:
Solve a system of equations for real triangular band matrix M*X=B:
M=
       1.000000    2.000000    0.000000    0.000000    
       0.000000    1.000000    2.000000    0.000000    
       0.000000    0.000000    1.000000    2.000000    
       0.000000    0.000000    0.000000    1.000000    

B=
       2.000000
       2.000000
       2.000000
       2.000000

Result vector=
       -10.000000
       6.000000
       -2.000000
       2.000000

Parameters:
	trans=NoTranspose, solve the equations A*x=b;
	trans=Transpose, solve the equations Transpose(A)*x=b;
	trans=ConjugateTranspose, solve the equations ConjugateTranspose(A)*x=b.
	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  dtbsv(
MatrixTriangle uplo,
MatrixTranspose trans, 
MatrixUnitTriangular diag, 
int n, //the oder of A
int k, //the subdiagonals(superdiagonals) of A
const double a[], //the real triangular band coefficient matrix A
int tda, //the last dimension of A
double x[], //Input: the vector b; Output: the solution of the equations, vector x
int incx //the spacing which the elements of vector x occur
);

/** f06skc
       Solve a system of equations for complex triangular band coefficient matrix
Example:
	This example solve a system of equations Ax=b, where matrix A is
       (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 the vector b is
       (11.000000,2.000000i)
       (12.000000,0.000000i)
       (13.000000,2.000000i)
       (14.000000,1.800000i)

void test_f06skc()      //test for function ztbsv(f06skc)
{
   int nRowCol=4;

   matrix<complex> mat_input={{1+1.2i,2+2.1i,0,0},
                              {0,5+1.2i,6+2.6i,0},
                   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -