Results 1 to 5 of 5

Thread: Gauss program

  1. #1
    Ratheo is offline Member
    Join Date
    May 2014
    Posts
    2
    Rep Power
    0

    Default Gauss program

    Hello.
    I have a big problem with writing Gauss Elimination in Java code. This is my homework, it's true. But I want to learn this, and I don't know how to bite this. I will be very gratefull if you give me some advices or hints. I must realise some points:
    1) Create new class - Gauss Elimination with two attributes (table A (nxn) and table B with vector (n));
    2) Add new method "eliminate" which transform matrix A and parametr vectors B ;
    3) Add new method "solve" which calculate inverse substitution.

    Thanks for all :)

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default Re: Gauss program

    What have you tried?

    What specific questions do you have?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Ratheo is offline Member
    Join Date
    May 2014
    Posts
    2
    Rep Power
    0

    Default Re: Gauss program

    This is my beginning :)
    Java Code:
    public class GaussElimination
    {
      
       	 double[][] A;         
       	 double[]   b;		
       
       	 public void eliminate(double[][] A, double[] b) 
       	 {
    </code>
    
    I have tried this code: 
    <code>
     public void GaussianElim(double[][] A, double[] b) 
       	 {
    		
    			for (i = 0; i < n; i++)
    		   	 {  // Process row i
    		    
    		   	    /* ---------------------
    		   	       (A) Select pivot
    		   	       --------------------- */
    		   	    pivot = A[i][i];
    		    
    		   	    /* ---------------------
    		   	       (B) Normalize row i
    		   	       --------------------- */
    		   	    for (j = 0; j < n; j++)
    		   	       A[i][j] = A[i][j]/pivot;
    		    
    		   	    b[i] = b[i]/pivot;
    		    
    		   	    /* ---------------------
    		   	       (C) Sweep using row i
    		   	       --------------------- */
    		   	    for (k = 0; k < n; k++)
    		   	    {
    		   	       if ( k != i )
    		   	       {
    		   		  factor = A[k][i];
    		    
    		   		  for (j = 0; j < n; j++)
    		   		     A[k][j] = A[k][j] - factor*A[i][j];
    		    
    		   		  b[k] = b[k] - factor*b[i];
    	
    		} <
    >
    But I don't understand this loops. Where can I start? I don't understand these methods :(
    Last edited by Norm; 05-03-2014 at 02:42 PM. Reason: < > changed to [ ] around code tags

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default Re: Gauss program

    I don't understand this loops
    Look at the tutorial for a descritpion of how a for loop works:
    The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)

    I don't know anything about Gauss, it is not a part of java. Java is a programming language that can be used to solve lots of different problems.
    If you have any specific questions about java programming, post them.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,762
    Blog Entries
    7
    Rep Power
    21

    Default Re: Gauss program

    Note that Gaussian elimination (and Gauss/Jordan elimination) is more complicated if the pivot element (the element on the diagonal of the matrix) is zero. You need to permute the rows (or columns) to get a non-zero element in that position.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 6
    Last Post: 12-15-2013, 07:40 AM
  2. ILL CONDITION MATRICES and gauss jordan elimination
    By manunited in forum New To Java
    Replies: 1
    Last Post: 09-28-2013, 05:35 PM
  3. Replies: 4
    Last Post: 11-21-2012, 02:19 PM
  4. Replies: 2
    Last Post: 04-02-2011, 01:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •