include/lshkit/concept.h

Go to the documentation of this file.
00001 /* 
00002     Copyright (C) 2008 Wei Dong <wdong@princeton.edu>. All Rights Reserved.
00003   
00004     This file is part of LSHKIT.
00005   
00006     LSHKIT is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 
00011     LSHKIT is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with LSHKIT.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00076 #ifndef __LSHKIT_CONCEPT__
00077 #define __LSHKIT_CONCEPT__
00078 
00079 #include <boost/concept/assert.hpp>
00080 #include <boost/concept/usage.hpp>
00081 
00082 namespace lshkit {
00083 
00085 template <typename LSH>
00086 struct LshConcept
00087 {
00088     typedef typename LSH::Domain Domain;
00089     typedef typename LSH::Parameter Parameter;
00090 
00091     BOOST_CONCEPT_USAGE(LshConcept)
00092     {
00093         LSH lsh1(param, rng1);
00094         LSH lsh2(param, rng2);
00095         LSH lsh3;
00096         lsh.reset(param, rng1);
00097         lsh.reset(param, rng2);
00098         same_type(lsh.getRange(), u);
00099         same_type(lsh(object), u);
00100         // current we do not check serialization.
00101     }
00102 protected:
00103     boost::mt11213b rng1;
00104     boost::mt19937 rng2;
00105     LSH lsh;
00106     Domain object;
00107     const Parameter param;
00108 
00109     unsigned u;
00110     template <typename T>
00111     void same_type(T const &, T const&);
00112 };
00113 
00115 template <typename LSH>
00116 struct DeltaLshConcept: public LshConcept<LSH>
00117 {
00118     typedef LshConcept<LSH> Super;
00119     BOOST_CONCEPT_USAGE(DeltaLshConcept)
00120     {
00121         float delta;
00122         Super::same_type(Super::lsh(Super::object, &delta), Super::u);
00123     }
00124 };
00125 
00126 }
00127 
00128 #endif
00129 

Get LSHKIT at SourceForge.net. Fast, secure and Free Open Source software downloads doxygen