commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1185184 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/function/Log10.java
Date Mon, 17 Oct 2011 14:05:53 GMT
Author: erans
Date: Mon Oct 17 14:05:53 2011
New Revision: 1185184

URL: http://svn.apache.org/viewvc?rev=1185184&view=rev
Log:
Added "derivative".

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/function/Log10.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/function/Log10.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/function/Log10.java?rev=1185184&r1=1185183&r2=1185184&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/function/Log10.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/function/Log10.java
Mon Oct 17 14:05:53 2011
@@ -18,6 +18,7 @@
 package org.apache.commons.math.analysis.function;
 
 import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
 import org.apache.commons.math.util.FastMath;
 
 /**
@@ -26,9 +27,22 @@ import org.apache.commons.math.util.Fast
  * @version $Id$
  * @since 3.0
  */
-public class Log10 implements UnivariateRealFunction {
+public class Log10 implements DifferentiableUnivariateRealFunction {
+    /** ln(10) = {@value}.*/
+    private static final double LN_10 = FastMath.log(10);
+
     /** {@inheritDoc} */
     public double value(double x) {
         return FastMath.log10(x);
     }
+
+    /** {@inheritDoc} */
+    public UnivariateRealFunction derivative() {
+        return new UnivariateRealFunction() {
+            /** {@inheritDoc} */
+            public double value(double x) {
+                return 1 / (x * LN_10);
+            }
+        };
+    }
 }



Mime
View raw message