Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

Gauss Elimination HELP! :)

Greenhorn
Posts: 12
Good Day

I found a code online in the internet, I just want to have an explanation of the parts of the code because I cannot understand its intended use. Can you help me out? Thanks.

I don't have an idea on how the equations are solve, so can you please?

I don't have problem understanding the INPUT part, but on the EQUATEOUT part, i do not understand most of the coding and how they come up with the answer. HELP!

Marshal
Posts: 4350
280
• 1
You must have some idea of what it's supposed to do right? After all, you were the one who found it on the internet. What were you looking for? What do you think it does? What were you hoping it does?

Just presenting a seemingly random block of code with a "What does this do" tagline is probably not going to get the responses you were hoping for. Please ShowSomeEffort (<-- click)

Greenhorn
Posts: 12
Actually I know how it works.

This part finds the pivot row, I guess it with the absolutes thing.

But don't understand this part sir.

Bartender
Posts: 3648
16

But don't understand this part sir.

Looking at the code, it's doing a swap. Let me use a simpler example: Given a=5 and b=10, how to swap these variables to a=10 and b=5 "without" losing the original value? The key here without losing original value. I can always just do:

But that will have lost my original value. Therefore, I need a temp value to store the original value.

Voila. The code in your Internet code is doing the thing only the variable coef is a multi-dimensional array.

Greenhorn
Posts: 12
Thanks for the wonderful reply sir!

Just like the comment I wrote, I know it is for pivoting, but can you give me another concrete example of what happens in this part of code?

Thanks sir!

Sheriff
Posts: 3752
62
This is one of the most basic constructs in Java. It 's going to be really hard to get an understanding of an algorithm without firstly understanding the language it is written in.

You might have a look at the for loop description in the tutorial. I'd say that you actually should read the entire Language Basic tutorial first before you go further on the algorithm.

Do you have any prior experience with programming? If not, I'd suggest starting with simpler algorithms than Gaussian elimination.

Greenhorn
Posts: 12
I understand the algorithm sir.

I just don't understand the Gaussian elimination applied in the codes. Im sorry sir for the inconvinience.

Martin Vajsar
Sheriff
Posts: 3752
62
No need to be sorry. We'd like to help, but we'd also like to understand what do you really need help with.

Do you have any experience in Java? Or any experience with programming in general?

If you do, it should be quite straightforward to understand what is happening in these for loops, especially if you're already familiar with the algorithm. I've therefore assumed that Java and perhaps programming in general is new to you. I honestly don't know what is the best way to start programming, but from my own experience, the best way to start with Java is the tutorial I've posted a link to. Java has the best and most extensive online documentations and tutorials of all languages I've met so far.

I might start explaining you the for loop, but it has been already done, and by folks that have spent more time over it that I could right now. This is why I gave you this link. If you go there, read the page, and still cannot understand what the for loop does, please come back and tell us what is unclear.