13        template <
typename Type>
 
   14        static double dotProduct(
const std::vector<Type>& a, 
const std::vector<Type>& b) {
 
   17            for (std::size_t i = 0; i < a.size(); ++i) {
 
   18                result += a[i] * b[i];
 
   23        template <
typename Type>
 
   24        static double magnitude(
const std::vector<Type>& v) {
 
   26            for (
double value : v) {
 
   27                result += value * value;
 
   32        template <
typename Type>
 
   33        static double cosineSimilarity(
const std::vector<Type>& a, 
const std::vector<Type>& b) {
 
   34            double dotProd = dotProduct(a, b);
 
   35            double magA = magnitude(a);
 
   36            double magB = magnitude(b);
 
   37            if(magA == 0 && magB == 0) {
 
   40            else if (magA == 0 || magB == 0) {
 
   44            return dotProd / (magA * magB);
 
Definition: exceptions.hpp:12