SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChebyshewMetric.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2006-2009 Christian Gehl
8  * Copyright (C) 2006-2009 Fraunhofer Institute FIRST
9  */
10 
11 #include <shogun/lib/config.h>
12 #include <shogun/lib/common.h>
13 #include <shogun/io/SGIO.h>
17 
18 using namespace shogun;
19 
21 {
22 }
23 
26 {
27  init(l, r);
28 }
29 
31 {
32  cleanup();
33 }
34 
35 bool CChebyshewMetric::init(CFeatures* l, CFeatures* r)
36 {
38 }
39 
41 {
42 }
43 
44 float64_t CChebyshewMetric::compute(int32_t idx_a, int32_t idx_b)
45 {
46  int32_t alen, blen;
47  bool afree, bfree;
48 
49  float64_t* avec=
50  ((CSimpleFeatures<float64_t>*) lhs)->get_feature_vector(idx_a, alen, afree);
51  float64_t* bvec=
52  ((CSimpleFeatures<float64_t>*) rhs)->get_feature_vector(idx_b, blen, bfree);
53 
54  ASSERT(alen==blen);
55 
56  float64_t result=DBL_MIN;
57 
58  for (int32_t i=0; i<alen; i++)
59  result=CMath::max(result, fabs(avec[i]-bvec[i]));
60 
61  ((CSimpleFeatures<float64_t>*) lhs)->free_feature_vector(avec, idx_a, afree);
62  ((CSimpleFeatures<float64_t>*) rhs)->free_feature_vector(bvec, idx_b, bfree);
63 
64  return result;
65 }

SHOGUN Machine Learning Toolbox - Documentation