Equation Solution  
    High Performance by Design
Navigation Tree  
Home  
'- - Programming Tools
'- - Parallel Computing
|     '- - LAIPE
|     |     '- - Benchmark
|     |     '- - Java LAIPE
|     |           '- - Example
|     '- - LAIPE2
|     '- - neuLoop
|     '- - MTASK
'- - Blog
'- - In-Situ Evaluation
'- - Numerical Analysis
'- - Structural Mechanics
|     '- - IFAS
|     '- - mCable
'- - Write Us
|     '- - Feedback  
|     '- - Info  
|     '- - Support  
|     '- - Webmaster  
'- - Privacy Policy
 



Java Example


        This example applies a parallel band solver of LAIPE to solve a sparse symmetrtic system [A]{X}={B}. The class "csp" in package com.equation.laipe is applied. Parallel method "decompose_CSP_4" decomposes the matrix [A], and returns the result in the same space. Parallel method "substitute_CSP_4" performs backward and forward substitutions. Java example is as follows:


import com.equation.laipe.*;


public class example1
{
/*
;  entry point
*/
   public static void main(String args[])
   {
      new example1();
      return;
   }

/*
; example that applies parallel band solver
*/
   public example1()
  {
   /*
   ; variables
   */
      float[] a = null;
      int n = 0;
      int m = 0;
      int offsetA;
      int offsetX;
      int cpus;
      boolean noGood;

   /*
   ; order of system equation
   */
      n = 10000; // assumed

   /*
   ; half bandwidth
   */
      m = 600; // assumed

   /*
   ; memory distribution
   */
      offsetA = -1;
      offsetX = offsetA+(n-1)*m+n;

   /*
   ; allocate memory space
   */
      a = new float[offsetX+n+2];

   /*
   ; prepare the left side matrix
   */
      // assumed the left side matrix starts
      // at offset offsetA in array a

   /*
   ; prepare the right side vector
   */
      // assumed the right side vector starts
      // at offset offsetX in array a

   /*
   ; number of CPUs to run LAIPE solver
   */
      cpus = 4; // assumed.

      // set number of CPUs for solver
      laipe.setTasks(cpus);

   /*
   ; apply parallel band solver of LAIPE
   */
      csp csp = new csp();

   /*
   ; decompose in parallel
   */
      noGood = csp.decompose_CSP_4(a,offsetA,n,m);

   /*
   ; stop if the system is not positive definite
   */
      if(noGood)
      {
         System.out.println("Not positive definite system."
         System.exit(0);
      }

   /*
   ; substitute in parallel
   */
      csp.substitute_CSP_4(a,offsetA,n,m,a,offsetX);

   /*
   ; output result
   */
      // statement to output result


      return;
      }
}