/* ## class NPoFull ## ## This class holds the routines for positive definite matrices in full ## form. It also holds the Cholesky routines for decomposing. ## */ package edu.rice.linpack.Matrix.NMatrix; import edu.rice.linpack.util.*; import edu.rice.linpack.LNumber.*; public class NPoFull extends NFull { public NPoFull() { super(); } public NPoFull(int n, int q) { super(n, q); } public NPoFull(LNumber[][] f) { super(f); } public NPoFull(NPoFull F) { super(F); } public NPoPack pack() { NPoPack P = new NPoPack(Mat); return P; } public void transpose() { } public LNumber getElem(int i, int j) { if(i > j) return super.getElem(j,i); return super.getElem(i,j); } public LNumber[] getRow(int i) { return getRow(i,0); } public LNumber[] getColumn(int i) { return getRow(i,0); } public LNumber[] getColumn(int i, int j) { return getRow(i,j); } public LNumber[] getRow(int i, int j) { LNumber[] F = new LNumber[rows - j]; for(int k=0;k c) super.setElem(c,i,L); else super.setElem(i,c,L); } protected LNumber oneNorm() { LNumber[] Z = new LNumber[cols]; for(int j=0;j= P.pl) && (k < P.pu)) { for(int q=kp;q<=P.pu;q++) { if(Mat[q][q].greaterThan(maxdia)) { maxdia = this.Mat[q][q]; maxln = q; } } } if(!maxdia.greaterOrEqual(0)) throw new SingularMatrixException(k+1); else { if(k != maxln) { this.swap(k,1,0,k,this,1,0,maxln); Mat[maxln][maxln] = Mat[k][k]; Mat[k][k] = maxdia; NUtil.swapElems(pivot, k, maxln); } W[k] = Mat[k][k].sqrt(); Mat[k][k] = W[k].Clone(); for(int j=kp;j=P.pl;k--) { if(pivot[k] < 0) { pivot[k] = -pivot[k]; if(P.pu != k) { this.swap(k,1,0,k,this,1,0,P.pu); this.swapElem(k,k,P.pu,P.pu); for(int j=k+1;j q) this.swapElem(k,j,q,j); } public void factor() throws SingularMatrixException { for(int j=0;j=0;k--) { if((Z[k].abs()).greaterThan(Mat[k][k].abs())) { LNumber S = (Mat[k][k].abs()).div(Z[k].abs()); NUtil.scal(cols,S,Z,1); } if(!Mat[k][k].equals(0)) Z[k].divTo(Mat[k][k]); else Z[k].setOne(); this.axpy(k,Z[k].negate(),1,0,k,Z,1,0); } LNumber S = (NUtil.asum(cols,Z,1)).invTo(); NUtil.scal(cols,S,Z,1); } private LNumber solveTransRV (LNumber[] Z) { LNumber ynorm = Z[0].Clone(); ynorm.setOne(); for(int k=0;k