Esempio n. 1
0
    def sqm(self):
        """
        Estimates the Euclidian distance between two vectors.

        @return row and col

        """
        if len(self.p) != len(self.q):
            raise Exception('Both vectors p and q must have the same length (got respectively %d and %d).'%(len(self.p),len(self.q)))

        row = list()
        for x in self.p:
            row.append( sum( sq(x,y) for y in self.q) )

        col = list()
        for y in self.q:
            col.append( sum( sq(y,x) for x in self.p) )

        return row,col
Esempio n. 2
0
    def sqv(self):
        """
        Estimates the Euclidian distance between two vectors.

        @param p is a vector of tuples of float values
        @param q is a vector of tuples of float values
        @return v

        """
        if len(self.p) != len(self.q):
            raise Exception('Both vectors p and q must have the same length (got respectively %d and %d).'%(len(self.p),len(self.q)))

        return sum([sq(x,y) for (x,y) in zip(self.p,self.q)])