pseudo code to c++ matrix row reduction

This is a discussion on pseudo code to c++ matrix row reduction within the C++ Programming forums, part of the General Programming Boards category; I need help with converting this to c++ Input the n x n matrix A and n element vector b ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    8

    pseudo code to c++ matrix row reduction

    I need help with converting this to c++

    Input the n x n matrix A and n element vector b
    for k = 1 to n
    for i = k + 1 to n
    lik aik=akk
    for j = k + 1 to n
    aij to aij - likakj
    end for
    end for
    end for

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    2,021
    What exactly is your trouble with it?

    And what's l in the psudo code?
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    8
    IDK, the professor for my linear algebra class decided to give us this code to see if we could convert it to c++

    this is what I came up with..
    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        int i;
        int m;
        int n; 
       
        cout<<"Input Matrix Size: ";
        cin>>i;
        
        cout<<"Input number of rows: ";
        cin>>m;
        
        cout<<"Input number of columns: ";
        cin>>n;
        
        for(m=1; n-1)
           cout<<b(m)-0
           
           for(n-1; N-1)
              cout<<a(m,n)=0
              end;
              
             for(a(m,m+1)
                cout<<-1 
                
                for(a(m,m)
                cout<<=2
                
                for(a(m+1,)
                cout<<=-1
                end;
                
               
                
                system("pause");
                return 0; 
                }

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    2,021
    Using a compiler and a C++ book on hand might help. There are too many errors in that to make it worth the time of anyone here to itemize, particularly since you are liable to make more errors correcting.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,295
    Quote Originally Posted by eholbro1 View Post
    IDK, the professor for my linear algebra class decided to give us this code to see if we could convert it to c++

    this is what I came up with..
    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        int i;
        int m;
        int n; 
       
        cout<<"Input Matrix Size: ";
        cin>>i;
        
        cout<<"Input number of rows: ";
        cin>>m;
        
        cout<<"Input number of columns: ";
        cin>>n;
        
        for(m=1; n-1)
           cout<<b(m)-0
           
           for(n-1; N-1)
              cout<<a(m,n)=0
              end;
              
             for(a(m,m+1)
                cout<<-1 
                
                for(a(m,m)
                cout<<=2
                
                for(a(m+1,)
                cout<<=-1
                end;
                
               
                
                system("pause");
                return 0; 
                }
    In all fairness the bit prior to the first for loop isn't too bad, but the rest of it may as well be "Mary had a little lamb" as far as a compiler is concerned.

    You can't use this forum to get you there, you need another source to learn from first. So many people don't seem to get that there is no shortcut in learning to program. "Do or do not; there is no try".
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 01:30 PM
  2. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 04:57 PM
  3. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  4. Trying to make this code faster & Cramer
    By just2peachy in forum C++ Programming
    Replies: 3
    Last Post: 12-03-2004, 09:54 AM
  5. What is a matrix's purpose in OpenGL
    By jimboob in forum Game Programming
    Replies: 5
    Last Post: 11-13-2004, 11:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21