C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-07-2009, 07:15 PM   #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
eholbro1 is offline   Reply With Quote
Old 11-07-2009, 07:22 PM   #2
Registered User
 
Join Date: Apr 2006
Posts: 1,193
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.
King Mir is offline   Reply With Quote
Old 11-07-2009, 07:27 PM   #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; 
            }
eholbro1 is offline   Reply With Quote
Old 11-07-2009, 07:49 PM   #4
Registered User
 
Join Date: Apr 2006
Posts: 1,193
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.
King Mir is offline   Reply With Quote
Old 11-08-2009, 02:10 AM   #5
Algorithm Dissector
 
iMalc's Avatar
 
Join Date: Dec 2005
Location: New Zealand
Posts: 2,476
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
iMalc is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C - access violation uber C Programming 2 07-08-2009 01:30 PM
Matrix Help HelpmeMark C++ Programming 27 03-06-2008 05:57 PM
matrix class shuo C++ Programming 2 07-13-2007 01:03 AM
Trying to make this code faster & Cramer just2peachy C++ Programming 3 12-03-2004 10:54 AM
What is a matrix's purpose in OpenGL jimboob Game Programming 5 11-14-2004 12:19 AM


All times are GMT -6. The time now is 03:45 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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