Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: dot product...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 43334 of 48044
Post > Topic >>

Re: dot product in c++

by Ondra Holub <ondra.holub@[EMAIL PROTECTED] > Feb 14, 2008 at 11:56 PM

On 15 =DAn, 05:12, "Gerry Ford" <inva...@[EMAIL PROTECTED]
> wrote:
> I just busted out my c++ reference from purgatory and find that it
doesn't=

> help my question at hand, concerning the inner product of vectors. 
'vecto=
r'
> is not in the index.
>
> The programs in this reference are of the form void(main), so I'm left
to
> find a better syntax on the net.  Since I want vectors and I want
output, =
I
> would assume that I have at least the following gheasders:
> #include <iostream.h>
> #include <vectors.h>
>
> I don't need anything off the command line, so I think that
> int main (void) { return 0; }
> is right. ??
>
> I'm given to understand that many of fortran's vector capabilities have
an=

> analog in c++.  How would I declare and print a single four_vector, with
> double-wide real entries.  For the purpose of illustration, let's make
the=

> ith entry the real square root of i:
> 0.0000..
> 1.0000...
> 1.414....
> 1.732..
>
> Since we're taking roots, we'll have to include math.h as well.  How
does
> one declare such a vector ****tably?
>
> --
> Gerry Ford
>
> "The apple was really a peach."
> -- Allison Dunn on the garden of eden

You should include headers from standard library without .h:

#include <vector>
#include <iostream>

Some C-headers were adopted to C++, for example math.h is used in C++
as

#include <cmath>

(But both work with small differencies.)

For dot product you can #include <numeric> and use
std::inner_product(vector1.begin(), vector1.end(), vector2.begin(),
0);
 




 1 Posts in Topic:
Re: dot product in c++
Ondra Holub <ondra.hol  2008-02-14 23:56:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 22:44:30 CDT 2008.