org.ojalgo.function.QuaternionFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ojalgo Show documentation
Show all versions of ojalgo Show documentation
oj! Algorithms - ojAlgo - is Open Source Java code that has to do with mathematics, linear algebra and optimisation.
/*
* Copyright 1997-2024 Optimatika
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.ojalgo.function;
import org.ojalgo.function.aggregator.AggregatorSet;
import org.ojalgo.function.aggregator.QuaternionAggregator;
import org.ojalgo.function.constant.QuaternionMath;
import org.ojalgo.scalar.Quaternion;
import org.ojalgo.type.context.NumberContext;
public final class QuaternionFunction extends FunctionSet {
@FunctionalInterface
public interface Binary extends BinaryFunction {
default double invoke(final double arg1, final double arg2) {
return this.invoke(Quaternion.valueOf(arg1), Quaternion.valueOf(arg2)).doubleValue();
}
default float invoke(final float arg1, final float arg2) {
return this.invoke(Quaternion.valueOf(arg1), Quaternion.valueOf(arg2)).floatValue();
}
default Quaternion invoke(final Quaternion arg1, final double arg2) {
return this.invoke(arg1, Quaternion.valueOf(arg2));
}
}
@FunctionalInterface
public interface Consumer extends VoidFunction {
default void invoke(final double arg) {
this.invoke(Quaternion.valueOf(arg));
}
default void invoke(final float arg) {
this.invoke(Quaternion.valueOf(arg));
}
}
@FunctionalInterface
public interface Nullary extends NullaryFunction {
default double doubleValue() {
return this.invoke().doubleValue();
}
}
@FunctionalInterface
public interface Parameter extends ParameterFunction {
default double invoke(final double arg, final int param) {
return this.invoke(Quaternion.valueOf(arg), param).doubleValue();
}
default float invoke(final float arg, final int param) {
return this.invoke(Quaternion.valueOf(arg), param).floatValue();
}
}
@FunctionalInterface
public interface Predicate extends PredicateFunction {
default boolean invoke(final double arg) {
return this.invoke(Quaternion.valueOf(arg));
}
default boolean invoke(final float arg) {
return this.invoke(Quaternion.valueOf(arg));
}
}
@FunctionalInterface
public interface Unary extends UnaryFunction {
default double invoke(final double arg) {
return this.invoke(Quaternion.valueOf(arg)).doubleValue();
}
default float invoke(final float arg) {
return this.invoke(Quaternion.valueOf(arg)).floatValue();
}
}
private static final QuaternionFunction SET = new QuaternionFunction();
public static QuaternionFunction getSet() {
return SET;
}
public static Nullary nullary(final Quaternion value) {
return () -> value;
}
private QuaternionFunction() {
super();
}
@Override
public UnaryFunction abs() {
return QuaternionMath.ABS;
}
@Override
public UnaryFunction acos() {
return QuaternionMath.ACOS;
}
@Override
public UnaryFunction acosh() {
return QuaternionMath.ACOSH;
}
@Override
public BinaryFunction add() {
return QuaternionMath.ADD;
}
@Override
public AggregatorSet aggregator() {
return QuaternionAggregator.getSet();
}
@Override
public UnaryFunction asin() {
return QuaternionMath.ASIN;
}
@Override
public UnaryFunction asinh() {
return QuaternionMath.ASINH;
}
@Override
public UnaryFunction atan() {
return QuaternionMath.ATAN;
}
@Override
public BinaryFunction atan2() {
return QuaternionMath.ATAN2;
}
@Override
public UnaryFunction atanh() {
return QuaternionMath.ATANH;
}
@Override
public UnaryFunction cardinality() {
return QuaternionMath.CARDINALITY;
}
@Override
public UnaryFunction cbrt() {
return QuaternionMath.CBRT;
}
@Override
public UnaryFunction ceil() {
return QuaternionMath.CEIL;
}
@Override
public UnaryFunction conjugate() {
return QuaternionMath.CONJUGATE;
}
@Override
public UnaryFunction cos() {
return QuaternionMath.COS;
}
@Override
public UnaryFunction cosh() {
return QuaternionMath.COSH;
}
@Override
public BinaryFunction divide() {
return QuaternionMath.DIVIDE;
}
@Override
public Unary enforce(final NumberContext context) {
return t -> Quaternion.valueOf(context.enforce(t));
}
@Override
public UnaryFunction exp() {
return QuaternionMath.EXP;
}
@Override
public UnaryFunction expm1() {
return QuaternionMath.EXPM1;
}
@Override
public UnaryFunction floor() {
return QuaternionMath.FLOOR;
}
@Override
public BinaryFunction hypot() {
return QuaternionMath.HYPOT;
}
@Override
public UnaryFunction invert() {
return QuaternionMath.INVERT;
}
@Override
public UnaryFunction log() {
return QuaternionMath.LOG;
}
@Override
public UnaryFunction log10() {
return QuaternionMath.LOG10;
}
@Override
public UnaryFunction log1p() {
return QuaternionMath.LOG1P;
}
@Override
public UnaryFunction logistic() {
return QuaternionMath.LOGISTIC;
}
@Override
public UnaryFunction logit() {
return QuaternionMath.LOGIT;
}
@Override
public BinaryFunction max() {
return QuaternionMath.MAX;
}
@Override
public BinaryFunction min() {
return QuaternionMath.MIN;
}
@Override
public BinaryFunction multiply() {
return QuaternionMath.MULTIPLY;
}
@Override
public UnaryFunction negate() {
return QuaternionMath.NEGATE;
}
@Override
public BinaryFunction pow() {
return QuaternionMath.POW;
}
@Override
public ParameterFunction power() {
return QuaternionMath.POWER;
}
@Override
public UnaryFunction rint() {
return QuaternionMath.RINT;
}
@Override
public ParameterFunction root() {
return QuaternionMath.ROOT;
}
@Override
public ParameterFunction scale() {
return QuaternionMath.SCALE;
}
@Override
public UnaryFunction signum() {
return QuaternionMath.SIGNUM;
}
@Override
public UnaryFunction sin() {
return QuaternionMath.SIN;
}
@Override
public UnaryFunction sinh() {
return QuaternionMath.SINH;
}
@Override
public UnaryFunction sqrt() {
return QuaternionMath.SQRT;
}
@Override
public UnaryFunction sqrt1px2() {
return QuaternionMath.SQRT1PX2;
}
@Override
public BinaryFunction subtract() {
return QuaternionMath.SUBTRACT;
}
@Override
public UnaryFunction tan() {
return QuaternionMath.TAN;
}
@Override
public UnaryFunction tanh() {
return QuaternionMath.TANH;
}
@Override
public UnaryFunction value() {
return QuaternionMath.VALUE;
}
}