diff --git a/src/experimental/org/apache/commons/math/analysis/DerivativeOperatorFactory.java b/src/experimental/org/apache/commons/math/analysis/DerivativeOperatorFactory.java new file mode 100644 index 000000000..018058cbb --- /dev/null +++ b/src/experimental/org/apache/commons/math/analysis/DerivativeOperatorFactory.java @@ -0,0 +1,24 @@ +/* + * Created on Nov 19, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.apache.commons.math.analysis; + +public class DerivativeOperatorFactory { + + public static DerivativeOperatorFactory newInstance() { + return null; + } + + public FunctionOperator getDefaultDerivativeOperator() { + return null; + } + + public FunctionOperator getCenteredDifferenceDerivativeOperator(){ + return null; + } + + // and so on for other implementations of numerical deriv's +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/analysis/DerivativeOperatorFactoryTest.java b/src/experimental/org/apache/commons/math/analysis/DerivativeOperatorFactoryTest.java new file mode 100644 index 000000000..24e6da935 --- /dev/null +++ b/src/experimental/org/apache/commons/math/analysis/DerivativeOperatorFactoryTest.java @@ -0,0 +1,36 @@ +/* + * Created on Nov 19, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.apache.commons.math.analysis; + +import junit.framework.TestCase; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class DerivativeOperatorFactoryTest extends TestCase { + + /** + * Constructor for DerivativeOperatorFactoryTest. + * @param arg0 + */ + public DerivativeOperatorFactoryTest(String arg0) { + super(arg0); + } + + //UnivariateRealFunction f = new SomeUserDefinedFunction(); + //FunctionOperator derivative = + // DerivativeOperatorFactory.newInstance().getDefaultDerivativeOperator(); + + //UnivariateRealFunction g = derivative.evaluate( f ); + + // to obtain the value of f'(0.0) use + //double fprime_at_0 = g.value( 0.0 ); + +} diff --git a/src/experimental/org/apache/commons/math/analysis/FunctionOperator.java b/src/experimental/org/apache/commons/math/analysis/FunctionOperator.java new file mode 100644 index 000000000..6907a8e86 --- /dev/null +++ b/src/experimental/org/apache/commons/math/analysis/FunctionOperator.java @@ -0,0 +1,23 @@ +/* + * Created on Nov 19, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.apache.commons.math.analysis; + +import org.apache.commons.math.MathException; + +public interface FunctionOperator { + + + /** + * Evaluate the Function Operator for a given real single variable function. + * + * @param f the function which should be evaluated + * @return the resultant function + * @throws MathException if the function couldn't be evaluated + */ + public UnivariateRealFunction evaluate(UnivariateRealFunction f) throws MathException; + +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/Compilable.java b/src/experimental/org/apache/commons/math/function/Compilable.java new file mode 100644 index 000000000..e3771d971 --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/Compilable.java @@ -0,0 +1,67 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public interface Compilable { + + public abstract Evaluation compile(EvaluationContext context) + throws EvaluationException; + +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/DefaultContext.java b/src/experimental/org/apache/commons/math/function/DefaultContext.java new file mode 100644 index 000000000..94a57f01b --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/DefaultContext.java @@ -0,0 +1,257 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class DefaultContext implements EvaluationContext { + + /** + * + */ + public DefaultContext() { + super(); + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#doubleValue(org.apache.archimedes.Evaluation) + */ + public double doubleValue(Evaluation argument) throws EvaluationException { + // TODO Auto-generated method stub + return ((DefaultValue)argument.evaluate(this)).doubleValue(); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#floatValue(org.apache.archimedes.Evaluation) + */ + public float floatValue(Evaluation argument) throws EvaluationException { + // TODO Auto-generated method stub + return ((DefaultValue)argument.evaluate(this)).floatValue(); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#intValue(org.apache.archimedes.Evaluation) + */ + public int intValue(Evaluation argument) throws EvaluationException { + // TODO Auto-generated method stub + return ((DefaultValue)argument.evaluate(this)).intValue(); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#longValue(org.apache.archimedes.Evaluation) + */ + public long longValue(Evaluation argument) throws EvaluationException { + // TODO Auto-generated method stub + return ((DefaultValue)argument.evaluate(this)).longValue(); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#shortValue(org.apache.archimedes.Evaluation) + */ + public short shortValue(Evaluation argument) throws EvaluationException { + // TODO Auto-generated method stub + return ((DefaultValue)argument.evaluate(this)).shortValue(); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#byteValue(org.apache.archimedes.Evaluation) + */ + public byte byteValue(Evaluation argument) throws EvaluationException { + // TODO Auto-generated method stub + return ((DefaultValue)argument.evaluate(this)).byteValue(); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#evaluate(double) + */ + public Evaluation evaluate(double d) { + // TODO Auto-generated method stub + return new DefaultValue(d); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#evaluate(float) + */ + public Evaluation evaluate(float f) { + // TODO Auto-generated method stub + return new DefaultValue(f); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#evaluate(int) + */ + public Evaluation evaluate(int i) { + // TODO Auto-generated method stub + return new DefaultValue(i); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#evaluate(long) + */ + public Evaluation evaluate(long l) { + // TODO Auto-generated method stub + return new DefaultValue(l); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#evaluate(short) + */ + public Evaluation evaluate(short s) { + // TODO Auto-generated method stub + return new DefaultValue(s); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.EvaluationContext#evaluate(byte) + */ + public Evaluation evaluate(byte b) { + // TODO Auto-generated method stub + return new DefaultValue(b); + } + + public class DefaultValue extends Number implements Evaluation { + + Number value; + + /** + * + */ + DefaultValue() { + super(); + // TODO Auto-generated constructor stub + } + + DefaultValue(Number n) { + value = n; + } + + DefaultValue(double d) { + value = new Double(d); + } + + DefaultValue(float f) { + value = new Float(f); + } + + DefaultValue(int i) { + value = new Integer(i); + } + + DefaultValue(long l) { + value = new Long(l); + } + + /* (non-Javadoc) + * @see org.apache.archimedes.Evaluation#evaluate(org.apache.archimedes.EvaluationContext) + */ + public Evaluation evaluate(EvaluationContext context) + throws EvaluationException { + return this; + } + + /* (non-Javadoc) + * @see java.lang.Number#intValue() + */ + public int intValue() { + // TODO Auto-generated method stub + return value.intValue(); + } + + /* (non-Javadoc) + * @see java.lang.Number#longValue() + */ + public long longValue() { + // TODO Auto-generated method stub + return value.longValue(); + } + + /* (non-Javadoc) + * @see java.lang.Number#floatValue() + */ + public float floatValue() { + // TODO Auto-generated method stub + return value.floatValue(); + } + + /* (non-Javadoc) + * @see java.lang.Number#doubleValue() + */ + public double doubleValue() { + // TODO Auto-generated method stub + return value.doubleValue(); + } + + /* (non-Javadoc) + * @see java.lang.Number#byteValue() + */ + public byte byteValue() { + // TODO Auto-generated method stub + return value.byteValue(); + } + + /* (non-Javadoc) + * @see java.lang.Number#shortValue() + */ + public short shortValue() { + // TODO Auto-generated method stub + return value.shortValue(); + } + + } +} diff --git a/src/experimental/org/apache/commons/math/function/Evaluation.java b/src/experimental/org/apache/commons/math/function/Evaluation.java new file mode 100644 index 000000000..add0ba8fd --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/Evaluation.java @@ -0,0 +1,67 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public interface Evaluation { + + public abstract Evaluation evaluate(EvaluationContext context) + throws EvaluationException; + +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/EvaluationContext.java b/src/experimental/org/apache/commons/math/function/EvaluationContext.java new file mode 100644 index 000000000..d4a51dc92 --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/EvaluationContext.java @@ -0,0 +1,88 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public interface EvaluationContext { + + public abstract double doubleValue(Evaluation argument) throws EvaluationException ; + + public abstract float floatValue(Evaluation argument) throws EvaluationException ; + + public abstract int intValue(Evaluation argument) throws EvaluationException ; + + public abstract long longValue(Evaluation argument) throws EvaluationException ; + + public abstract short shortValue(Evaluation argument) throws EvaluationException ; + + public abstract byte byteValue(Evaluation argument) throws EvaluationException ; + + public abstract Evaluation evaluate(double d); + + public abstract Evaluation evaluate(float f); + + public abstract Evaluation evaluate(int i); + + public abstract Evaluation evaluate(long l); + + public abstract Evaluation evaluate(short s); + + public abstract Evaluation evaluate(byte b); + +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/EvaluationException.java b/src/experimental/org/apache/commons/math/function/EvaluationException.java new file mode 100644 index 000000000..2f89859e0 --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/EvaluationException.java @@ -0,0 +1,97 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class EvaluationException extends Exception { + + /** + * + */ + public EvaluationException() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @param message + */ + public EvaluationException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * @param message + * @param cause + */ + public EvaluationException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + /** + * @param cause + */ + public EvaluationException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/experimental/org/apache/commons/math/function/Variable.java b/src/experimental/org/apache/commons/math/function/Variable.java new file mode 100644 index 000000000..56afbd60a --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/Variable.java @@ -0,0 +1,76 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function; + +import java.io.Serializable; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class Variable implements Evaluation, Serializable { + + public Evaluation evaluate(EvaluationContext context) + throws EvaluationException { + return null; + + //context.evaluate(value.doubleValue()); + } + + public String toString() { + return "Variable"; + } +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/simple/Add.java b/src/experimental/org/apache/commons/math/function/simple/Add.java new file mode 100644 index 000000000..b1fdfe637 --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/simple/Add.java @@ -0,0 +1,94 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function.simple; + +import java.io.Serializable; + +import org.apache.commons.math.function.Compilable; +import org.apache.commons.math.function.Evaluation; +import org.apache.commons.math.function.EvaluationContext; +import org.apache.commons.math.function.EvaluationException; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class Add implements Evaluation, Serializable { + + private Evaluation left; + + private Evaluation right; + + public void setLeftOperand(Evaluation left) { + this.left = left; + } + + public void setRightOperand(Evaluation right) { + this.right = right; + } + + public Evaluation evaluate(EvaluationContext context) throws EvaluationException { + return context.evaluate( + context.doubleValue(left) + context.doubleValue(right) + ); + } + + + public String toString() { + return "Add"; + } + +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/simple/Divide.java b/src/experimental/org/apache/commons/math/function/simple/Divide.java new file mode 100644 index 000000000..3cb9e6888 --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/simple/Divide.java @@ -0,0 +1,93 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function.simple; + +import java.io.Serializable; + +import org.apache.commons.math.function.EvaluationContext; +import org.apache.commons.math.function.Evaluation; +import org.apache.commons.math.function.EvaluationException; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class Divide implements Evaluation, Serializable { + + private Evaluation left; + + private Evaluation right; + + public void setLeftOperand(Evaluation left) { + this.left = left; + } + + public void setRightOperand(Evaluation right) { + this.right = right; + } + + public Evaluation evaluate(EvaluationContext context) throws EvaluationException { + return context.evaluate( + context.doubleValue(left) / context.doubleValue(right) + ); + } + + public String toString() { + return "Divide"; + } + + +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/simple/Equals.java b/src/experimental/org/apache/commons/math/function/simple/Equals.java new file mode 100644 index 000000000..db8ca1743 --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/simple/Equals.java @@ -0,0 +1,91 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function.simple; + +import java.io.Serializable; + +import org.apache.commons.math.function.Evaluation; +import org.apache.commons.math.function.EvaluationContext; + + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class Equals implements Evaluation, Serializable { + + private Evaluation left; + + private Evaluation right; + + public void setLeftOperand(Evaluation left) { + this.left = left; + } + + public void setRightOperand(Evaluation right) { + this.right = right; + } + + public Evaluation evaluate(EvaluationContext context) { + + return null; + } + + public String toString() { + return "Equals"; + } + +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/simple/Multiply.java b/src/experimental/org/apache/commons/math/function/simple/Multiply.java new file mode 100644 index 000000000..40b10ab61 --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/simple/Multiply.java @@ -0,0 +1,91 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function.simple; + +import java.io.Serializable; + +import org.apache.commons.math.function.EvaluationContext; +import org.apache.commons.math.function.Evaluation; +import org.apache.commons.math.function.EvaluationException; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class Multiply implements Evaluation, Serializable { + + private Evaluation left; + + private Evaluation right; + + public void setLeftOperand(Evaluation left) { + this.left = left; + } + + public void setRightOperand(Evaluation right) { + this.right = right; + } + + public Evaluation evaluate(EvaluationContext context) throws EvaluationException { + return context.evaluate( + context.doubleValue(left) * context.doubleValue(right) + ); + } + + public String toString() { + return "Multiply"; + } +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/simple/Power.java b/src/experimental/org/apache/commons/math/function/simple/Power.java new file mode 100644 index 000000000..b5ef26798 --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/simple/Power.java @@ -0,0 +1,95 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function.simple; + +import java.io.Serializable; + +import org.apache.commons.math.function.Evaluation; +import org.apache.commons.math.function.EvaluationContext; +import org.apache.commons.math.function.EvaluationException; + + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class Power implements Evaluation, Serializable { + + private Evaluation argument; + + private Evaluation power; + + public void setOperand(Evaluation argument) { + this.argument = argument; + } + + public void setPower(Evaluation power) { + this.power = power; + } + + public Evaluation evaluate(EvaluationContext context) throws EvaluationException { + return context.evaluate( + Math.pow( + context.doubleValue(argument), + context.doubleValue(power) + ) + ); + } + + public String toString() { + return "Power"; + } +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/simple/Sqrt.java b/src/experimental/org/apache/commons/math/function/simple/Sqrt.java new file mode 100644 index 000000000..25d7df921 --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/simple/Sqrt.java @@ -0,0 +1,90 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function.simple; + +import java.io.Serializable; + +import org.apache.commons.math.function.Evaluation; +import org.apache.commons.math.function.EvaluationContext; +import org.apache.commons.math.function.EvaluationException; + + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class Sqrt implements Evaluation, Serializable { + + private Evaluation argument; + + public void setOperand(Evaluation argument) { + this.argument = argument; + } + + /* (non-Javadoc) + * @see org.apache.archimedes.NumericFunction#evaluate(org.apache.archimedes.EvaluationContext) + */ + public Evaluation evaluate(EvaluationContext context) throws EvaluationException { + return context.evaluate( + Math.sqrt(context.doubleValue(argument))); + + } + + public String toString() { + return "Square Root"; + } + +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/function/simple/Subtract.java b/src/experimental/org/apache/commons/math/function/simple/Subtract.java new file mode 100644 index 000000000..33f7e4a68 --- /dev/null +++ b/src/experimental/org/apache/commons/math/function/simple/Subtract.java @@ -0,0 +1,91 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their name without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.commons.math.function.simple; + +import java.io.Serializable; + +import org.apache.commons.math.function.EvaluationContext; +import org.apache.commons.math.function.Evaluation; +import org.apache.commons.math.function.EvaluationException; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class Subtract implements Evaluation, Serializable { + + private Evaluation left; + + private Evaluation right; + + public void setLeftOperand(Evaluation left) { + this.left = left; + } + + public void setRightOperand(Evaluation right) { + this.right = right; + } + + public Evaluation evaluate(EvaluationContext context) throws EvaluationException { + return context.evaluate( + context.doubleValue(left) - context.doubleValue(right) + ); + } + + public String toString() { + return "Subtract"; + } +} \ No newline at end of file diff --git a/src/experimental/org/apache/commons/math/linear/Decomposer.java b/src/experimental/org/apache/commons/math/linear/Decomposer.java new file mode 100644 index 000000000..228d28078 --- /dev/null +++ b/src/experimental/org/apache/commons/math/linear/Decomposer.java @@ -0,0 +1,19 @@ +/* + * Created on Nov 19, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.apache.commons.math.linear; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public interface Decomposer { + + Decomposition decompose(RealMatrix); + +} diff --git a/src/experimental/org/apache/commons/math/linear/Decomposition.java b/src/experimental/org/apache/commons/math/linear/Decomposition.java new file mode 100644 index 000000000..0867d9339 --- /dev/null +++ b/src/experimental/org/apache/commons/math/linear/Decomposition.java @@ -0,0 +1,27 @@ +/* + * Created on Nov 19, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.apache.commons.math.linear; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public interface Decomposition { + + // solve A*x=b + RealVector solve(RealVector b); + + + // solve matrix equation + RealMatrix solve(RealMatrix b); + + + RealMatrix invert(); + +} diff --git a/src/experimental/org/apache/commons/math/linear/DecompositionFactory.java b/src/experimental/org/apache/commons/math/linear/DecompositionFactory.java new file mode 100644 index 000000000..c4e32231b --- /dev/null +++ b/src/experimental/org/apache/commons/math/linear/DecompositionFactory.java @@ -0,0 +1,34 @@ +/* + * Created on Nov 19, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.apache.commons.math.linear; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public abstract class DecompositionFactory { + + /* + * get a matrix specific decomposer factory + * class RealMatrix { + * DecompositionFactory getDecompositionFactory(); + * } + */ + + // get overall default factory + public static DecompositionFactory newInstance(){ + return null; + } + + // construct a new default decomposer + public abstract Decomposer newDecomposer(); + + // example for a specific decomposer (Householder or QR) + public abstract Decomposer newQRDecopmposer(); +} diff --git a/src/experimental/org/apache/commons/math/linear/RealVector.java b/src/experimental/org/apache/commons/math/linear/RealVector.java new file mode 100644 index 000000000..d30b1ae8d --- /dev/null +++ b/src/experimental/org/apache/commons/math/linear/RealVector.java @@ -0,0 +1,13 @@ +/* + * Created on Nov 19, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.apache.commons.math.linear; + + +public class RealVector { + + +}