Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 26th, 2005, 6:37 AM   #1
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 5 TecBrain is on a distinguished road
problem with reading my matrices

I am trying to write a program that will do the followings:
Addition of two matrices
Subtraction of two matrices
Multiplication of two matrices
Inverse of a matrix

Up too now I have defined my class but I have some problem with reading my matrices, I would appreciate your help, I can’t understand exactly what am I doing or what am I suppose to do:

Please let me know if I am on the right path:

#include <iostream>
#include <stdlib.h>

using namespace std;

//---------------------------------------------------------------//

class matrix{
    public:
        matrix();
        void readmatrix();
        void printmatrix();
        bool addsub(char c, const matrix &A, const matrix &B);
        
    private:
        void identity();
        int row, col;
        float entryA[maxrow][maxcol];
        float entryB[maxrow][maxcol];
        float answer[maxrow][maxcol];
    };
    
//------------------------------------------------------//
    

void matrix::readmatrix()



cout << "Enter number of rows for Matrix A:" <<endl;
cin >> rowa;
cout << "Enter number of col for Matrix A:" <<endl; 
cin >> cola;
cout << "Enter the elements of Matrix A:" <<endl; 

for (i=0;i<rowa;i++)
    {
    for (j=0;j<cola;j++)
        {
        cin >> entryA[row][col];
        }
    }            
    
cout << "Enter number of rows for Matrix B:" <<endl;
cin >> rowb;
cout << "Enter number of col for Matrix B:" <<endl; 
cin >> colb;
cout << "Enter the elements of Matrix B:" <<endl; 

for (i=0;i<rowb;i++)
    {
    for (j=0;j<colb;j++)
        {
        cin >> entryB[row][col];
        }
    }    

//----------------------------------------------------//

Also do I need to define all these arrays?since I am having two D Arrays.
        float entryA[maxrow][maxcol];
        float entryB[maxrow][maxcol];
        float answer[maxrow][maxcol];

Thanks
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.

Last edited by TecBrain; Feb 26th, 2005 at 3:51 PM. Reason: Progress//
TecBrain is offline   Reply With Quote
Old Feb 26th, 2005, 4:03 PM   #2
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 5 TecBrain is on a distinguished road
Is it possible to change the title name?
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:45 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC