[eigen] Unexpected behavior of applyHouseholderOnTheRight() |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] Unexpected behavior of applyHouseholderOnTheRight()
- From: Yixuan Qiu <yixuanq@xxxxxxxxx>
- Date: Sat, 15 Apr 2017 16:16:05 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cos-name.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:from:date:message-id:subject:to; bh=b0a8fgt7TJOn9pWti774S73odVy656qaqsn87r9DKOU=; b=FqLv19BNy5s7EFRkDY+UcQOyFdGRx54PPvCJZNkvMoccpoRUavwM1qyDJg4q8wFrws sH9e8tG6Oy3simy1wUec7Z14jAX7gWu3LtAwE4uLlofHOqBzSLK2p/Ibc4w/NXlHxRJD 5F+cnf/6HMDkxLd2DH/8YTOYsNG6kvgoYwuUp+Zi78oP6QXuHQDYSCrgigq4SNWGs/Nd 8ugl8ia4I/entX5u7lae17dmdbhvaE2veorQmPvDBSHWvvmU9b52p7RDx7AfFvBtJvsU 62VFNWmGFZYHhTsL4TBns8nnGgfg8UtD4500GSm0ovZmed72rPcQZ9SGguibtgdrnSYU BYug==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=b0a8fgt7TJOn9pWti774S73odVy656qaqsn87r9DKOU=; b=GOuMv4SWenuFFpeNbcfYQvwdcpT0ReX+CgjaxAU4o1jSqRogpwlEhRJBcMRaCBb4k2 IgGBgrjBadqfBCwHaksJcdU1FIldoIenfBF+R0Tm0T+y+pQusZxDp2cY9brll7vg6a3Z s1aIX/iDN14C8ASaTUYap8HnZZnrkw3zJQ0xqfHnqJfaXFltF7KB5tI4IeVqCCov/8IA iUYxlhzuqW+kCmJsXTu+6SSiCcO8SDPRq49N4s0HoL26J6FyE+pAYww+Qgw76Oby26hH nfNEHuLBDIrUSIDjThXY2HVM3pT4DqR0MsNeiseJQLiQPjL4GjRlCgXqcyAJ5j7vBHyf kk9Q==
Hi All,
I have a question on the MatrixBase::applyHouseholderOnTheRight() function that applies a Householder transformation to a matrix on the right.
If the Householder transformation is H, then I expect that this function will calculate X * H or X * H^*, depending on the definition. But in fact I find that it calculates X * H^T, which is fine with real-valued matrices but is quite confusing with complex-valued matrices.
Attached is a minimal example to reproduce the issue. I wonder if this is a "bug" or my own misunderstanding of the function.
Thanks.
Best,
Yixuan
#include <Eigen/Eigenvalues>
#include <iostream>
using Eigen::VectorXcd;
using Eigen::MatrixXcd;
int main()
{
const int n = 3;
std::srand(0);
VectorXcd x = VectorXcd::Random(n);
VectorXcd essential(n - 1);
std::complex<double> tau;
double beta;
// Create a random Householder transformation
x.makeHouseholder(essential, tau, beta);
std::cout << "essential = \n" << essential << std::endl << std::endl;
std::cout << "tau = " << tau << std::endl << std::endl;
std::cout << "beta = " << beta << std::endl << std::endl;
// Compute the transformation matrix by definition
// H = 1 - tau * v * v^*, v = [1 essential^T]^T
VectorXcd h(n);
h[0] = std::complex<double>(1, 0);
h.tail(n - 1) = essential;
MatrixXcd H = MatrixXcd::Identity(n, n) - tau * h * h.adjoint();
std::cout << "H = \n" << H << std::endl << std::endl;
// Compute the results of applying the transformation to an identity matrix
MatrixXcd H_left = MatrixXcd::Identity(n, n);
MatrixXcd H_right = MatrixXcd::Identity(n, n);
VectorXcd tmp(n);
H_left.applyHouseholderOnTheLeft(essential, tau, tmp.data());
H_right.applyHouseholderOnTheRight(essential, tau, tmp.data());
// It shows that H_left = H, but H_right = H^T (not H or H^*)
std::cout << "H_left = \n" << H_left << std::endl << std::endl;
std::cout << "H_right = \n" << H_right << std::endl << std::endl;
return 0;
}