vector multiplication

can't find in google!

vector1 * vector2 = vector3

then x= summation of vector3
Are you talking about the STL container or the geometric vector?

The use of the word vector for the STL container is unfortunate. It creates a lot of confusion for me

As far as geometric vectors are concerned, there is no simple multiply of two vectors. There is a dot product and cross product and they produce very different results.

If you're talking about the STL container, it's a container, not a math term. If you want to multiply the contents of two vectors and sum the results, you'll have to write your own routine.
Last edited on
I guess you mean sth like
1
2
3
4
5
int vector1[10];
int vector2[10];
int vector3[10];

vector3=vector1*vector2;

Don't you? Btw: I'm not sure if this might be right, I would not use it...
A possible solution might be:

1
2
3
4
5
6
7
8
9
10
int vector1[10];
int vector2[10];
int vector3[10];
int x;

for(int i=0;i<10;i++)
{
    vector3[i]=vector1[i]*vector2[i];
    x+=vector3[i];
}
Last edited on
In standard header <numeric> thsre is algorithm std::inner_product that do the task you needed.

for example,

1
2
3
4
5
6
7
int vector1[N];
int vector2[N];


// somehow fill the arrays

int product = std::inner_product( vector1, vector1 + N, vector2, 0 );
Last edited on
the vector im reffering to this is the vector use for extending the number of times a user can input...

vector 1= directs to a dynamic memory
vector 2= refers to the quantity of vector 1
vector 3= refers to the corresponding value each vector 1 points to
vector 4= product of vector 2 and 3
what does vector 4 do exactly?

http://bipolarsymptomsinmen.eipaha.com/
Topic archived. No new replies allowed.