Working on it now .... :D
Omar Al Qady
Posts
-
Read coefficients of linear equations into 2d array -
Read coefficients of linear equations into 2d arrayGood ideas, I'll try to incorporate them into my solution :) Thanks :)
-
Read coefficients of linear equations into 2d array1. Yes, that's possible, but a friend gave an idea of initializing the whole 2d array to equal zero, so when a variable isn't found in an equation the value isn't changed and would be correct for further calculations. 2. Yes, the sequence may change from one equation to another. 3. Variables could be one or more character so I'll just save them in an array of strings. 4. No maximum size was stated, but I don't think that matters as long as the arrays are dynamic, or does it?? :doh:
-
Read coefficients of linear equations into 2d arrayActually I was very busy yesterday, so I didn't have time to implement the ideas that I got from the discussion here yet but I'll start working on it today and let you know how it works out. Post your ideas anyway they might help me now :) I need all the help I can get :) Thank you for taking the time to think about the problem :)
-
Read coefficients of linear equations into 2d arrayI don't know about this either, so I'll try working with the hints and ideas from above and if it doesn't work out I'll research this and work on it :) Thanks for your ideas :)
-
Read coefficients of linear equations into 2d arrayI'll look into the source of 'sage' then and see if it's of any help. The other things you mentioned I'm afraid I don't understand as I am not a very advanced programmer (yet I hope :) ). Thanks for replying :)
-
Read coefficients of linear equations into 2d arrayOK then, thank you all for your help and I'll post here if I get it done :)
-
Read coefficients of linear equations into 2d arrayNo the sequence is not constant and there might be coefficients of 0 which would the variable would not be at all present in the line.
-
Read coefficients of linear equations into 2d arrayYes I think I'll try getline() and save each line into a string in a string array, and then parse it like I was advised to do above and save the coefficients in the 2d array while checking for variable in the variable array each time. I think this would be the way to go :) Thanks for replying :)
-
Read coefficients of linear equations into 2d arrayI was just thinking about what would happen if a coefficient is zero and I just freaked out and thought I'd skip it before your reply :D But I'll try your way and see how it goes :) Thanks a lot :)
-
Read coefficients of linear equations into 2d arraySo maybe I'd read each line into a string, and then go through it char by char checking for letters and = and if not I'd store in the 2d double array and after I find a letter I move to the next column, and so on till the = and store what's after it in the solutions array. I'm getting a vague idea now of how to do this, but are the signs and decimal points also readable and convertible in the same way? For example when reading -2.9 , the - & . wouldn't fall in the range for the letters and the = but can I convert them along with the numbers into a double??
-
Read coefficients of linear equations into 2d arrayThe problem is that the variables aren't always x,y,z because the program should solve n equations with n variables, so they can be more than 3 or less, so I can't assume when reading the data it's only three variables. I thought about something but I just can't implement, if I can read double by double into the array until I reach the equal sign then the double after is read into a different n sized array for the solutions, and when a new line is started I'd repeat the process in the next row of the 2d array. I don't know if what I said above is even possible but if you can help me in implementing it I'd be grateful :) Thanks for your reply :) and thanks in advance for any additional help you can give :)
-
Read coefficients of linear equations into 2d arrayHi, I'm working on a program that reads linear equations from a file such as those:
3x+2y-2.5z=9
-2x+9y+12z=23.4
4.2x-7y+9.6z=45.3The file is supposed to contain n equations with n variables which I would read into a 2d dynamic array of doubles and then I'm supposed to solve the resulting matrix using Gauss's method. I've already implemented Gauss's method but I can't figure out when reading from file how to get only the numbers and the signs for example from the above equations I'm supposed to have the following in the array:
[+3][+2][-2.5]
[-2][+9][+12]
[+4.2][-7][+9.6]I need the numbers after the equal sign to be stored in a separate n sized array as well. If anyone has any ideas I'd really appreciate it :)