MCPcopy Create free account
hub / github.com/davisking/dlib / distance_function

Class distance_function

dlib/svm/function.h:282–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280 typename K
281 >
282 class distance_function
283 {
284 public:
285 typedef K kernel_type;
286 typedef typename K::scalar_type scalar_type;
287 typedef typename K::scalar_type result_type;
288 typedef typename K::sample_type sample_type;
289 typedef typename K::mem_manager_type mem_manager_type;
290
291 typedef matrix<scalar_type,0,1,mem_manager_type> scalar_vector_type;
292 typedef matrix<sample_type,0,1,mem_manager_type> sample_vector_type;
293
294
295 distance_function (
296 ) : b(0), kernel_function(K()) {}
297
298 explicit distance_function (
299 const kernel_type& kern
300 ) : b(0), kernel_function(kern) {}
301
302 distance_function (
303 const kernel_type& kern,
304 const sample_type& samp
305 ) :
306 alpha(ones_matrix<scalar_type>(1,1)),
307 b(kern(samp,samp)),
308 kernel_function(kern)
309 {
310 basis_vectors.set_size(1,1);
311 basis_vectors(0) = samp;
312 }
313
314 distance_function (
315 const decision_function<K>& f
316 ) :
317 alpha(f.alpha),
318 b(trans(f.alpha)*kernel_matrix(f.kernel_function,f.basis_vectors)*f.alpha),
319 kernel_function(f.kernel_function),
320 basis_vectors(f.basis_vectors)
321 {
322 // make sure requires clause is not broken
323 DLIB_ASSERT(f.alpha.size() == f.basis_vectors.size(),
324 "\t distance_function(f)"
325 << "\n\t The supplied decision_function is invalid."
326 << "\n\t f.alpha.size(): " << f.alpha.size()
327 << "\n\t f.basis_vectors.size(): " << f.basis_vectors.size()
328 );
329 }
330
331 distance_function (
332 const scalar_vector_type& alpha_,
333 const scalar_type& b_,
334 const K& kernel_function_,
335 const sample_vector_type& basis_vectors_
336 ) :
337 alpha(alpha_),
338 b(b_),
339 kernel_function(kernel_function_),

Callers 4

operator*Method · 0.70
operator/Method · 0.70
operator+Method · 0.70
operator-Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected