>> Tim Prince thought that utab's subroutine went
>> out of its way tomake something hard. I saw no source posting after
>> this
>> serious criticism.
>
> I could not get this point, could you be a bit more specific on that?
>
utab,
I never saw an update of your source that would reflect any of the forum
criticisms.
This is the latest version of my c++ program to match:
// vector3.cpp contributor: Jim Langston
#include
#include
#include
#include
double dot_product (const std::vector& vec_a, const
std::vector& vec_b)
{
if ( vec_a.size() != vec_b.size() )
{
std::cerr << "Vectors for dot product are not same size!\n";
return 0.0;
}
double sum = 0;
for ( std::size_t i = 0; i < vec_a.size(); ++i )
{
sum += vec_a[i] * vec_b[i];
}
return std::pow(sum, .5);
}
// Following prototype is not needed in this program since
// the definition is above, but would be used in another
// source file without the previous definition.
double dot_product (const std::vector& vec_a, const
std::vector& vec_b);
int main()
{
std::vector vec_a;
std::vector vec_b;
for ( int i = 0; i < 4; ++i )
{
vec_a.push_back( std::sqrt( static_cast( i )) );
vec_b.push_back( (-1.0) *i * i );
}
So we have our c++ function for the dot-product. That the output needs help
to reflect a negative value is fortunate: I'll ask the friendly folks in
c.l.c++ to fix that and help me herd it into an external function as well.
I have better information from the -v switch, but it's a mixed bag, as
text58 shows: