/* ## class DPoFull ## ## 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.DMatrix; import edu.rice.linpack.util.*; import edu.rice.linpack.Vector.*; import edu.rice.linpack.LNumber.*; public class DPoFull extends DFull { public DPoFull() { super(); } public DPoFull(int n, int q) { super(n, q); } public DPoFull(double[][] f) { super(f); } public DPoFull(DPoFull F) { super(F); } public DPoPack pack() { DPoPack P = new DPoPack(this.Mat); return P; } public void setPivots(int[] p) { int q = Math.min(p.length,cols); for(int i=0;i j) return super.getElem(j,i); return super.getElem(i,j); } public double[] getRow(int i) { return getRow(i,0); } public double[] getColumn(int i) { return getRow(i,0); } public double[] getColumn(int i, int j) { return getRow(i,j); } public double[] getRow(int i, int j) { double[] F = new double[rows - j]; for(int k=0;k c) super.setElem(c,i,L); else super.setElem(i,c,L); } protected double oneNorm() { double[] Z = new double[cols]; for(int j=0;j= P.pl) && (k < P.pu)) { for(int q=kp;q<=P.pu;q++) { if(this.Mat[q][q] > maxdia) { maxdia = this.Mat[q][q]; maxln = q; } } } if(maxdia < 0) throw new SingularMatrixException(k+1); else { if(k != maxln) { this.swap(k,1,0,k,this,1,0,maxln); this.Mat[maxln][maxln] = this.Mat[k][k]; this.Mat[k][k] = maxdia; DUtil.swapElems(pivot, k, maxln); } W[k] = Math.sqrt(this.Mat[k][k]); this.Mat[k][k] = W[k]; 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(Math.abs(Z[k]) > Math.abs(this.Mat[k][k])) { double S = Math.abs(this.Mat[k][k])/Math.abs(Z[k]); DUtil.scal(cols,S,Z,1); } if(this.Mat[k][k] != 0) Z[k] = Z[k]/this.Mat[k][k]; else Z[k] = 1; this.axpy(k,-Z[k],1,0,k,Z,1,0); } double S = 1.0/DUtil.asum(cols,Z,1); DUtil.scal(cols,S,Z,1); } private double solveTransRV (double[] Z) { double ynorm = 1; for(int k=0;k this.Mat[k][k]) { double S = this.Mat[k][k]/Math.abs(Z[k]); DUtil.scal(cols,S,Z,1); ynorm *= S; } Z[k] = Z[k]/this.Mat[k][k]; } double S = 1/DUtil.asum(cols,Z,1); DUtil.scal(cols,S,Z,1); ynorm *= S; return ynorm; } public void solve(Vector B, int Job) throws WrongDataTypeException { this.solve(B); } public void solve(Vector Be) throws WrongDataTypeException { double[] B = Be.getDoubleArray(); // Solve Trans(R)*Y = B // this.solveTransAX(B); // Solve R*X = Y // this.solveUX(B); return; } public Vector determ() { double[] Det = new double[2]; Det[0] = 1; Det[1] = 0; for(int i=0;i