Blame view

src/ExternLib/Magnitude/magnitude.cc 731 Bytes
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * 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]);
}
ed4f5039   Benjamin Renard   Add double, long ...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

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]);
}