c@256: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@256: c@256: /* c@256: QM DSP Library c@256: c@256: Centre for Digital Music, Queen Mary, University of London. c@256: This file copyright 2008 Kurt Jacobson. c@309: c@309: This program is free software; you can redistribute it and/or c@309: modify it under the terms of the GNU General Public License as c@309: published by the Free Software Foundation; either version 2 of the c@309: License, or (at your option) any later version. See the file c@309: COPYING included with this distribution for more information. c@256: */ c@256: c@256: #include "CosineDistance.h" c@256: c@256: #include c@256: #include c@256: c@256: using std::cerr; c@256: c@256: double CosineDistance::distance(const vector &v1, c@256: const vector &v2) c@256: { c@256: dist = 1.0; dDenTot = 0; dDen1 = 0; dDen2 = 0; dSum1 =0; c@299: double small = 1e-20; c@256: c@256: //check if v1, v2 same size c@256: if (v1.size() != v2.size()) c@256: { c@256: cerr << "CosineDistance::distance: ERROR: vectors not the same size\n"; c@256: return 1.0; c@256: } c@256: else c@256: { c@256: for(int i=0; i