SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vw_math.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights
3  * embodied in the content of this file are licensed under the BSD
4  * (revised) open source license.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Adaptation of Vowpal Wabbit v5.1.
12  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society.
13  */
14 
16 
17 namespace shogun
18 {
19 
21 {
22  float32_t ret = 0.;
23  for (VwFeature* f = begin; f!= end; f++)
24  ret += weights[(f->weight_index + offset) & mask] * f->x;
25  return ret;
26 }
27 
28 float32_t sd_offset_truncadd(float32_t* weights, vw_size_t mask, VwFeature* begin, VwFeature* end, vw_size_t offset, float32_t gravity)
29 {
30  float32_t ret = 0.;
31  for (VwFeature* f = begin; f!= end; f++)
32  {
33  float32_t w = weights[(f->weight_index+offset) & mask];
34  float32_t wprime = real_weight(w,gravity);
35  ret += wprime*f->x;
36  }
37  return ret;
38 }
39 
41 {
43 
44  return f.x *
45  sd_offset_add(weights, mask, cross_features.begin, cross_features.end, halfhash);
46 }
47 
49 {
51 
52  return f.x *
53  sd_offset_truncadd(weights, mask, cross_features.begin, cross_features.end, halfhash, gravity);
54 }
55 
56 }

SHOGUN Machine Learning Toolbox - Documentation