IndexType* load_saved_index(const Matrix<ElementType>& dataset, const std::string& filename, Distance distance) { FILE* fin = fopen(filename.c_str(), "rb"); if (fin == NULL) { return NULL; } IndexHeader header = load_header(fin); if (header.data_type != flann_datatype_value<ElementType>::value) { throw FLANNException("Datatype of saved index is different than of the one to be created."); } IndexParams params; params["algorithm"] = header.index_type; IndexType* nnIndex = create_index_by_type<Distance>(header.index_type, dataset, params, distance); rewind(fin); nnIndex->loadIndex(fin); fclose(fin); return nnIndex; }