package scotch.data.floating;
import static java.util.Arrays.asList;
import static scotch.runtime.RuntimeSupport.callable;
import java.util.List;
import scotch.data.double_.Double_;
import scotch.data.fractional.Fractional;
import scotch.data.num.Num;
import scotch.runtime.Callable;
import scotch.symbol.InstanceGetter;
import scotch.symbol.TypeInstance;
import scotch.symbol.TypeParameters;
import scotch.symbol.type.TypeDescriptor;
@SuppressWarnings("unused")
@TypeInstance(typeClass = "scotch.data.floating.Floating")
public class FloatingDouble implements Floating<Double> {
private static final Callable<FloatingDouble> INSTANCE = callable(FloatingDouble::new);
@InstanceGetter
public static Callable<FloatingDouble> instance() {
return INSTANCE;
}
@TypeParameters
public static List<TypeDescriptor> parameters() {
return asList(Double_.TYPE);
}
private FloatingDouble() {
// intentionally empty
}
@Override
public Callable<Double> pow(Callable<Fractional<Double>> fractional, Callable<Num<Double>> num, Callable<Double> left, Callable<Double> right) {
return callable(() -> Math.pow(left.call(), right.call()));
}
@Override
public Callable<Double> sqrt(Callable<Fractional<Double>> fractional, Callable<Num<Double>> num, Callable<Double> operand) {
return callable(() -> Math.sqrt(operand.call()));
}
}