Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: need help solving Gaussian method for inverse

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need help solving Gaussian method for inverse

    i got some code but its not working or compiling. i need to use this code to find inverse of any size matrix. specific help would be appreciated. here is my code:

    public static double[][] GaussianEliminverse(double[][] A,int B)
    {
    double[][] b = new double[B][B];
    for (int row = 0; row < B; row++) {
    for (int col = 0; col < B; col++) {
    if (row == col) {
    b[row][col] = 1;
    } else {
    b[row][col] = 0;
    }
    }
    }

    double pivot, factor;
    int i;
    int j;
    int k;

    int n = b.length;

    for (i = 0; i < n; i++) {
    pivot = A[i][i];

    for (j = 0; j < n; j++)
    A[i][j] = A[i][j] / pivot;

    b[i][j] = b[i][j] / pivot;

    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][j] = b[k][j] - factor * b[i][j];
    }
    }
    }
    for (int row = 0; row < b.length; row++) {
    for (int col = 0; col < b[row].length; col++) {
    System.out.print(b[row][col] + " ");
    }
    System.out.println();
    }
    return (b);
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: need help solving Gaussian method for inverse

    Please keep this discussion in your other thread:
    http://www.javaprogrammingforums.com...-matrices.html
    I am locking this thread.

Similar Threads

  1. Thank you for solving the mystery!!
    By Maxi in forum Member Introductions
    Replies: 1
    Last Post: September 19th, 2012, 07:41 PM
  2. Help with solving Maze
    By tcao2 in forum Algorithms & Recursion
    Replies: 9
    Last Post: May 5th, 2012, 08:58 PM
  3. Solving a polynomial
    By arvindbis in forum Java Theory & Questions
    Replies: 9
    Last Post: March 8th, 2012, 12:16 AM
  4. help please with code for inverse radon transform
    By sc3105 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 29th, 2011, 11:17 PM
  5. Inverse of a Matrix problem
    By shivamchauhan in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 17th, 2011, 01:40 PM