diff options
author | John Langford <jl@hunch.net> | 2013-04-04 20:35:44 +0400 |
---|---|---|
committer | John Langford <jl@hunch.net> | 2013-04-04 20:35:44 +0400 |
commit | 39b8e97dacdc2332a58863178fa4f8cefeeedb04 (patch) | |
tree | 4d8cc5d71653cac88c986f167557d9da1ef7798a /vowpalwabbit/sparse_dense.h | |
parent | 30da4ec6fcb3a8e379a25ef941b70c98526b2661 (diff) |
remove feature loops in bfgs.cc
Diffstat (limited to 'vowpalwabbit/sparse_dense.h')
-rw-r--r-- | vowpalwabbit/sparse_dense.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/vowpalwabbit/sparse_dense.h b/vowpalwabbit/sparse_dense.h index 4f193c65..d175f0ef 100644 --- a/vowpalwabbit/sparse_dense.h +++ b/vowpalwabbit/sparse_dense.h @@ -40,15 +40,15 @@ float one_pf_cubic_predict(vw& all, feature& f0, feature& f1, v_array<feature> c return sd_add<T>(all, cross_features.begin, cross_features.end, halfhash + offset, mult); } -inline float vec_add(vw& all, float fx, uint32_t fi) { - return all.reg.weight_vector[fi & all.reg.weight_mask] * fx; +inline void vec_add(vw& all, void* p, float fx, uint32_t fi) { + *(float*)p += all.reg.weight_vector[fi & all.reg.weight_mask] * fx; } -inline float vec_add_trunc(vw& all, float fx, uint32_t fi) { - return trunc_weight(all.reg.weight_vector[fi & all.reg.weight_mask], (float)all.sd->gravity) * fx; +inline void vec_add_trunc(vw& all, void* p, float fx, uint32_t fi) { + *(float*)p += trunc_weight(all.reg.weight_vector[fi & all.reg.weight_mask], (float)all.sd->gravity) * fx; } -inline float vec_add_rescale(vw& all, float fx, uint32_t fi) { +inline void vec_add_rescale(vw& all, void* p, float fx, uint32_t fi) { weight* w = &all.reg.weight_vector[fi & all.reg.weight_mask]; float x_abs = fabs(fx); if( x_abs > w[all.normalized_idx] ) {// new scale discovered @@ -58,10 +58,10 @@ inline float vec_add_rescale(vw& all, float fx, uint32_t fi) { } w[all.normalized_idx] = x_abs; } - return w[0] * fx; + *(float*)p += w[0] * fx; } -inline float vec_add_trunc_rescale(vw& all, float fx, uint32_t fi) { +inline void vec_add_trunc_rescale(vw& all, void* p, float fx, uint32_t fi) { weight* w = &all.reg.weight_vector[fi & all.reg.weight_mask]; float x_abs = fabs(fx); if( x_abs > w[all.normalized_idx] ) { @@ -71,10 +71,10 @@ inline float vec_add_trunc_rescale(vw& all, float fx, uint32_t fi) { } w[all.normalized_idx] = x_abs; } - return trunc_weight(w[0], (float)all.sd->gravity) * fx; + *(float*)p += trunc_weight(w[0], (float)all.sd->gravity) * fx; } -inline float vec_add_rescale_general(vw& all, float fx, uint32_t fi) { +inline void vec_add_rescale_general(vw& all, void* p, float fx, uint32_t fi) { weight* w = &all.reg.weight_vector[fi & all.reg.weight_mask]; float x_abs = fabs(fx); float power_t_norm = 1.f - (all.adaptive ? all.power_t : 0.f); @@ -85,10 +85,10 @@ inline float vec_add_rescale_general(vw& all, float fx, uint32_t fi) { } w[all.normalized_idx] = x_abs; } - return w[0] * fx; + *(float*)p += w[0] * fx; } -inline float vec_add_trunc_rescale_general(vw& all, float fx, uint32_t fi) { +inline void vec_add_trunc_rescale_general(vw& all, void* p, float fx, uint32_t fi) { weight* w = &all.reg.weight_vector[fi & all.reg.weight_mask]; float x_abs = fabs(fx); float power_t_norm = 1.f - (all.adaptive ? all.power_t : 0.f); @@ -99,7 +99,7 @@ inline float vec_add_trunc_rescale_general(vw& all, float fx, uint32_t fi) { } w[all.normalized_idx] = x_abs; } - return trunc_weight(w[0], (float)all.sd->gravity) * fx; + *(float*)p += trunc_weight(w[0], (float)all.sd->gravity) * fx; } ///////////////////////////////////////////////////////////////////////////////////////////// |