View Javadoc

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 OBVectorDouble 
23  	*  and feeds parent TestFrameworkDouble with them.
24    *  @author      Arnoldo Jose Muller Molina    
25    */
26  import java.util.Random;
27  
28  public class VectorTestFrameworkApproxDouble extends TestFrameworkApproxDouble<OBVectorDouble> {
29  
30  	private int vectorDimensionality;
31  	private Random r;
32  	public VectorTestFrameworkApproxDouble(int vectorDimensionality, int dbSize, int querySize,
33  			IndexDouble<OBVectorDouble> index) {
34  		super(OBVectorDouble.class, dbSize, querySize, index);
35  		this.vectorDimensionality = vectorDimensionality;
36  		r = new Random();
37  	}
38  
39  	@Override
40  	protected OBVectorDouble next() {
41  		double[] vector = new double[vectorDimensionality];
42  		int i = 0;
43  		while(i < vector.length){
44  			vector[i] =   			
45  	  r.nextDouble();
46  
47  					//(double)r.nextInt(Double.MAX_VALUE/vectorDimensionality);
48  			i++;
49  		}
50  		return new OBVectorDouble(vector);
51  	}
52  	
53  	protected void search() throws Exception{
54  				 search(index, (double)0.01 ,(byte)   3);
55  				 search(index, (double)0.1 ,(byte)  3);
56  				 search(index, (double)0.2 ,(byte)  3);
57  				 search(index, (double)20 ,(byte)  3);
58  				 //TODO: Range 100 fails for Double/Float Fix this.
59  				 //search(index, (double)2001 ,(byte)  3);
60  		
61  	}
62  	
63  	
64  }