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

com.expleague.ml.models.QuadraticModel Maven / Gradle / Ivy

There is a newer version: 1.4.9
Show newest version
package com.expleague.ml.models;

import com.expleague.commons.math.vectors.Mx;
import com.expleague.commons.math.vectors.MxTools;
import com.expleague.commons.math.vectors.VecTools;
import com.expleague.commons.math.vectors.Vec;
import com.expleague.commons.math.Func;

public class QuadraticModel extends Func.Stub {
  private final Mx M;
  private final Vec b;
  private final double c;

  public QuadraticModel(final Mx m, final Vec b, final double c) {
    M = m;
    this.b = b;
    this.c = c;
  }

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

  @Override
  public double value(final Vec x) {
    return VecTools.multiply(x, MxTools.multiply(M, x)) + VecTools.multiply(x, b) + c;
  }

  @Override
  public String toString() {
    return M.toString() + "\n" + b.toString() + "\n" + c;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy