PUBS: A Practical Upper Bounds Solver

/*

This Program is taken from the following site (without permission) solely for the experimentation of cost analysis of practial java programs

http://www.physics.unlv.edu/~pang/cp2_j.html

*/
///////////////////////////////////////////////////////////////////////////
//                                                                       //
// Program file name: Inverse.java                                       //
//                                                                       //
//  Tao Pang 2006                                                       //
//                                                                       //
// Last modified: January 18, 2006                                       //
//                                                                       //
// (1) This Java program is part of the book, "An Introduction to        //
//     Computational Physics, 2nd Edition," written by Tao Pang and      //
//     published by Cambridge University Press on January 19, 2006.      //
//                                                                       //
// (2) No warranties, express or implied, are made for this program.     //
//                                                                       //
///////////////////////////////////////////////////////////////////////////

// An example of performing matrix inversion through the
// partial-pivoting Gaussian elimination.

import java.lang.*;
public class Inverse {
  public static void main(String argv[]) {
    double a[][]= {{ 100,  100,  100},
                   {-100,  300, -100},
                   {-100, -100,  300}};
    int n = a.length;
    double d[][] = invert(a);
    for (int i=0; i=0; --j) {
        x[j][i] = b[index[j]][i];
        for (int k=j+1; k c1) c1 = c0;
      }
      c[i] = c1;
    }

 // Search the pivoting element from each column
    int k = 0;
    for (int j=0; j pi1) {
          pi1 = pi0;
          k = i;
        }
      }

   // Interchange rows according to the pivoting order
      int itmp = index[j];
      index[j] = index[k];
      index[k] = itmp;
      for (int i=j+1; i