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

📄 matrixvectormul.c

📁 matrixvectormul.c “矩阵向量乘”
💻 C
字号:
/*******************************************************************************
Prototype:  void MatrixVectorProduct(char S, int Size, complex *XVec, 
              complex *AVec, int *RIIndex,int **RICol,complex **RIDat)
Description:    To multiply the final matrix equation { [FEM] +[Cdd] }
                with a vector. 
Input value: 
    complex **RIDat, int RIIndex, int **RICol --- the FEM matrix stored using the row-indexed scheme.
    complex *XVec --- pointer to a vector of complex type
    complex *AVec --- where the results are stored.
    int Size  --- the dimension of the vectors.  The vector and the matrix  
                  should have the same dimension.
    char S --- operation type. If s== '  ',  return [A]={[FEM] +[Cdd] }[X]. 
               If S='*', return [A]={[FEM] +[Cdd] }*[X], 
               where * denoteds conjugate.
Return value:   none
Global value used:  Cdd
Global value modified:     none 
Subroutines called:   COMplex_Add(), COMplex_Null(), COMplex_Mul(), 
                      COMplex_Conjg(), 
*******************************************************************************/
void MatrixVectorProduct(char S, int Size, complex *XVec, complex *AVec, 
                         int *RIIndex,int **RICol,complex **RIDat)
{   
    int II;
    int IEdge, JEdge;
  
    for(II=0;II<Size;II++)
        AVec[II]=COMplex_Null();
 
    if( S==' ' )
    {
        for(IEdge=0; IEdge<Size; IEdge++) 
            for(JEdge=0; JEdge<RIIndex[IEdge]; JEdge++)
                AVec[IEdge] = COMplex_Add(AVec[IEdge],
                      COMplex_Mul(RIDat[IEdge][JEdge],
                                  XVec[ RICol[IEdge][JEdge]]) );
     
        /* moment mehtod part is added to the right-bottom corner */
        for(IEdge=0;IEdge<HybrdBoundEdgeNum;IEdge++)  
            for(JEdge=0;JEdge<HybrdBoundEdgeNum;JEdge++)  
                 AVec[IEdge+TotInnerEdgeNum] =   COMplex_Add( 
                     AVec[IEdge+TotInnerEdgeNum],
                     COMplex_Mul(Cdd[IEdge][JEdge], 
                             XVec[JEdge+TotInnerEdgeNum]));
   }   /* if(S==' '  */
   
   
   else  /* S== '*'  */
   {
   
       for(IEdge=0; IEdge<Size; IEdge++) 
           for(JEdge=0; JEdge<RIIndex[IEdge]; JEdge++) 
               AVec[IEdge] = COMplex_Add(AVec[IEdge],
                   COMplex_Mul(COMplex_Conjg(RIDat[IEdge][JEdge]),
                               XVec[ RICol[IEdge][JEdge]]) );
      
       /* moment method part Cdd is added to the right-bottom corner */
       for(IEdge=0;IEdge<HybrdBoundEdgeNum;IEdge++)   
           for(JEdge=0;JEdge<HybrdBoundEdgeNum;JEdge++)               
               AVec[IEdge+TotInnerEdgeNum] = COMplex_Add( 
                    AVec[IEdge+TotInnerEdgeNum], 
                    COMplex_Mul(COMplex_Conjg(Cdd[JEdge][IEdge]), 
                                XVec[JEdge+TotInnerEdgeNum]));
      
   }  /*  else */
   
} /* end of MatrixVectorProduct() */

⌨️ 快捷键说明

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