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

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

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

import org.jetbrains.annotations.NotNull;

/**
 * a * x^b
 * User: solar
 * Date: 29.06.15
 * Time: 16:48
 */
public class Pow extends ElementaryFunc {
  private final double a;
  private final double b;

  public Pow(double a, double b) {
    this.a = a;
    this.b = b;
  }

  @Override
  public double value(double x) {
    return a * Math.pow(x, b);
  }

  @NotNull
  @Override
  public ElementaryFunc gradient() {
    if (b == 1)
      return new Const(a);
    return new Pow(a * b, b - 1);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy