From 5857e3f0a5af21e344fc42c5b8395044b062c6ef Mon Sep 17 00:00:00 2001 From: Arthur Drobot Date: Thu, 3 Aug 2017 09:52:56 -0700 Subject: [PATCH] Add cos. --- .../org/nwapw/abacus/plugin/StandardPlugin.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java index c916c7c..a394c4b 100755 --- a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java +++ b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java @@ -308,6 +308,19 @@ public class StandardPlugin extends Plugin { } }; + public static final Function FUNCTION_COS = new Function() { + @Override + protected boolean matchesParams(NumberInterface[] params) { + return params.length == 1; + } + + @Override + protected NumberInterface applyInternal(NumberInterface[] params) { + return FUNCTION_SIN.apply(getPi(params[0].getClass()).divide(new NaiveNumber(2).promoteTo(params[0].getClass())) + .subtract(params[0])); + } + }; + public StandardPlugin(PluginManager manager) { super(manager); } @@ -355,6 +368,7 @@ public class StandardPlugin extends Plugin { registerFunction("ln", FUNCTION_LN); registerFunction("sqrt", FUNCTION_SQRT); registerFunction("sin", FUNCTION_SIN); + registerFunction("cos", FUNCTION_COS); } @Override