Various fixes and enhancements:
[measurements/measurements.git] / src / net / mattmccutchen / measurements / MeasurementsAddIn.java
index 5f56dec..0c02f46 100644 (file)
@@ -42,9 +42,17 @@ public class MeasurementsAddIn extends AddInBase<AddInHelper>
                        new FunctionInfo("mpowint", "mpowint", "Raises a measurement to an integer power.",
                                Arrays.asList(new ArgumentInfo("base", "Base"),
                                        new ArgumentInfo("exp", "Exponent"))),
+                       new FunctionInfo("mrootint", "mrootint", "Takes an integer square root of a measurement.  Does not allow fractional powers of units in the result.",
+                               Arrays.asList(new ArgumentInfo("base", "Base"),
+                                       new ArgumentInfo("exp", "Exponent"))),
                        new FunctionInfo("mpow", "mpow", "Raises one measurement to the power of another.  Both must be pure numbers.",
                                Arrays.asList(new ArgumentInfo("base", "Base"),
                                        new ArgumentInfo("exp", "Exponent"))),
+                       new FunctionInfo("mexp", "mexp", "Raises e (2.718...) to the power of a measurement.",
+                               Arrays.asList(new ArgumentInfo("m", "Measurement"))),
+                       new FunctionInfo("mln", "mln", "Takes the natural logarithm of a measurement.  " +
+                               "The measurement must be a pure number, so you may have to rewrite a difference of logarithms as a logarithm of a quotient.",
+                               Arrays.asList(new ArgumentInfo("m", "Measurement"))),
                        new FunctionInfo("mcmp", "mcmp",
                                "Returns the difference between two measurements, expressed in units of the sum of their uncertainties.  " +
                                "You can compare measurements very flexibly by checking the result against a tolerance.",
@@ -100,10 +108,23 @@ public class MeasurementsAddIn extends AddInBase<AddInHelper>
                return Measurement.format(MeasurementMath.powint(
                        Measurement.parseCode(a), b), true);
        }
+       public String mrootint(String a, String bstr) {
+               int b = Integer.parseInt(bstr);
+               return Measurement.format(MeasurementMath.rootint(
+                       Measurement.parseCode(a), b), true);
+       }
        public String mpow(String a, String b) {
                return Measurement.format(MeasurementMath.pow(
                        Measurement.parseCode(a), Measurement.parseCode(b)), true);
        }
+       public String mexp(String m) {
+               return Measurement.format(MeasurementMath.exp(
+                       Measurement.parseCode(m)), true);
+       }
+       public String mln(String m) {
+               return Measurement.format(MeasurementMath.ln(
+                       Measurement.parseCode(m)), true);
+       }
        public double mcmp(String a, String b) {
                return MeasurementMath.cmp(
                        Measurement.parseCode(a), Measurement.parseCode(b));