/*=================================================================
 * Top-k Pruning method for object class retrieval.
 * Publication:
 * Methods For Scalable Object-Class Retrieval. 
 *    By M. Rastegari, C. Fang, L. Torresani.
 *    In Proceeding of ICCV'2011
 * 
 * Code is writen by Mohammad Rastegari. Report any bugs to mrastegari@cs.dartmouth.edu
 * 
 * Copyright (c) 2011
 * Permission is hereby granted, free of charge, to any person obtaining a 
 * copy of this software and associated documentation files (the “Software”),  
 * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY. 
 * 
 * The calling syntax in matlab is:
 *
 *		[top_K, top_K_idx, time] = TkP(single(w),B,uint32(idx),uint32(K));
 *
 *Inputs:
 * w  : 2659-by-1 weight vector which can be obtained by any linear classifiers. 
 * B  : N-by-333 binary classemes matrix (Large Database).
 * idx: indices of sorting absolute values of w in descending order.
 * K  : number of items for retrieval.
 *
 *Outputs:
 * top_K    : (K+1)-by-1 matrix containing the scores of the top-K retrieved items (data begins from second element)
 * top_K_idx: (K+1)-by-1 matrix containing the indices of the top-K retrieved items (data begins from second element)
 * time     : retrieval time (in second).   
 *=================================================================*/