/*
*   Class   ComplexMatrix
*
*   Defines a complex matrix and includes the methods
*   needed for standard matrix manipulations, e.g. multiplation,
*   and related procedures, e.g. solution of complex linear
*   simultaneous equations
*
*   See class PhasorMatrix for phasor matrix manipulation
*   See class Complex for standard complex arithmetic
*
* 	WRITTEN BY: Dr Michael Thomas Flanagan
*
*   DATE:	    June 2002
*   UPDATES:    16 February 2006, 7 March 2006, 31 March 2006, 22 April 2006, 1 July 2007, 9 April 2008
*               18 October 2008, 16 June 2009, November 2009, 12 January 2010, 14 November 2010, 15-16 July 2011
*
*
*   DOCUMENTATION:
*   See Michael Thomas Flanagan's Java library on-line web pages:
*   http://www.ee.ucl.ac.uk/~mflanaga/java/ComplexMatrix.html
*   http://www.ee.ucl.ac.uk/~mflanaga/java/
*
*   Copyright (c) 2002 - 2010 Michael Thomas Flanagan

*
*   PERMISSION TO COPY:
*   Permission to use, copy and modify this software and its documentation for
*   NON-COMMERCIAL purposes is granted, without fee, provided that an acknowledgement
*   to the author, Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies.
*
*   Dr Michael Thomas Flanagan makes no representations about the suitability
*   or fitness of the software for any or for a particular purpose.
*   Michael Thomas Flanagan shall not be liable for any damages suffered
*   as a result of using, modifying or distributing this software or its derivatives.
*
***************************************************************************************/

package flanagan.complex;

import flanagan.math.*;

public class ComplexMatrix{

	    private int nrow = 0;               // number of rows
	    private int ncol = 0;               // number of columns
	    private Complex matrix[][] = null;  // 2-D Complex Matrix
	    private int index[] = null;         // row permutation index
	    private double dswap = 1.0D;        // row swap index
	    private static final double TINY = 1.0e-30;

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

	    // CONSTRUCTORS
	    // Construct a nrow x ncol matrix of complex variables all equal to zero
    	public ComplexMatrix(int nrow, int ncol){
		    this.nrow = nrow;
		    this.ncol = ncol;
	    	this.matrix = Complex.twoDarray(nrow, ncol);
		    this.index = new int[nrow];
        	for(int i=0;i=this.nrow)throw new IllegalArgumentException("Sub-matrix position is outside the row bounds of this Matrix");
        	if(j+l-1>=this.ncol)throw new IllegalArgumentException("Sub-matrix position is outside the column bounds of this Matrix");

        	int m = 0;
        	int n = 0;
        	for(int p=0; pk)throw new IllegalArgumentException("row indices inverted");
        	if(j>l)throw new IllegalArgumentException("column indices inverted");
        	if(k>=this.nrow)throw new IllegalArgumentException("Sub-matrix position is outside the row bounds of this Matrix" );
        	if(l>=this.ncol)throw new IllegalArgumentException("Sub-matrix position is outside the column bounds of this Matrix" + i + " " +l);

        	int n=k-i+1, m=l-j+1;
        	ComplexMatrix subMatrix = new ComplexMatrix(n, m);
        	Complex[][] sarray = subMatrix.getArrayReference();
        	for(int p=0; p=this.nrow)throw new IllegalArgumentException("The entered row index, " + ii + " must lie between 0 and " + (this.nrow-1) + " inclusive");
    	    if(jj<0 || jj>=this.ncol)throw new IllegalArgumentException("The entered column index, " + jj + " must lie between 0 and " + (this.ncol-1) + " inclusive");

    	    int[] rowi = new int[this.nrow - 1];
    	    int[] colj = new int[this.ncol - 1];
    	    int kk = 0;
    	    for(int i=0; i=this.ncol)testOuter = false;
                }
                rowPointer++;
                if(rowPointer>=this.nrow || !testInner)testOuter = false;
            }

            for(int i=0; i big) big=temp;
			    }
        		if (big == 0.0) throw new ArithmeticException("Singular matrix");
    			vv[i]=1.0/big;
	    	}
	    	for (int j=0;j= big) {
				        big=dum;
				        imax=i;
			    	}
		        }
		    	if (j != imax) {
			        for (int k=0;k=0;i--) {
		    	sum=Complex.copy(xvec[i]);
		    	for (int j=i+1;j 

Ads help maintain this website.