Matrix 矩阵向量乘法,在Lapack中丢失

Matrix 矩阵向量乘法,在Lapack中丢失,matrix,vector,multiplication,lapack,Matrix,Vector,Multiplication,Lapack,我想计算 x^T A x*(x转置矩阵A乘以x共轭复数) 使用Lapack。我没有找到这个函数。还是有一个?最快的方法是什么?您可以通过两个单独的步骤计算操作: computey我想你是在问Fortran代码吧? program main use blas95 implicit none integer, parameter :: n = 2 complex :: x(n), y(n), A(n,n), res complex :: cdotu ! init v

我想计算

x^T A x*(x转置矩阵A乘以x共轭复数)


使用Lapack。我没有找到这个函数。还是有一个?最快的方法是什么?

您可以通过两个单独的步骤计算操作:


  • compute
    y我想你是在问Fortran代码吧?
    
    program main
    
      use blas95
    
      implicit none
    
      integer, parameter :: n = 2
      complex :: x(n), y(n), A(n,n), res
    
      complex :: cdotu
    
      ! init vector x, matrix A by some data
      x = [(1, 1), (-1, 2)]
      A = reshape([1, 2, 3, 4], [n, n])
    
      ! compute: y <- A * conjg(x)
      call cgemv('N', n, n, (1, 0), A, n, conjg(x), 1, (0, 0), y, 1)    ! standard BLAS
      call gemv(A, conjg(x), y)                                         ! BLAS95 from intel MKL
    
      ! compute: res <- x^T * y
      res = cdotu(n, x, 1, y, 1)                                        ! standard BLAS
      res = dotu(x, y)                                                  ! BLAS95 from intel MKL
    end program