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

📄 ocn_f06.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 5 页
字号:
	   		 /*------------------------------------------------------------------------------*
 * File Name: OCN_f06.h															*
 * Creation: TCZ 7/25/2001														*
 * Purpose: Origin C Header for NAG functions									*
 * Copyright (c); OriginLab Corp.	2001										*
 * All Rights Reserved															*
 * 																				*
 * Modification Log:															*
 *------------------------------------------------------------------------------*/

#ifndef _O_NAG_f06_H
#define _O_NAG_f06_H

//#importdll "ONAG" // NAG DLL prepared by OriginLab
#pragma dll(ONAG)
#include <NAG\nag_types.h>
/* 
////////////////////////////////////////////////////////////////////////////////
This headfile contains the basic linear algebra functions in NAG_Chapter f06 which 
perform elementary algebraic operations involving vectors and matricces. 

The enumeration types given by
  typedef enum 
  { 
      NoTranspose,  //Operate with the matrix
      Transpose,    //Operate with the transpose of the matrix
      ConjugateTranspose   //Operate with the conjugate transpose of the matrix
  } MatrixTranspose;
  
  typedef enum 
  { 
      UpperTriangle, //Upper triangle
      LowerTriangle  // Lower triangle
  } MatrixTriangle;
  
  typedef enum 
  { 
      UnitTriangular, // Unit triangular, the diagonal elements are not referenced
      NotUnitTriangular // Non-unit triangular
  } MatrixUnitTriangular;
  
  typedef enum 
  { 
      LeftSide, // Multiply general matrix by symmetric, Hermitian or triangular matrix on the left
      RightSide // Multiply general matrix by symmetric, Hermitian or triangular matrix on the right
  } OperationSide;
*/
/////////////////////////////////////////////////////////////////////////////////

