All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.expleague.ml.func.generic.WSum Maven / Gradle / Ivy

package com.expleague.ml.func.generic;

import com.expleague.commons.math.vectors.Vec;
import com.expleague.commons.math.vectors.VecTools;
import com.expleague.commons.math.FuncC1;

/**
* User: solar
* Date: 26.05.15
* Time: 11:45
*/
public class WSum extends FuncC1.Stub {
  public final Vec weights;

  public WSum(Vec weights) {
    this.weights = weights;
  }

  @Override
  public Vec gradientTo(Vec x, Vec to) {
    VecTools.assign(to, weights);
    return to;
  }

  @Override
  public double value(Vec x) {
    return VecTools.multiply(weights, x);
  }

  @Override
  public int dim() {
    return weights.length();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy