diff options
author | Brian Muller <brian.muller@livingsocial.com> | 2012-01-03 23:56:51 +0400 |
---|---|---|
committer | Brian Muller <brian.muller@livingsocial.com> | 2012-01-03 23:56:51 +0400 |
commit | 9f457bf70dcab12082ec07cc6018e3f1a75899a2 (patch) | |
tree | a30f2028788bf291a71200ff5644a3c72a842f27 /vowpalwabbit/sparse_dense.h | |
parent | 5c267f9404ffbb733c88b759605386aad51e6baf (diff) |
now creating a linkable library
Diffstat (limited to 'vowpalwabbit/sparse_dense.h')
-rw-r--r-- | vowpalwabbit/sparse_dense.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/vowpalwabbit/sparse_dense.h b/vowpalwabbit/sparse_dense.h new file mode 100644 index 00000000..649d7365 --- /dev/null +++ b/vowpalwabbit/sparse_dense.h @@ -0,0 +1,41 @@ +/* +Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights +embodied in the content of this file are licensed under the BSD +(revised) open source license + */ + +#ifndef SPARSE_DENSE_VECTOR_H +#define SPARSE_DENSE_VECTOR_H + +#include <math.h> +#include "parse_example.h" + +inline float sign(float w){ if (w < 0.) return -1.; else return 1.;} + +inline float trunc_weight(float w, float gravity){ + return (gravity < fabsf(w)) ? w - sign(w) * gravity : 0.; +} + +float sd_add(weight* weights, size_t mask, feature* begin, feature* end); +float sd_add_trunc(weight* weights, size_t mask, feature* begin, feature* end, float gravity); + +float sd_offset_add(weight* weights, size_t mask, feature* begin, feature* end, size_t offset); +void sd_offset_update(weight* weights, size_t mask, feature* begin, feature* end, size_t offset, float update, float regularization); + +void quadratic(v_array<feature> &f, const v_array<feature> &first_part, + const v_array<feature> &second_part, size_t thread_mask); + +float one_of_quad_predict(v_array<feature> &page_features, feature& offer_feature, weight* weights, size_t mask); + +float one_pf_quad_predict(weight* weights, feature& page_feature, v_array<feature> &offer_features, size_t mask); + +float one_pf_quad_predict_trunc(weight* weights, feature& f, v_array<feature> &cross_features, size_t mask, float gravity); + +float offset_quad_predict(weight* weights, feature& page_feature, v_array<feature> &offer_features, size_t mask, size_t offset); + +void print_audit_quad(weight* weights, audit_data& page_feature, v_array<audit_data> &offer_features, size_t mask); +void print_quad(weight* weights, feature& page_feature, v_array<feature> &offer_features, size_t mask); + +float single_quad_weight(weight* weights, feature& page_feature, feature* offer_feature, size_t mask); + +#endif |