Tapkee
embed.hpp
Go to the documentation of this file.
00001 /* This software is distributed under BSD 3-clause license (see LICENSE file).
00002  *
00003  * Copyright (c) 2012-2013 Sergey Lisitsyn
00004  */
00005 
00006 #ifndef TAPKEE_EMBED_H_
00007 #define TAPKEE_EMBED_H_
00008 
00009 /* Tapkee includes */
00010 #include <tapkee/defines.hpp>
00011 #include <tapkee/methods.hpp>
00012 /* End of Tapkee includes */
00013 
00014 namespace tapkee
00015 {
00094 template <class RandomAccessIterator, class KernelCallback, class DistanceCallback, class FeaturesCallback>
00095 TapkeeOutput embed(RandomAccessIterator begin, RandomAccessIterator end,
00096                    KernelCallback kernel_callback, DistanceCallback distance_callback,
00097                    FeaturesCallback features_callback, ParametersSet parameters)
00098 {
00099 #if EIGEN_VERSION_AT_LEAST(3,1,0)
00100     Eigen::initParallel();
00101 #endif
00102     TapkeeOutput output;
00103 
00104     parameters.merge(tapkee_internal::defaults);
00105 
00106     DimensionReductionMethod selected_method = parameters(keywords::method);
00107     
00108     void (*progress_function)(double) = parameters(keywords::progress_function);
00109     bool (*cancel_function)() = parameters(keywords::cancel_function);
00110 
00111     tapkee_internal::Context context(progress_function,cancel_function);
00112 
00113     try 
00114     {
00115         LoggingSingleton::instance().message_info("Using the " + get_method_name(selected_method) + " method.");
00116         
00117         output = tapkee_internal::initialize(begin,end,kernel_callback,distance_callback,features_callback,parameters,context)
00118                                  .embedUsing(selected_method);
00119     }
00120     catch (const std::bad_alloc&)
00121     {
00122         throw not_enough_memory_error("Not enough memory");
00123     }
00124 
00125     return output;
00126 }
00127 }
00128 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines