      }
    }

    template <typename T>
    T sign(T x) { return (x == .0 ? .0 : (x < .0 ? -1.0 : 1.0)); }

    void GpgpuSneRaster::updateEmbedding(embedding_type* embedding, float exaggeration, float iteration, float mult) {
      for (int i = 0; i < _gradient.size(); ++i) {
        _gain[i] = static_cast<float>((sign(_gradient[i]) != sign(_previous_gradient[i])) ? (_gain[i] + .2) : (_gain[i] * .8));
        if (_gain[i] < _params._minimum_gain) {
          _gain[i] = static_cast<float>(_params._minimum_gain);
        }