magnitude.cc
731 Bytes
/**
* Magnitude.cc
*
* Created on: 31 oct. 2012
* Author: AKKA IS
*/
#include "magnitude.hh"
#include <math.h>
float magnitude(const std::vector<float>& vec)
{
return sqrtf(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
}
double magnitude(const std::vector<double>& vec)
{
return sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
}
long double magnitude(const std::vector<long double>& vec)
{
return sqrtl(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
}
int magnitude(const std::vector<int>& vec)
{
return sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
}
short magnitude(const std::vector<short>& vec)
{
return sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
}