Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey jadbenautho

i really need your help man.
i am in my first year or computer science and we are using c++ and it is unfamiliar territory for me. I was hoping you could help me out. this is the prompt:

create a simple matrix calculator. The calculator will be able to:
read in matrices (from a file) perform operations on those matrices (as specified in the file) display the results and write the results to a file The operations we will be performing include:
matrix addition matrix multiplication calculating the determinant of a matrix calculating the transpose of a matrix For more information about matrix operations search for "matrix operations" in your favorite search engine. One site we found did have lots of good information http://www.miislita.com/information-retrieval-tutorial/matrix-tutorial-2-matrix-operations.html

Input File
A file will be organized as follows
#matrices specified in the file
first_matrix_#rows first_matrix_#columns
first_matrix
second_matrix_#rows second_matrix_#columns
second_matrix
.
.
.
operations_until_eof
so the following would be an example of the file
4
2 3
1 2 3
4 5 6
3 4
4 5 7 23
34 65 12 86
-1 38 -54 21
2 2
-1 5
-83 195
2 3
65 -4 123
54 12 -76
1+4
4*2
2T
3D
3I

Assumptions and Tips
Let's say that matrices will be smaller than 25 rows and 25 columns and that you will have less than 25 of them in a single input file For the operations, there will be no spaces between matrices and operations For the operations, the numbering of matrices will start with 1 Use functions as much as you can to
break down problems into smaller pieces allow for easier debugging
Posted

1 solution

What you need to do is break the whole problem you have here in to smaller more manageable problems.

There are two main portions to your particular assignment which are the matrix calculations on arbitrarily sized matrices and parsing the input file. There is then the third much simpler task of writing your results to another file.

So, parsing the input file can be broken down into a few much simpler problems again that you should be able to figure out by some light searching.

1. Open a file
2. Read lines from the file
3. parse each line to get the data you need
  3a. Line 1, Change string into int to get number of matrices in file
  3b. Line 2, split the string into two so you have a separate string for each number, then convert each string into an int to find out the size of the matrix
  3c. Parse Y lines and split into X number of ints to get the matrix data
Etc. 


I think you get the idea there. Reading and writing from files is fairly easy to do so you shouldn't have much trouble finding information on that and you should be able to find numerous articles on working with n*n matrices, it might be worth trying to search for C++ articles on the subject so you don't get to bogged down with all the fancy symbols that mathematicians like to use (They get me confused anyway).

As this is an assignment we can't simply give you the solution but if you have any specific problems or bugs that you can't work out you can always post another question about it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900