LU decomposition of complex dense matrices

David Lidsky <[email protected]>
Newsgroups gmane.comp.lib.mtl.devel
Message-ID <[email protected]>
Hi,

I'm interested in inverting small dense complex
matrices.  The mtl function, lu_factorize, works fine
for a real matrix.  I'd like to make it work for a
complex matrix.  Naively putting in a complex matrix
does not give the correct LU decomposition.  Delving a
little bit deeper, I found that the mtl max_index
function does not work for complex vectors.  For
example, the largest (magnitude) component in the
vector (1 + 0*i, 0 - 2*i) is the second (last) one. 
But max_index gives the first one.  The following code
demonstrates this:

// -*- c++ -*-
//
// $COPYRIGHT$
//
//===========================================================================
#include "C:/Include/mtl/workaround.h"
#include "C:/Include/mtl/utils.h" 
#include "C:/Include/mtl/linalg_vec.h"
#include "C:/Include/mtl/mtl.h"
using namespace mtl;
using namespace std;
//begin
typedef external_vec<complex <double> > Vec;
//end

/*
  Sample Output 

  [(1,0),(0,-2),]
	Largest element in the vector z is at location 1

 */

// How can we make it give the desired answer:
// "Largest element in the vector z is at location 2"



int main()
{
	const int N = 2;
	complex<double> I(0,1);
	complex<double> test[] = {1, -2.0*I};
	Vec z(test,N);
	int imax = max_index(z);
	print_vector(z);
	cout << "Largest element in the vector z is at
location "
         << imax << endl;
    return 0;
}  

How can I modify the code so that it works for complex
numbers?

Dave



=====
[email protected]
David Lidsky


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
_______________________________________________
This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.