Skip to content

Commit

Permalink
Merge pull request #101 from koosvary/featre/enableAll
Browse files Browse the repository at this point in the history
Featre/enable all
  • Loading branch information
JasbirShah authored Oct 31, 2018
2 parents 5fadc65 + a0b9b87 commit 61a7452
Show file tree
Hide file tree
Showing 46 changed files with 84 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class AbsoluteValue extends ArithmeticPrimitive<Number> {
public AbsoluteValue() {
super(
args -> Math.abs(args.get(0)),
1, "ABS", "Returns the positive value of a.", 4
1, "ABS", "Returns the positive value of a."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Addition extends ArithmeticPrimitive<Number> {
public Addition() {
super(
args -> args.stream().mapToDouble(Number::doubleValue).sum(),
2, "ADD", "Returns a + b.", 1
2, "ADD", "Returns a + b."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class And extends ArithmeticPrimitive<Number> {
public And() {
super(
args -> (args.get(0) > 0 && args.get(1) > 0) ? 1.d : 0.d,
2, "AND", "Returns 1 if both a and b are greater than 0, 0 otherwise.", 4
2, "AND", "Returns 1 if both a and b are greater than 0, 0 otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ArcCos extends ArithmeticPrimitive<Number> {
public ArcCos() {
super(
args -> Math.acos(args.get(0)),
1, "ACOS", "Returns the inverse cosine function of a.", 4
1, "ACOS", "Returns the inverse cosine function of a."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ArcSin extends ArithmeticPrimitive<Number> {
public ArcSin() {
super(
args -> Math.asin(args.get(0)),
1, "ASIN", "Returns the inverse sine function of a.", 4
1, "ASIN", "Returns the inverse sine function of a."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ArcTan extends ArithmeticPrimitive<Number> {
public ArcTan() {
super(
args -> Math.atan(args.get(0)),
1, "ATAN", "Returns the inverse single argument tangent function of a.", 4
1, "ATAN", "Returns the inverse single argument tangent function of a."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ public class ArithmeticPrimitive<T extends Number> extends FunctionalPrimitive<D
public ArithmeticPrimitive(final Function<List<Double>, Double> lambda, final int arity, final String symbol, final String description, final Integer defaultComplexity) {
super(lambda, arity, symbol, description, defaultComplexity);
}

public ArithmeticPrimitive(final Function<List<Double>, Double> lambda, final int arity, final String symbol, final String description) {
super(lambda, arity, symbol, description);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Ceiling extends ArithmeticPrimitive<Number> {
public Ceiling() {
super(
args -> Math.ceil(args.get(0)),
1, "CEIL", "Returns the integer of a rounded up.", 4
1, "CEIL", "Returns the integer of a rounded up."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

public class Constant<T> extends FunctionalPrimitive<T, T> {
public Constant(final T value) {
super(args -> value, 0, value.toString(), "A constant value.", 1);
super(args -> value, 0, value.toString(), "A constant value.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Cos extends ArithmeticPrimitive<Number> {
public Cos() {
super(
args -> Math.cos(args.get(0)),
1, "COS", "Returns the cosine of a.", 3
1, "COS", "Returns the cosine of a."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Division() {

return identity;
},
2, "DIV", "Returns the division of a / b.", 2
2, "DIV", "Returns the division of a / b."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class EqualTo extends ArithmeticPrimitive<Number> {
public EqualTo() {
super(
args -> args.get(0).equals(args.get(1)) ? 1.d : 0.d,
2, "EQUAL", "Returns 1 if a is equal to b, 0 otherwise.", 4
2, "EQUAL", "Returns 1 if a is equal to b, 0 otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Exponential extends ArithmeticPrimitive<Number> {
public Exponential() {
super(
args -> Math.exp(args.get(0)),
1, "EXP", "Returns e^a.", 4
1, "EXP", "Returns e^a."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Floor extends ArithmeticPrimitive<Number> {
public Floor() {
super(
args -> Math.floor(args.get(0)),
1, "FLOOR", "Returns the integer of a rounded down.", 4
1, "FLOOR", "Returns the integer of a rounded down."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ public FunctionalPrimitive(Function<List<T>, R> lambda, int arity, String symbol
this.complexity = new SimpleIntegerProperty(defaultComplexity);
}

public FunctionalPrimitive(Function<List<T>, R> lambda, int arity, String symbol, String description) {
this.lambda = lambda;
this.arity = arity;
this.symbol = symbol;
this.description = description;
this.defaultComplexity = 1;
this.complexity = new SimpleIntegerProperty(this.defaultComplexity);
}

@Override
public R apply(List<T> args) {
assert (args.size() >= getArity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class GaussianFunction extends ArithmeticPrimitive<Number> {
public GaussianFunction() {
super(
args -> Math.exp(-Math.pow(args.get(0),2)),
1, "GAUSS", "Returns exp(-x^2), providing a normal distribution.", 4
1, "GAUSS", "Returns exp(-x^2), providing a normal distribution."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class GreaterThan extends ArithmeticPrimitive<Number> {
public GreaterThan() {
super(
args -> args.get(0) > args.get(1) ? 1.d : 0.d,
2, "GREATER", "Returns 1 if a > b, 0 otherwise.", 4
2, "GREATER", "Returns 1 if a > b, 0 otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class GreaterThanOrEqual extends ArithmeticPrimitive<Number> {
public GreaterThanOrEqual() {
super(
args -> args.get(0) >= args.get(1) ? 1.d : 0.d,
2, "GREATER_EQUAL", "Returns 1 if a >= b, 0 otherwise.", 4
2, "GREATER_EQUAL", "Returns 1 if a >= b, 0 otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class IfThenElse extends ArithmeticPrimitive<Number> {
public IfThenElse() {
super(
args -> args.get(0) > 0 ? args.get(1) : args.get(2),
3, "IF", "Returns returns b if a > 0, c otherwise.", 5
3, "IF", "Returns returns b if a > 0, c otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class LessThan extends ArithmeticPrimitive<Number> {
public LessThan() {
super(
args -> args.get(0) < args.get(1) ? 1.d : 0.d,
2, "LESS", "Returns 1 if a < b, 0 otherwise.", 4
2, "LESS", "Returns 1 if a < b, 0 otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class LessThanOrEqual extends ArithmeticPrimitive<Number> {
public LessThanOrEqual() {
super(
args -> args.get(0) <= args.get(1) ? 1.d : 0.d,
2, "LESSEQUAL", "Returns 1 if a <= b, 0 otherwise.", 4
2, "LESSEQUAL", "Returns 1 if a <= b, 0 otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class LogisticFunction extends ArithmeticPrimitive<Number> {
public LogisticFunction() {
super(
args -> 1/(1+Math.exp(args.get(0))),
1, "LOGISTIC", "Returns (1 / 1 + exp(-a)).\nThis is a common sigmoid squashing function.", 4
1, "LOGISTIC", "Returns (1 / 1 + exp(-a)).\nThis is a common sigmoid squashing function."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Maximum extends ArithmeticPrimitive<Number> {
public Maximum() {
super(
args -> Math.max(args.get(0),args.get(1)),
2, "MAX", "Returns the maximum value of a and b.", 4
2, "MAX", "Returns the maximum value of a and b."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Minimum extends ArithmeticPrimitive<Number> {
public Minimum() {
super(
args -> Math.min(args.get(0),args.get(1)),
2, "MIN", "Returns the minimum value of a and b.", 4
2, "MIN", "Returns the minimum value of a and b."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Modulo extends ArithmeticPrimitive<Number> {
public Modulo() {
super(
args -> args.get(0) % args.get(1),
2, "MOD", "Returns the remainder of a / b.", 4
2, "MOD", "Returns the remainder of a / b."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Multiplication extends ArithmeticPrimitive<Number> {
public Multiplication() {
super(
args -> args.stream().reduce(1.d, (a, b) -> a * b),
2, "MUL", "Returns a * b.", 1
2, "MUL", "Returns a * b."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class NaturalLog extends ArithmeticPrimitive<Number> {
public NaturalLog() {
super(
args -> Math.log(args.get(0)),
1, "LN", "Returns the natural logarithm (base e) of a.", 4
1, "LN", "Returns the natural logarithm (base e) of a."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Negation extends ArithmeticPrimitive<Number> {
public Negation() {
super(
args -> -args.get(0),
1, "NEG", "Returns - a.", 1
1, "NEG", "Returns - a."
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Not extends ArithmeticPrimitive<Number> {
public Not() {
super(
args -> (args.get(0) > 0) ? 0.d : 1.d,
1, "NOT", "Returns 0 if a is greater than 0, 1 otherwise.", 4
1, "NOT", "Returns 0 if a is greater than 0, 1 otherwise."
);
}
}
2 changes: 1 addition & 1 deletion api/src/main/java/org/iconic/ea/operator/primitive/Or.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Or extends ArithmeticPrimitive<Number> {
public Or() {
super(
args -> (args.get(0) > 0 || args.get(1) > 0) ? 1.d : 0.d,
2, "OR", "Returns 1 if either a or b are greater than 0, 0 otherwise.", 4
2, "OR", "Returns 1 if either a or b are greater than 0, 0 otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Power extends ArithmeticPrimitive<Number> {
public Power() {
super(
args -> Math.pow(args.get(0), args.get(1)),
2, "POW", "Returns a^b.", 5
2, "POW", "Returns a^b."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Root() {
}
return Double.NaN;
},
2, "ROOT", "Returns the b-th root of a if a is greater than 0, NaN otherwise.", 5
2, "ROOT", "Returns the b-th root of a if a is greater than 0, NaN otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SignFunction extends ArithmeticPrimitive<Number> {
public SignFunction() {
super(
args -> Math.signum(args.get(0)),
1, "SGN", "Returns -1 if a is negative, 1 if a is positive, 0 otherwise.", 4
1, "SGN", "Returns -1 if a is negative, 1 if a is positive, 0 otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Sin extends ArithmeticPrimitive<Number> {
public Sin() {
super(
args -> Math.sin(args.get(0)),
1, "SIN","Returns the sine of a.", 3
1, "SIN","Returns the sine of a."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SquareRoot extends ArithmeticPrimitive<Number> {
public SquareRoot() {
super(
args -> Math.sqrt(args.get(0)),
1, "SQRT","Returns the square root of a.", 4
1, "SQRT","Returns the square root of a."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class StepFunction extends ArithmeticPrimitive<Number> {
public StepFunction() {
super(
args -> args.get(0) > 0 ? 1.d : 0.d,
1, "STEP","Returns 1 if x is positive, 0 otherwise.", 4
1, "STEP","Returns 1 if x is positive, 0 otherwise."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public Subtraction() {

return identity;
},
2, "SUB", "Returns a - b.", 1
2, "SUB", "Returns a - b."
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Tan extends ArithmeticPrimitive<Number> {
public Tan() {
super(
args -> Math.tan(args.get(0)),
1, "TAN","Returns the tangent of a.", 4
1, "TAN","Returns the tangent of a."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Tanh extends ArithmeticPrimitive<Number> {
public Tanh() {
super(
args -> Math.tanh(args.get(0)),
1, "TANH","Returns the hyperbolic tangent of a.\nThis is a common squashing function returning a value between -1 and 1.", 4
1, "TANH","Returns the hyperbolic tangent of a.\nThis is a common squashing function returning a value between -1 and 1."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class TwoArcTan extends ArithmeticPrimitive<Number> {
public TwoArcTan() {
super(
args -> Math.atan2(args.get(0),args.get(1)),
2, "ATAN2","Returns the two argument inverse tangent function.", 4
2, "ATAN2","Returns the two argument inverse tangent function."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Xor extends ArithmeticPrimitive<Number> {
public Xor() {
super(
args -> (args.get(0) > 0 ^ args.get(1) > 0) ? 1.d : 0.d,
2, "XOR","Returns 1 if (a <= 0 and b > 0) or (a > 0 and b <= 0), 0 otherwise.", 4
2, "XOR","Returns 1 if (a <= 0 and b > 0) or (a > 0 and b <= 0), 0 otherwise."
);
}
}
Loading

0 comments on commit 61a7452

Please sign in to comment.