C++ Help with Matrices

Posted on 2014-04-13
Last Modified: 2014-04-13
Hi i need help multiplying 2 matrix arrays b_matrix and p_matrix such that it creates a V_matrix and then use that V_matrix to create the C_matrix.

This isnt necessarily 'matrix' multiplication, more so scalar, by that I mean i coded the formula such that the first row of the V_matrix will be 0 60 50 45.

Can anyone help me?
Question by:college_student
  • 3
  • 3
LVL 35

Expert Comment

ID: 39998245
The code that you've got there to do the multiplication looks fine. You just need to name the function properly (you can't have the square brackets in a function name) and then call that function from within your code. And I can't see how this would be too much of a drama because you have already done exactly this with the "costMatrix()" function!

Author Comment

ID: 39998249
how would i call it within the code? and would the proper name be V_matrix()?

Author Comment

ID: 39998265
ok ill keep that in mind. could you help answer my question though?
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.


Expert Comment

by:Subrat (C++ windows/Linux)
ID: 39998276
I don't know while updating the message, i found some error related to {i} tag something....
So uploading the file for your reference.
Including to the above answer given by expert....

Look into the attachment.
LVL 35

Accepted Solution

mccarl earned 500 total points
ID: 39998279
So I am assuming that you haven't written all this code yourself then?

Whoever wrote the "costMatrix()" function has given you a pretty good hint as to what to do. The code that you have posted shows how to declare a function, costMatrix, is an example of this, and also how to call that function from within other parts of your code (look at the fourth line of code in your main() function body. So all you need to do is follow those examples.

would the proper name be V_matrix()?
The proper name would be whatever you wanted to call it that makes sense to you. But yes, that is closer to the correct syntax to yuse when declaring the function. But I wouldn't call the function the same as an existing variable name. You may want to call the function something descriptive such as "calculateVMatrix()", although I am sure that as far as your algorithm goes, that there is probably an even better description for what generating the V matrix is really doing.

Author Closing Comment

ID: 39998295
Thanks for your help. i got it now
LVL 35

Expert Comment

ID: 39998296
Not a problem! :)

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question