Solved

C++ Help with Matrices

Posted on 2014-04-13
9
238 Views
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?
new-qap-ee-code-help.txt
0
Comment
Question by:college_student
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
9 Comments
 
LVL 35

Expert Comment

by:mccarl
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!
0
 

Author Comment

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

Author Comment

by:college_student
ID: 39998265
ok ill keep that in mind. could you help answer my question though?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

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.
help.txt
0
 
LVL 35

Accepted Solution

by:
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.
0
 

Author Closing Comment

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

Expert Comment

by:mccarl
ID: 39998296
Not a problem! :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 clear a vector as well as how to detect empty vectors in C++.

738 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