def claim_n_points(self, nnn, newclazz):
        working_set = self.working_set
        if self.classcounts_ws[newclazz] == self.size_ws:
            raise Exception('The whole working set already belongs to class ' +
                            str(newclazz))
        gradient_vec = np.zeros((self.size_ws))
        tempvec = np.zeros((self.Y.shape[1]))
        cython_mmc.compute_gradient(self.Y_ws, gradient_vec,
                                    self.classcounts_ws, self.classvec_ws,
                                    self.size_ws, self.size, self.DVTY,
                                    self.sqrtRx2_ws, self.sqrtR.shape[1],
                                    newclazz, tempvec, self.Y.shape[1])

        claiminds = np.argsort(gradient_vec)

        clazzcountchanges = np.zeros((self.labelcount), dtype=np.int32)
        cython_mmc.claim_n_points(self.Y_ws, gradient_vec, self.classcounts_ws,
                                  self.classvec_ws, claiminds, nnn, self.DVTY,
                                  self.sqrtRx2_ws, self.sqrtR.shape[1],
                                  newclazz, clazzcountchanges)

        self.Y[working_set] = self.Y_ws
        self.classvec[working_set] = self.classvec_ws
        #self.classcounts[oldclazz] -= nnn
        self.classcounts[newclazz] += nnn
        for i in range(self.labelcount):
            self.classcounts[i] += clazzcountchanges[i]
 def compute_steepness_vector(self):        
     gradient_vec0 = np.zeros((self.size_ws))
     tempvec = np.zeros((self.Y.shape[1]))
     cython_mmc.compute_gradient(self.Y_ws,
                  gradient_vec0,
                  self.classcounts_ws,
                  self.classvec_ws,
                  self.size_ws,
                  self.size,
                  self.DVTY,
                  self.sqrtRx2_ws,
                  self.sqrtR.shape[1],
                  0,
                  tempvec,
                  self.Y.shape[1])
     gradient_vec1 = np.zeros((self.size_ws))
     tempvec = np.zeros((self.Y.shape[1]))
     cython_mmc.compute_gradient(self.Y_ws,
                  gradient_vec1,
                  self.classcounts_ws,
                  self.classvec_ws,
                  self.size_ws,
                  self.size,
                  self.DVTY,
                  self.sqrtRx2_ws,
                  self.sqrtR.shape[1],
                  1,
                  tempvec,
                  self.Y.shape[1])
     
     steepness_vector = np.zeros((self.size_ws))
     steepness_vector[0:self.classcounts_ws[1]] = np.sort(gradient_vec0)[0:self.classcounts_ws[1]][::-1]
     steepness_vector[self.classcounts_ws[1]:] = np.sort(gradient_vec1)[0:self.classcounts_ws[0]]
     #print steepness_vector
     return steepness_vector
 def claim_n_points(self, nnn, newclazz):
     working_set = self.working_set
     if self.classcounts_ws[newclazz] == self.size_ws:
         raise Exception('The whole working set already belongs to class '+str(newclazz))
     gradient_vec = np.zeros((self.size_ws))
     tempvec = np.zeros((self.Y.shape[1]))
     cython_mmc.compute_gradient(self.Y_ws,
                  gradient_vec,
                  self.classcounts_ws,
                  self.classvec_ws,
                  self.size_ws,
                  self.size,
                  self.DVTY,
                  self.sqrtRx2_ws,
                  self.sqrtR.shape[1],
                  newclazz,
                  tempvec,
                  self.Y.shape[1])
     
     claiminds = np.argsort(gradient_vec)
     
     clazzcountchanges = np.zeros((self.labelcount), dtype = np.int32)
     cython_mmc.claim_n_points(self.Y_ws,
                  gradient_vec,
                  self.classcounts_ws,
                  self.classvec_ws,
                  claiminds,
                  nnn,
                  self.DVTY,
                  self.sqrtRx2_ws,
                  self.sqrtR.shape[1],
                  newclazz,
                  clazzcountchanges)
     
     self.Y[working_set] = self.Y_ws
     self.classvec[working_set] = self.classvec_ws
     #self.classcounts[oldclazz] -= nnn
     self.classcounts[newclazz] += nnn
     for i in range(self.labelcount):
         self.classcounts[i] += clazzcountchanges[i]
    def compute_steepness_vector(self):
        gradient_vec0 = np.zeros((self.size_ws))
        tempvec = np.zeros((self.Y.shape[1]))
        cython_mmc.compute_gradient(self.Y_ws, gradient_vec0,
                                    self.classcounts_ws, self.classvec_ws,
                                    self.size_ws, self.size, self.DVTY,
                                    self.sqrtRx2_ws, self.sqrtR.shape[1], 0,
                                    tempvec, self.Y.shape[1])
        gradient_vec1 = np.zeros((self.size_ws))
        tempvec = np.zeros((self.Y.shape[1]))
        cython_mmc.compute_gradient(self.Y_ws, gradient_vec1,
                                    self.classcounts_ws, self.classvec_ws,
                                    self.size_ws, self.size, self.DVTY,
                                    self.sqrtRx2_ws, self.sqrtR.shape[1], 1,
                                    tempvec, self.Y.shape[1])

        steepness_vector = np.zeros((self.size_ws))
        steepness_vector[0:self.classcounts_ws[1]] = np.sort(
            gradient_vec0)[0:self.classcounts_ws[1]][::-1]
        steepness_vector[self.classcounts_ws[1]:] = np.sort(
            gradient_vec1)[0:self.classcounts_ws[0]]
        #print steepness_vector
        return steepness_vector