diff options
author | John Langford <jl@hunch.net> | 2011-06-19 06:22:50 +0400 |
---|---|---|
committer | John Langford <jl@hunch.net> | 2011-06-19 06:22:50 +0400 |
commit | b7944093363d409b15939f073ae39b89f6820e63 (patch) | |
tree | 5d1dfd57da5fa7147da0fd5033e5098824c82bcd /sparse_dense.h | |
parent | 9d2d1b7a88dc154fdc43af1ee432a7074825fa62 (diff) |
almost all the l1 from the online tree
Diffstat (limited to 'sparse_dense.h')
-rw-r--r-- | sparse_dense.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sparse_dense.h b/sparse_dense.h index 7f903086..9cff24ed 100644 --- a/sparse_dense.h +++ b/sparse_dense.h @@ -9,6 +9,15 @@ embodied in the content of this file are licensed under the BSD #include "parse_example.h" +inline float sign(float w){ if (w < 0.) return -1.; else return 1.;} + +inline float real_weight(float w,float gravity){ + float wprime = 0.; + if (gravity < fabsf(w)) + wprime = sign(w)*(fabsf(w) - gravity); + return wprime; +} + float sd_add(weight* weights, size_t mask, feature* begin, feature* end); float sd_truncadd(weight* weights, size_t mask, feature* begin, feature* end, float gravity); |