0

I would like to compute

x^T A x* (x transposed times matrix A times x conjugate complex)

using Lapack. I did not find a function for this. Or is there one? What is the fastest way of doing this?

1
  • I assume you are asking about Fortran code? Commented Jun 4, 2021 at 7:28

1 Answer 1

1

You could compute the operation in two separate steps:

  1. compute y <- A x*
  2. compute res <- x^T y

I implemented this in the following program

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

Note: I included the standard BLAS routines as well as the BLAS95 routines available through intel's MKL.


Link to intel's documentation on

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.