Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit da34b627 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Adding a missing file in the Mercurial

parent 9e8ac84e
#include "common.h"
double norm(const vec& a)
{
double norm = 0.0 ;
for(unsigned int i=0; i<a.size(); ++i)
{
norm += a[i]*a[i];
}
return sqrt(norm);
}
vec normalize(const vec& a)
{
vec b(a.size());
double norm = 0.0 ;
for(unsigned int i=0; i<a.size(); ++i)
{
norm += a[i]*a[i];
}
norm = sqrt(norm);
for(unsigned int i=0; i<a.size(); ++i)
{
b[i] = a[i]/norm;
}
return b;
}
double dot(const vec& a, const vec& b)
{
#ifdef DEBUG
assert(a.size() == b.size());
#endif
double res = 0.0;
for(unsigned int i=0; i<a.size(); ++i)
{
res += a[i]*b[i];
}
return res;
}
vec product(const vec& a, const vec& b)
{
#ifdef DEBUG
assert(a.size() == b.size());
#endif
vec res(a.size());
for(unsigned int i=0; i<a.size(); ++i)
{
res[i] = a[i]*b[i];
}
return res;
}
std::ostream& operator<<(std::ostream& out, const vec& v)
{
out << "[";
for(int i=0; i<v.size(); ++i)
{
out << v(i);
if(i != v.size()-1) { out << ", "; }
}
out << "]";
return out;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment