1. ## Help!! Tips on Matrix Calculator Program please!

Hi everyone, I'm enjoying all the great info on this board. Could I ask for some tips on this program I have for school? Its for Matrix Math. The program will read 4X4 matrices from the keyboard and perform operations on them. The operations are: +, -, scalar *, matrix *, and transpose. A 'Q' will quit the program.

It needs to run something like this:

-----------------------------------------------------------------------------

How many initial matrices will begiven? 2

For matrix 1:
Row 1? 2 4 0 1
Row 2? 3 0 1 2
Row 3? 1 0 1 -1
Row 4? 0 1 2 0

For matrix 2:
Row 1? 1 0 0 0
Row 2? 0 1 0 0
Row 3? 0 0 1 0
Row 4? 0 0 0 1

Operation? +

First matrix for +? 1
Second matrix for +? 2

Result is matrix 3:
Row 1: 3 4 0 1
Row 2: 3 1 1 2
Row 3: 1 0 2 -1
Row 4: 0 1 2 1

Operation? *

Scalar value for *? 2
Matrix for *? 3

Result is matrix 4:
Row 1: 6 8 0 2
Row 2: 6 2 2 4
Row 3: 2 0 4 -2
Row 4: 0 2 4 2

Operation? T

Matrix for T? 4

Result is matrix 5:
Row 1: 6 6 2 0
Row 2: 8 2 0 2
Row 3: 0 2 4 4
Row 4: 2 4 -2 2

Operation? X

First matrix for X? 1
Second matrix for X? 3

Result is matrix 6:
Row 1: 18 13 6 11
Row 2: 10 14 6 4
Row 3: 4 3 0 -1
Row 4: 5 1 5 0

Operation? Q
---------------------------------------------------------------------

Any help is appreciated!

2. Well, your matrices can be represented by 4X4 arrays.. The math part's just a matter of figuring out how to add, multiply, etc. arrays... Whaddya got so far?

3. I think I'm supposed to use a 3D array instead of a bunch of 2ds, is that good?

4. I can't think of any reason you'd want to use 3d arrays...

5. What I'm thinking is I might need to use a 3D because the number of matrices is a variable, entered by user. It could be two, it could be twenty.

6. bis-ump!!

7. This has been asked mant times before.

8. Ok, so how do I make it do this:

For matrix 1:
Row 1? 2 4 0 1
Row 2? 3 0 1 2
Row 3? 1 0 1 -1
Row 4? 0 1 2 0

For matrix 2:
Row 1? 1 0 0 0
Row 2? 0 1 0 0
Row 3? 0 0 1 0
Row 4? 0 0 0 1

Where the space makes it go to a new column??
I don't know how to input a row at a time.

9. ## Hmm....

I wouldn't use 2d or 3d arrays.

Make a matrix class then have an array of class objects or use a linked list of classes....

10. ## I think Donk has the best idea

Unless you are using c or pascal or sth, neither of which allows that. In that case, perhaps you should try a dynamic array of 2d arrays.

11. The thing is, we haven't learned classes yet so I don't think that would be a good idea. I'm pretty sure we're supposed to use a 3D array. So how can I input a row at a time?

12. Easily

cout << "Enter row " << row << "->";
cin >> var1;
cin >> var2;
cin >> var3;
cin >> var4;

This will work provided they seperate each element by spaces. Of course you'll probably want to use some loops, and put the 'var's in an array or something, as this isn't expandable.

13. Thanks