Public Group

This topic is 3891 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello everyone again! I was wondering if you guys could help me again I'm on a new exercise called Matrix Addition. And all the author gave me is what you can find below in my link. All you have to do is copy and paste and it send you directly to the magnified image of my exercise. I'm actually kinda confused on how to do it. I tried making arrays and then referencing back to them to do an addition on each of them. It became a mess of code. And it probably wouldn't have even worked right. So I was wondering if you guys could help me on what I need to do to make this program work. Thanks! Link to picture of exercise: http://i32.tinypic.com/wb5kpt.jpg

Share on other sites
0) What don't you understand? Do you know, for example, what a Matrix actually *is*?

1) What have you figured out so far?

Do you have a structure that represents a Matrix? You don't seem to be expected here to read in any data; you just set up two hard coded Matrix objects and add them.

We're not psychic. If you tried something and want to know what's wrong, you should show what you tried.

2) You can link images here with ordinary HTML <img> tags (use the thumbnails from the image hosting site, not the full sized image, unless it's small). Although honestly, it would have been less effort to just type out the text from the book than it was to scan the page, put it up on an image hosting site and then explain how to find it.

Share on other sites
0) Yes I do a matrix is an array of an array. A multidimensional array both the same thing. So let's say with the picture provided it wanted us to use these numbers and add them accordingly. -5, 2, 8, 1, 0, 0 = A / 1, 0, 2, 0, 3, -6 = B

So we say... umm.. hmm.. okay

int a[2][3] =
{
{-5, 2, 8},
{1, 0, 0}
};

And then for B:

int b[2][3] = // which will be same thing for a
{
{1, 0, 2},
{0, 3, -6}
};

1) Well let's see I figure that I will need a multidimensional array aka matrix and that I will need to take a + b = c.

I guess where I'm confused at is that I don't know the syntax for adding a + b to = c because if you do c = a + b; your gonna get errors for trying to add pointers.

2) Actually when I posted my other exercises I tried typing out there examples just like the book said and it was too big of a task when I can simply take a picture of it, crop it, and host it, so everyone can see it just like in the books. And when I tried to use the HTML tags I tried using . I didn't know about the <img> tag.. Sorry!

Share on other sites
Hmm can anyone help me?

Share on other sites
I don't think you are quite familiar with the concept of a matrix, at least in the mathematical context, which is the one relevant here. A matrix is a multi-dimensional array, which represents some abstract quantity (for example, a transformation – a single matrix might represent the idea of rotating an object 45 degrees around an axis and then translating it by 3 units along that axis in a certain direction) and has specific operations defined upon it. Matrices and their operations are not built in to C++ – you have to define them yourself (or, better yet, use an existing library).

The Wikipedia article should help. If this is a pedagogical programming exercise, rather than a linear algebra one, you're probably most interested in the "Adding and multiplying matrices" section (although a scan of the rest of the page will almost certainly be helpful).

Share on other sites
Oops!

Good thing he's not online right now.

Thanks for that smitty :]

Code is gone now.

[Edited by - crazysk8er on January 29, 2008 9:43:55 AM]

Share on other sites
Quote:
 Original post by crazysk8erI hope that I understood what you were wanting, and that this helped.edit: explained some code

This problem looks like homework, which is why people weren't just giving the answer.

;-)

Share on other sites
Quote:
 Original post by Roberts911) Well let's see I figure that I will need a multidimensional array aka matrix and that I will need to take a + b = c. I guess where I'm confused at is that I don't know the syntax for adding a + b to = c because if you do c = a + b; your gonna get errors for trying to add pointers.

Well, if you read your exercise closely, it tells you what to do.

"Using a double for-loop to iterate over the matrix elements, compute the sum of each component and store the result in the third matrix (e.g., C[j] = A[j] + B[j] )."

Share on other sites
If the OP needs to learn a decent c++, a better description of the exercise would be: "Implement your memory manager class matrix with overloaded + operator". ;)

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 42
• Forum Statistics

• Total Topics
632635
• Total Posts
3007559
• Who's Online (See full list)

There are no registered users currently online

×

Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!