1. Member Join Date
May 2014
Posts
2
Rep Power
0

## 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 :)  Reply With Quote

2. ## Re: Gauss program

What have you tried?

What specific questions do you have?  Reply With Quote

3. Member Join Date
May 2014
Posts
2
Rep Power
0

## 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 01:42 PM. Reason: < > changed to [ ] around code tags  Reply With Quote

4. ## 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.  Reply With Quote

5. ## 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  Reply With Quote

#### Posting Permissions

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