Efficient way of computing X'*A*X where A is symmetric

Open discussion regarding features, bugs, issues, vendors, etc.

Efficient way of computing X'*A*X where A is symmetric

Postby eev234 » Mon Jul 18, 2011 10:07 am

Hi All.

I was would like to ask what is the best way of evaluating the following product of matrices:

Let X be m-by-n, A be m-by-m and symmetric and I want to compute
C = X' * A * X
where X' is the transpose of X. The result is a symmetric n-by-n matrix. The only option I can find is to call dgemm twice. Any ideas?
eev234
 
Posts: 2
Joined: Mon Jul 18, 2011 9:55 am

Re: Efficient way of computing X'*A*X where A is symmetric

Postby cottrell » Thu Jul 21, 2011 10:02 pm

So far as I know, there is no built-in BLAS function that will do this.

You could take a look at the implementation in libgretl, at
http://gretl.cvs.sourceforge.net/viewvc/gretl/gretl/lib/src/gretl_matrix.c?revision=1.495&view=markup
Look for gretl_matrix_qform (for quadratic form).

The "gretl_matrix_set" and "gretl_matrix_get" things are macros. defined in
http://gretl.cvs.sourceforge.net/viewvc/gretl/gretl/lib/src/gretl_matrix.h?revision=1.237&view=markup

The nice thing about the "gretl_matrix" type from the pov of this forum
is that the actual data storage is just a one-dimensional array of doubles,
in column-major order, and so is fully compatible with lapack.
cottrell
 
Posts: 68
Joined: Thu Jan 15, 2009 1:40 pm

Re: Efficient way of computing X'*A*X where A is symmetric

Postby eev234 » Thu Jul 28, 2011 4:58 am

Dear cottrell,

Thank you for your reply. That was very helpful. I looked into it and I think it's what I am looking for.
eev234
 
Posts: 2
Joined: Mon Jul 18, 2011 9:55 am


Return to User Discussion

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests