// Copyright (C) 1999 Jean-Marc Valin #include "BufferedNode.h" #include "Buffer.h" #include "Vector.h" #include using namespace std; namespace FD { class Dist; DECLARE_NODE(Dist) /*Node * * @name Dist * @category DSP:Misc * @description Calculates the distance between two vectors * * @input_name INPUT1 * @input_type Vector * @input_description First input vector * * @input_name INPUT2 * @input_type Vector * @input_description Second input vector * * @output_name OUTPUT * @output_type Vector * @output_description Distance between INPUT1 and INPUT2 * END*/ class Dist : public BufferedNode { int input2ID; int input1ID; int outputID; static float ncos_dist(const float *x1, const float *x2, int len) { double xx=0,xy=0,yy=0; double sx=0,sy=0; for (int i=0;i &in1 = object_cast > (input1Value); const Vector &in2 = object_cast > (input2Value); if (in1.size() != in2.size()) throw new NodeException(this, "Vector size don't match", __FILE__, __LINE__); float dist = cos_dist(&in1[0], &in2[0], in1.size()); out[count] = ObjectRef (Float::alloc(dist)); } }; }//namespace FD