473,473 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Vector Arithmetic

4 New Member
hi guys am new in c++ and am havin trouble in a home work would u pleaz help me. it says:
write a prog in 2files the first contains the main prog and the second contains the function
the prog calculates the dot product y=A*B where A and B r vectors
and calculates the sum C[ ]=sin(A[i])+cos(B[i])
(use a function for the dot product and for the sum)

and in the 2nd part it says use the dynamic reservation fot the same program.

thnx!
Mar 29 '07 #1
7 1617
JosAH
11,448 Recognized Expert MVP
I don't know whether or not I understand your notation correctly but please note
that X.Y == |X|.|Y|.cos(phi) where the expression on the left denotes the dot
product, |Z| is the length of the vector Z and phi is the angle between those two
vectors.

kind regards,

Jos
Mar 29 '07 #2
bcoz
4 New Member
soory that was a mistak not the dot product, the product A*B
thnx
Mar 29 '07 #3
bcoz
4 New Member
soory that was a mistak not the dot product, the product A*B.
thnx


I don't know whether or not I understand your notation correctly but please note
that X.Y == |X|.|Y|.cos(phi) where the expression on the left denotes the dot
product, |Z| is the length of the vector Z and phi is the angle between those two
vectors.

kind regards,

Jos
Mar 29 '07 #4
bcoz
4 New Member
Heelp Emergency!!!!
--------------------------------------------------------------------------------

hi guys am new in c++ and am havin trouble in a home work would u pleaz help me. it says:
write a prog in 2files the first contains the main prog and the second contains the function
the prog calculates the product y=A*B where A and B r vectors
and calculates the sum C[ ]=sin(A[i])+cos(B[i])
(use a function for the dot product and for the sum)

and in the 2nd part it says use the dynamic reservation fot the same program.

thnx!

--------------------------------------------------------------------------------
Mar 29 '07 #5
JosAH
11,448 Recognized Expert MVP
soory that was a mistak not the dot product, the product A*B.
thnx
Please rephrase your question then because now I don't understand your
question anymore (just call me thick).

kind regards,

Jos
Mar 29 '07 #6
Savage
1,764 Recognized Expert Top Contributor
Please don't double post!!!

First you will write a function in separate file and then save it as *.h

Later in your main programm you will include it like header file:

#include "*.h"

Secound you must make in main loop fo filling arrays of a[] and b[]

once you have done it c and y are only feaw formulas away from you!

Hope this helps!

Savage
Mar 29 '07 #7
Ganon11
3,652 Recognized Expert Specialist
Please don't double-post your question - use this thread for any more questions about this problem. I have merged the two threads you started.
Mar 29 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Andreas Krueger | last post by:
Hi! I am fed up with vector<int> iv; iv.push_back(42); iv.push_back(9); iv.push_back(11); ... and would rather use a function "fillVector": vector<int> iv = fillVector(42,9,11); like...
4
by: Angela | last post by:
It's late. Why is the compiler saying that this is the wrong syntax: vector<vector<cIndicatorValue>> ranks; One other question: If I want to access one of cIndicatorValue's functions, I have...
19
by: Carlo Milanesi | last post by:
Mathematically speaking, a 'vector' is something you can add to another vector and multiply by a number. But in C++, the following code is illegal: std::vector<double> v1(3), v2(3); v1 + v2; //...
29
by: Hagen | last post by:
Hello, in a recent thread "speed of vector vs array" I read about the problem of the slow acces by addressing vector elements by indexing, unfortunately I see no workaround in my case. My...
13
by: Mike Austin | last post by:
Hi all. Just working on a small virtual machine, and thought about using vector iterators instead of pointer arithmetic. Question is, why does an iterator plus any number out of range not...
27
by: Marcus Kwok | last post by:
I am getting warnings when comparing a (regular) int to the value returned from std::vector.size() in code similar to the following: int i = //stuff if (i >= vec.size()) The compiler gives...
12
by: No Such Luck | last post by:
Hi All: I'm not sure if this is the right place to ask this question, but I couldn't find a more appropriate group. This is more of a theory question regarding an algorithm implemented in C, not...
7
by: ma740988 | last post by:
Consider: # include <iostream> # include <string> # include <map> # include <bitset> # include <vector> using namespace std;
7
by: silverburgh.meryl | last post by:
in STL, why vector has an API to return the n-th element, but list does not have such API? http://www.sgi.com/tech/stl/Vector.html http://www.sgi.com/tech/stl/List.html Thank you.
4
by: helge | last post by:
What is the best way to implement a vector in space R3, i.e a vector holding three floats, supporting arithmetic operations, dot and cross product etc in c++? is there a standard library class for...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.