Author 
Topic 
Fordia 
Posted  2008.07.28 14:55:00  [ 1]
Edited by: Fordia on 30/07/2008 11:48:32Ok since my last post http://myeve.eveonline.com/ingameboard.asp?a=topic&threadID=824409, ive been doing abit more C++ in my spare time. I'm now onto find the determinant of square matrices from 2 to 9 i.e. 2x2, 3x3.....9x9, and straight away i'm all "waaaaa? im confused...." Woti want the program to do is ask me for a number, n, where n ranges from 2 up to and including 9, and then once ive given the number it finds the determinant of said matrix and shows it on screen. Im using Visual C++ 2008 Express Edition (the free 1 off MS's website). So if any1 cud help me that wud b great links, code, anything will do. 
Cal5 Federal Defence Union

Posted  2008.07.28 15:10:00  [ 2]
Not sure how exactly you would go about doing this. However, it does sound like a job for 'arrays'. You would want to create 2x 2D arrays which would then be equivilant to (in this context) a matrice.
Try doing some reading up on arrays and see if that helps you in the right direction.
Good Luck! 
Mazzarins Demise Profit Development and Research Association

Posted  2008.07.28 16:04:00  [ 3]
Make a while loop.
And that's all I retained from my programming class. 
Minessis Aliastra

Posted  2008.07.28 16:11:00  [ 4]
I know very little C++, but way way too much mathematics. So, perhaps there is a function already in a C library that you could implement, i.e. maybe in the .Math library, probably called "determinant".
And if there isn't then I you definitely could write your own script that actually calculates the determinant. You of course need to know how to compute that... http://en.wikipedia.org/wiki/Determinant the method to use is essentially an iteration of solving for 2x2 determinants implementing some rules telling which cols and rows to use for the 2x2 matrices and whether or not to multiply each submatrix by a factor of 1 or 1.
It's pretty straight forward.
Now as to what the input number "n" represents in your program: If "n" is just the number of cols and rows in your matrix and say you input "4" meaning a 4 row 4 col matrix, then I am going to assume that you have already input a 4x4 matrix into your program somewhere else, correct? Because, if you haven't you will need to obviously do so, or have the program randomly generate one.
Goodluck

Isiskhan Gnostic Misanthropy

Posted  2008.07.28 16:29:00  [ 5]
I'll be happy to help if you have a specific problem as in your previous thread, but this reeks of "Please do my homework, I'm too f*cking lazy to work it out myself". 
Jim McGregor 
Posted  2008.07.28 17:44:00  [ 6]
Edited by: Jim McGregor on 28/07/2008 17:45:06
1. Write algorithm for what the program needs to do exactly. 2. Write code.
Easy. And Im not going to do your homework for you either.

Fordia 
Posted  2008.07.28 17:54:00  [ 7]
Its not homework i can assure you that. I finished school a looong time ago. Im jus learning C++ merely as a hobby at the moment, but i hope to put my skills to practical use in the future....if and when i get them. I do want to learn it myself, im jus merely asking for a little guidance. Again, a nudge in the right direction will be so much appreciated. 
Jim McGregor 
Posted  2008.07.28 17:58:00  [ 8]
Edited by: Jim McGregor on 28/07/2008 17:58:43 Originally by: Fordia
I do want to learn it myself, im jus merely asking for a little guidance. Again, a nudge in the right direction will be so much appreciated.
Well, then ask a specific question where you are getting stuck instead of asking for the complete solution. Do you even have a algorithm? You need to plan the program before you code. That step doesnt even require programming skills. 
Dantes Revenge Caldari 
Posted  2008.07.28 18:16:00  [ 9]
Flowcharts are your friend. If you don't know how to flowchart, write a list of step by step instructions in plain text required to perform the task, as if you were explaining to a child how to do it. Then determine what commands are required to turn plain text into program code. As for matrices, work in dimensions with the relevant number of coordinates to find a data storage location: 1 dimension is a list of locations. n(w) 2 dimensions is a grid of locations. n(w,x) 3 dimensions in a cube of locations. n(w,x,y) 4 dimensions is a list of cubes of locations. n(w,x,y,z) and so on. If you've managed to flummox yourself this far into it, classes and types are not going to be easy 
Fordia 
Posted  2008.07.28 19:10:00  [ 10]
Ok i understand that to create a matrix i use an array. I understand how to create the array, what i am stuck on though is finding the determinant of an array. So your specific question Jim McGregor is this: "How do i find the determinant of a matrix?". 
Chainsaw Plankton IDLE GUNS IDLE EMPIRE 
Posted  2008.07.28 20:18:00  [ 11]
det(a*b) errr wait thats matlab 
Isiskhan Gnostic Misanthropy

Posted  2008.07.28 20:39:00  [ 12]
Originally by: Fordia So your specific question Jim McGregor is this: "How do i find the determinant of a matrix?".
Google is your friend. (C++ code link included at the bottom if the explanation is not enough). And if you're serious about programming, you better get well acquainted with that particular friend. In any case, assuming you're not lying about this not being a homework assignment, what you want to do to learn programming  no matter what language  is to pick up a problem domain you know about and find interesting, set yourself a goal, and work towards that, instead of picking up random exercises about a domain you know little about. For instance, games  start out by developing a 2D implementation of the classic Tron videogame. 
EnslaverOfMinmatar Amarr 
Posted  2008.07.29 03:23:00  [ 13]
seriously if u cant figure that out, u need to change ur major 
cytomatrix Caldari Brutal Deliverance Extreme Prejudice. 
Posted  2008.07.29 14:15:00  [ 14]

Fordia 
Posted  2008.07.30 11:48:00  [ 15]
Edited by: Fordia on 30/07/2008 11:56:09Ok so ive tried to understand the resources people have being and this is what ive come up with. My idea now is for the code to ask u for a number between 2 and 9, then it displays the matrix for that numnber and then tells u the determinant. However i thought, instead of getting the code to figure the determinant out, i will jus do that myself and get the code to simply display the value. Here is my code so far, but i keep getting a failed build: #include <iostream> #include <cstdlib> #include <cstdio> #include <math> #include <conio> using namespace std; int main () { int n; cout<<"Please enter an integer value from, and including, 2 up to 9:"; cin>>n; cout<<"You have entered "<<n; if (n==2) { cout<<"A 2x2 matrix is:"; { int firstarray[] = {1, 2}; int secondarray[] = {2, 1}; printarray (firstarray,2); printarray (secondarray,2); cout<<"The determinant of a 2x2 matrix is 3"; } } system("PAUSE"); return 0; } Originally by: EnslaverOfMinmatar seriously if u cant figure that out, u need to change ur major
For the last time, i am not at school/university. 