/* ## class FPoFull ## ## 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.FMatrix; import edu.rice.linpack.util.*; import edu.rice.linpack.Vector.*; import edu.rice.linpack.LNumber.*; public class FPoFull extends FFull { public FPoFull() { super(); } public FPoFull(int n, int q) { super(n, q); } public FPoFull(float[][] f) { super(f); } public FPoFull(FPoFull F) { super(F); } public FPoPack pack() { FPoPack P = new FPoPack(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 float[] getRow(int i) { return getRow(i,0); } public float[] getColumn(int i) { return getRow(i,0); } public float[] getColumn(int i, int j) { return getRow(i,j); } public float[] getRow(int i, int j) { float[] F = new float[rows - j]; for(int k=0;k c) super.setElem(c,i,L); else super.setElem(i,c,L); } protected float oneNorm() { float[] Z = new float[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; FUtil.swapElems(pivot, k, maxln); } W[k] = (float)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])) { float S = Math.abs(this.Mat[k][k])/Math.abs(Z[k]); FUtil.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); } float S = (float)1.0/FUtil.asum(cols,Z,1); FUtil.scal(cols,S,Z,1); } private float solveTransRV (float[] Z) { float ynorm = 1; for(int k=0;k this.Mat[k][k]) { float S = this.Mat[k][k]/Math.abs(Z[k]); FUtil.scal(cols,S,Z,1); ynorm *= S; } Z[k] = Z[k]/this.Mat[k][k]; } float S = 1/FUtil.asum(cols,Z,1); FUtil.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 { float[] B = Be.getFloatArray(); // Solve Trans(R)*Y = B // this.solveTransAX(B); // Solve R*X = Y // this.solveUX(B); return; } public Vector determ() { float[] Det = new float[2]; Det[0] = 1; Det[1] = 0; for(int i=0;i