1 package net.obsearch.index; 2 /* 3 OBSearch: a distributed similarity search engine This project is to 4 similarity search what 'bit-torrent' is to downloads. 5 Copyright (C) 2008 Arnoldo Jose Muller Molina 6 7 This program is free software: you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation, either version 3 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 /** 22 * VectorTestFramework creates objects of type OBVectorFloat 23 * and feeds parent TestFrameworkFloat with them. 24 * @author Arnoldo Jose Muller Molina 25 */ 26 import java.util.Random; 27 28 public class VectorTestFrameworkApproxFloat extends TestFrameworkApproxFloat<OBVectorFloat> { 29 30 private int vectorDimensionality; 31 private Random r; 32 public VectorTestFrameworkApproxFloat(int vectorDimensionality, int dbSize, int querySize, 33 IndexFloat<OBVectorFloat> index) { 34 super(OBVectorFloat.class, dbSize, querySize, index); 35 this.vectorDimensionality = vectorDimensionality; 36 r = new Random(); 37 } 38 39 @Override 40 protected OBVectorFloat next() { 41 float[] vector = new float[vectorDimensionality]; 42 int i = 0; 43 while(i < vector.length){ 44 vector[i] = 45 r.nextFloat(); 46 47 //(float)r.nextInt(Float.MAX_VALUE/vectorDimensionality); 48 i++; 49 } 50 return new OBVectorFloat(vector); 51 } 52 53 protected void search() throws Exception{ 54 search(index, (float)0.01 ,(byte) 3); 55 search(index, (float)0.1 ,(byte) 3); 56 search(index, (float)0.2 ,(byte) 3); 57 search(index, (float)20 ,(byte) 3); 58 //TODO: Range 100 fails for Double/Float Fix this. 59 //search(index, (float)2001 ,(byte) 3); 60 61 } 62 63 64 } 65