Gauss Jordan function????

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaygee
    New Member
    • Feb 2007
    • 12

    Gauss Jordan function????

    I need help with writing an inverse() function....any one got a clue?
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by kaygee
    I need help with writing an inverse() function....any one got a clue?
    I take it you're writing a function to calculate the mathematical inverse. If you posted the formula for that, we could help you create an algorithm for programming it.

    Comment

    • cyberking
      New Member
      • Jan 2007
      • 84

      #3
      Hi.
      If its a mathematical inverse u are tryin, then this would be the code of the function..

      int inverse(number_ from_main)
      {
      int inverse; // can also be float
      inverse = 1 / number_from_mai n ;
      return inverse;
      }

      Comment

      • kaygee
        New Member
        • Feb 2007
        • 12

        #4
        Originally posted by cyberking
        Hi.
        If its a mathematical inverse u are tryin, then this would be the code of the function..

        int inverse(number_ from_main)
        {
        int inverse; // can also be float
        inverse = 1 / number_from_mai n ;
        return inverse;
        }
        5 Description of the Algorithm
        Algorithm 5.1: Gauss-Jordan Method (B 2 <n×n)
        comment: Create an Augmented Matrix
        A = [B I]
        for i = 1 to n
        8>
        >>>>>>>>>>>>>>> >>>>>>>>>>>><>> >>>>>>>>>>>>>>> >>>>>>>>>>>:
        comment: Find the pivot
        pivot aii
        if pivot < 10−8
        then
        8>
        >><>>>:
        Matrix is singular
        det 0
        Return
        comment: Perform Row Elimination
        comment: Normalise the row by dividing each element by the pivot
        for j = 1 to 2n
        aij = aij/pivot
        for k = 1 to n
        8>
        >>>>>><>>>>>> >:
        if k 6= i
        then
        8>
        >><>>>:
        m aki
        for j = 1 to 2n
        akj = akj − m × aij
        for i = 1 to n
        8>
        <>
        :
        for j = 1 to n
        B−1[i, j] = A[i, j + n]
        output (B−1)

        Comment

        • sicarie
          Recognized Expert Specialist
          • Nov 2006
          • 4677

          #5
          Kaygee-

          You were given an algorithm, one that will translate very easily into computer code. Is there a part you are getting stuck on? What do you not understand?

          Comment

          Working...