Adding Two-Dimensional arrays together - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22

Thread: Adding Two-Dimensional arrays together

  1. #16
    Join Date
    Jan 2010
    Posts
    17

    Re: Adding Two-Dimensional arrays together

    Oh yes I can calculate simultaneous equations by hand. I just found it difficult using a loop to attempt to calculate them with like addition. I just don't understand the whole calculation via a loop with a 2D Array of [3] [4]. I'm a total noob at C++. I've tried an attempt and to me it doesn't seem correct.

  2. #17
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,891

    Re: Adding Two-Dimensional arrays together

    Please, lay out the sequence of steps you'd use to solve this pair of equations, and we'll go from there.

    9 = 4x + 6y
    -3 = x - 10y

  3. #18
    Join Date
    Apr 1999
    Posts
    27,444

    Re: Adding Two-Dimensional arrays together

    Quote Originally Posted by TBsparky View Post
    Oh yes I can calculate simultaneous equations by hand.
    The issue is how you are solving these by hand. If you're solving them by hand using the algrebaic way of doing things, you will be here for months writing a program to simulate what you learned in junior high school. Heck, an expert would be here for weeks writing such a program.

    The easiest way that simultaneous equations are solved by computer is to use Gaussian elimination. Did your teacher discuss that? If not, please look that up, as you cannot possibly write a program to solve equations in the "traditional" math book way.

    Regards,

    Paul McKenzie

  4. #19
    Join Date
    Jan 2010
    Posts
    17

    Re: Adding Two-Dimensional arrays together

    No she did not discuss the Gaussain method. As far as i know its Solving Simultaneous equations by the use of matrices

  5. #20
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,891

    Re: Adding Two-Dimensional arrays together

    Quote Originally Posted by TBsparky View Post
    by the use of matrices
    Key phrase. Do you know what this means? "use of matrices" can mean anything.

  6. #21
    Join Date
    Apr 1999
    Posts
    27,444

    Re: Adding Two-Dimensional arrays together

    Quote Originally Posted by TBsparky View Post
    No she did not discuss the Gaussain method. As far as i know its Solving Simultaneous equations by the use of matrices
    And Guassian method uses matrices.

    Again, you cannot write a program within a reasonable time trying to solve equations the way you do by hand using traditional math. The routine you want is called Guassian elimination. Just do a google search, and you will see the routine explained to you.

    If your teacher wants you to solve equations as you do with traditional math you learned in school, he or she is playing a very cruel joke on you. You won't, and I bet your entire class won't be able to complete the assignment, or even know where to start if that is really what the teacher is expecting. So I'm assuming your teacher is wanting you to solve the equations using Gaussian elimination (there are other methods, but this is the easiest to implement).

    Edit:

    Here is a link to a previous topic. Please read:

    http://www.codeguru.com/forum/showth...light=gaussian

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; April 28th, 2011 at 05:49 PM.

  7. #22
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,891

    Re: Adding Two-Dimensional arrays together

    Quote Originally Posted by Paul McKenzie View Post
    Again, you cannot write a program within a reasonable time trying to solve equations the way you do by hand using traditional math.
    You can actually, for this specific case: 2 equations in 2 unknowns. It's simple enough in that case to write out the substitutions explicitly.

    Gaussian elimination is the more general solution for handling n equations in n unknowns, of course.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center