Please use BLAS for this kind of stuff, it's already included in this file.

    cblas_dnrm2(n_features, &w[0], 1)

This is more stable and probably faster.