/** f06pac
		computes a matrix-vector product for general matrix.
		
Example:
	This example computes the matrix-vector product for a general matrix
        1  2  3  4
        5  6  7  8
        9 10 11 12
       13 14 15 16
    
    and a vector
       17
       18
       19
       20.

void test_f06pac()      //test for function dgemv(f06pac)
{
    int nRows=4;
    int nCols=4;

    matrix<double> mat_input={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};

    vector<double> vec_input={17,18,19,20};

    vector<double> vec_output(nRows);
    vec_output=0;

    dgemv(NoTranspose,nRows,nCols,1,mat_input,nCols,vec_input,1,1,vec_output,1);

    printf("Compute a matrix-vector product for general real matrix M*V:\n");

    printf("M=\n");                     //output mat_input
    for(int i=0;i<nRows;i++)
    {
       printf("       ");
       for(int j=0;j<nCols;j++)
          printf("%f    ",mat_input[i][j]);
       printf("\n");
    }

    printf("\n");                       //output vec_input
    printf("V=\n");
    for(i=0;i<nRows;i++)
    {
      printf("       ");
      printf("%f\n",vec_input[i]);
    }

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

	The output is following:
	
Compute a matrix-vector product for general real matrix M*V:
M=
       1.000000    2.000000    3.000000    4.000000    
       5.000000    6.000000    7.000000    8.000000    
       9.000000    10.000000    11.000000    12.000000    
       13.000000    14.000000    15.000000    16.000000    

V=
       17.000000
       18.000000
       19.000000
       20.000000

Result vector=
       190.000000
       486.000000
       782.000000
       1078.000000


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  dgemv(
MatrixTranspose trans,
int m,  //the number of rows of A
int n,  // the number of columns of A
double alpha, 
const double a[], //a general m by n matrix
int tda, //the last demension of A
const double x[], //vector x
int incx,  //the spacing which the elements of the vector x occur
double beta,
double y[], //Input: vector y; Output: alpha*trans(A)*x + beta*y
int incy   //the spacing which the elements of the vector y occur
);

/** f06sac
       Compute a matrix-vector product for complex general matrix
Example:
	This example computes the matrix-vector product for a general complex matrix
        1+2i,8+3i,2+3i,3+4i
        2+1i,3+1i,5+2i,4+4i
        1+3i,2+1i,2+3i,5+4i
        1+4i,2+3i,6+1i,2+4i
    
    and a vector
       2+2i
       1+1i
       3+2i
       2+4i.

void test_f06sac()    //test for function zgemv(f06sac)
{
   int nRows=4;
   int nCols=4;

   matrix<complex>  mat_input={{1+2i,8+3i,2+3i,3+4i},
                               {2+1i,3+1i,5+2i,4+4i},
                               {1+3i,2+1i,2+3i,5+4i},
                               {1+4i,2+3i,6+1i,2+4i}};

   vector<complex>  vec_input={2+2i,1+1i,3+2i,2+4i};

   vector<complex>  vec_output(nRows);
   vec_output=0;

   zgemv(NoTranspose,nRows,nCols,1,mat_input,nCols,vec_input,1,1,vec_output,1);

   printf("Compute a matrix-vector product for general complex matrix M*V:\n");

   printf("M=\n");                     //output mat_input
   for(int i=0;i<nRows;i++)
   {
       printf("       ");
       for(int j=0;j<nCols;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<nRows;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<nRows;i++)
   {
      printf("       ");
      printf("(%f,%fi)\n",vec_output[i].m_re,vec_output[i].m_im);
   }
}

	The output is following:
	
Compute a matrix-vector product for general complex matrix M*V:
M=
       (1.000000,2.000000i)    (8.000000,3.000000i)    (2.000000,3.000000i)    (3.000000,4.000000i)    
       (2.000000,1.000000i)    (3.000000,1.000000i)    (5.000000,2.000000i)    (4.000000,4.000000i)    
       (1.000000,3.000000i)    (2.000000,1.000000i)    (2.000000,3.000000i)    (5.000000,4.000000i)    
       (1.000000,4.000000i)    (2.000000,3.000000i)    (6.000000,1.000000i)    (2.000000,4.000000i)    

V=
       (2.000000,2.000000i)
       (1.000000,1.000000i)
       (3.000000,2.000000i)
       (2.000000,4.000000i)

Result vector=
       (-7.000000,50.000000i)
       (7.000000,50.000000i)
       (-9.000000,52.000000i)
       (-3.000000,46.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  zgemv(
MatrixTranspose trans, 
int m,  //the number of rows of A
int n,  //the number of columns of A
complex alpha, 
const complex a[], //the m by n complex matrix A 
int tda, // the last dimension of A
const complex x[], // the vector x
int incx,  //the spacing which the elements of the vector x occur
complex beta, 
complex y[], //Input: the vecor y; Output: alpha*trans(A)*x+beta*y
int incy   // the spacing which the elements of the vector y occur
);



/** f06pbc
       Compute a matrix-vector product for real general band matrix
Example:
	This example computes the matrix-vector product for a real matrix
	   1.000000    2.000000    3.000000    0.000000    
       4.000000    5.000000    6.000000    7.000000    
       0.000000    8.000000    9.000000    10.000000  
    which in band storage and a real vector
       11 
       12
       13
       14
       
void test_f06pbc()              //test for function dgbmv(f06pbc)
{
   int nRows=3;
   int nCols=4;

   matrix<double> mat_input={{1,2,3,0},
                             {4,5,6,7},
                             {0,8,9,10}};
                             
   matrix<double> mat_input_band={{0,1,2,3},
                                  {4,5,6,7},
                                  {8,9,10,0}};
   int kupper=2;
   int klower=1;

   vector<double> vec_input={11,12,13,14};

   vector<double> vec_output(nRows);
   vec_output=0;

   dgbmv(NoTranspose,nRows,nCols,klower,kupper,1,mat_input_band,nCols,vec_input,1,1,vec_output,1);

   printf("Compute a matrix-vector product for real band matrix M*V:\n");

   printf("M=\n");                     //output mat_input
   for(int i=0;i<nRows;i++)
   {
       printf("       ");
       for(int j=0;j<nCols;j++)
          printf("%f    ",mat_input[i][j]);
       printf("\n");
   }

   printf("\n");                       //output vec_input
   printf("V=\n");
   for(i=0;i<nCols;i++)
   {
      printf("       ");
      printf("%f\n",vec_input[i]);
   }

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

  The output is following:
Compute a matrix-vector product for real band matrix M*V:
M=
       1.000000    2.000000    3.000000    0.000000    
       4.000000    5.000000    6.000000    7.000000    
       0.000000    8.000000    9.000000    10.000000    

V=
       11.000000
       12.000000
       13.000000
       14.000000

Result vector=
       74.000000
       280.000000
       353.000000
  	

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  dgbmv(
MatrixTranspose trans, 
int m, // the number of rows of A
int n, // the number of columns of A 
int kl, //specify the subdiagonals of the matrix A
int ku, //specify the superdiagonals of the matrix A
double alpha,
const double a[], //the real m by n matrix A which stored in band storage
int tda, // the last dimension of A
const double x[], // vector x
int incx,  // the spacing which the elements of the vector x occur
double beta, 
double y[], //Input: vector y; Output: alpha*trans(A)*x+beta*y
int incy   // the spacing which the elements of vector y occur
);


/** f06sbc
       Compute a matrix-vector product for complex general band matrix
Example:
	This example computes the matrix-vector product for a complex general matrix
	   (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)    
    which is stored in band storage and a complex vector
       (11.000000,2.000000i)
       (12.000000,0.000000i)
       (13.000000,2.000000i)
       (14.000000,1.800000i)
       
void test_f06sbc()     //test for function zgbmv(f06sbc)
{
   int nRows=3;
   int nCols=4;

   matrix<complex> mat_input={{1+1.2i,2+2.1i,3+1.0i,0},
                             {4+2.6i,5+1.2i,6+2.6i,7+4.1i},
                             {0,8+1i,9,10+2i}};
   int kupper=2;
   int klower=1;
   matrix<complex> mat_input_band={{0,1+1.2i,2+2.1i,3+1.0i},
                                  {4+2.6i,5+1.2i,6+2.6i,7+4.1i},
                                  {8+1i,9,10+2i,0}};

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

   vector<complex> vec_output(nRows);
   vec_output=0;

   zgbmv(NoTranspose,nRows,nCols,klower,kupper,1,mat_input_band,nCols,vec_input,1,1,vec_output,1);

   printf("Compute a matrix-vector product for complex band matrix M*V:\n");

   printf("M=\n");                     //output mat_input
   for(int i=0;i<nRows;i++)
   {
       printf("       ");
       for(int j=0;j<nCols;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<nCols;i++)
   {
      printf("       ");
      printf("(%f,%fi)\n",vec_input[i].m_re,vec_input[i].m_im);

⌨️ 快捷键说明

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