/****************************************************************************************************

		MatrixTriangulator.h
		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	charles
		Date:	3/24/2006

****************************************************************************************************/

#ifndef __MatrixTriangulator__
#define __MatrixTriangulator__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "MatrixMN.h"

class TMatrixTriangulator : public TMCObject
{
public:
	TMatrixTriangulator();

	void		SetFirstElement(real64 firstElement);

	void		AddRow(TVectorN<real64>& newRow);
	void		AddColumn(TVectorN<real64>& newColumn);
	void		RemoveColumn(int32 colToDelete);
	void		RemoveLine(int32 lineToDelete);

	void		Solve(TVectorN<real64>& x,TVectorN<real64>& v1) const;


	const TMatrixMN<real64>& GetQ() const { return Q; }
	const TMatrixMN<real64>& GetR() const { return R; }
	const TMatrixMN<real64>& GetA() const { return A; }

	// checks the product of the 3 matrices is still correct
	void		CheckProduct();

protected:

	// the triangulator mains Q and R so that Q.A = R
	//
	TMatrixMN<real64>	Q;	// orthogonal matrix
	TMatrixMN<real64>	A;
	TMatrixMN<real64>	R;	// triangular superior matrix
};




#endif



