/* * Class PhasorMatrix * * 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 ComplexMatrix for rectangular complex matrix manipulations * * WRITTEN BY: Dr Michael Thomas Flanagan * * DATE: July 2007 * AMENDED: 19 April 2008, 14 November 2010 * * DOCUMENTATION: * See Michael Thomas Flanagan's Java library on-line web pages: * http://www.ee.ucl.ac.uk/~mflanaga/java/PhasorMatrix.html * http://www.ee.ucl.ac.uk/~mflanaga/java/ * * Copyright (c) 2007 - 2010 * * 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.circuits; import flanagan.math.Fmath; import flanagan.math.Matrix; import flanagan.complex.Complex; import flanagan.complex.ComplexMatrix; public class PhasorMatrix{ private int nrow = 0; // number of rows private int ncol = 0; // number of columns private Phasor matrix[][] = null; // 2-D Phasor 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 PhasorMatrix(int nrow, int ncol){ this.nrow = nrow; this.ncol = ncol; this.matrix = Phasor.twoDarray(nrow, ncol); this.index = new int[nrow]; for(int i=0;ik)throw new IllegalArgumentException("row indices inverted"); if(j>l)throw new IllegalArgumentException("column indices inverted"); int n=k-i+1, m=l-j+1; for(int p=0; p=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 n=k-i+1, m=l-j+1; for(int p=0; p=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 n=k-i+1, m=l-j+1; PhasorMatrix subMatrix = new PhasorMatrix(n, m); Phasor[][] sarray = subMatrix.getArrayReference(); for(int p=0; p 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=Phasor.copy(xvec[i]); for (int j=i+1;j