simplified DifferentiableMultivariateVectorialFunction
the gradient and partial derivaritves can be retrieved from the jacobian and adding them at the interface level was cumbersome for implementing optimization problems. Now users need to provide only the jacobian method git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@775751 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
acd879648c
commit
4d3b3886f9
|
@ -27,46 +27,8 @@ package org.apache.commons.math.analysis;
|
|||
public interface DifferentiableMultivariateVectorialFunction
|
||||
extends MultivariateVectorialFunction {
|
||||
|
||||
/**
|
||||
* Returns the partial derivative of the function with respect to point
|
||||
* coordinate x<sub>j</sub>.
|
||||
* <p>
|
||||
* The partial derivative basically represents column j of the jacobian
|
||||
* matrix. If the partial derivatives with respect to all coordinates are
|
||||
* needed, it may be more efficient to use the {@link #jacobian()} method
|
||||
* which will compute the complete matrix at once.
|
||||
* </p>
|
||||
* @param j index of the coordinate with respect to which the partial
|
||||
* derivative is computed
|
||||
* @return the partial derivative function with respect to point coordinate
|
||||
* x<sub>i</sub>
|
||||
*/
|
||||
MultivariateVectorialFunction partialDerivative(int j);
|
||||
|
||||
/**
|
||||
* Returns the gradient function of the i<sup>th</sup> component of
|
||||
* the vectorial function.
|
||||
*
|
||||
* <p>
|
||||
* The i<sup>th</sup> gradient basically represents row i of the jacobian
|
||||
* matrix. If all gradients are needed, it may be more efficient to use the
|
||||
* {@link #jacobian()} method which will compute the complete matrix at once.
|
||||
* </p>
|
||||
* @param i index of the function component for which the gradient is requested
|
||||
* @return the gradient function of the i<sup>th</sup> component of
|
||||
* the vectorial function
|
||||
*/
|
||||
MultivariateVectorialFunction gradient(int i);
|
||||
|
||||
/**
|
||||
* Returns the jacobian function.
|
||||
* <p>
|
||||
* If only one column of the jacobian is needed, it may be more efficient to
|
||||
* use the {@link #partialDerivative(int)} method which will compute only the
|
||||
* specified column. If only one row of the jacobian is needed, it may be more
|
||||
* efficient to use the {@link #gradient(int)} method which will compute only the
|
||||
* specified row.
|
||||
* </p>
|
||||
* @return the jacobian function
|
||||
*/
|
||||
MultivariateMatrixFunction jacobian();
|
||||
|
|
|
@ -493,24 +493,6 @@ extends TestCase {
|
|||
return factors.operate(variables);
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction partialDerivative(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = 1037082026387842358L;
|
||||
public double[] value(double[] point) {
|
||||
return factors.getColumn(i);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction gradient(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = -3268626996728727146L;
|
||||
public double[] value(double[] point) {
|
||||
return factors.getRow(i);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateMatrixFunction jacobian() {
|
||||
return new MultivariateMatrixFunction() {
|
||||
private static final long serialVersionUID = -8387467946663627585L;
|
||||
|
@ -590,29 +572,6 @@ extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction partialDerivative(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = -2884159755283203273L;
|
||||
public double[] value(double[] point) {
|
||||
double[][] m = jacobian(point);
|
||||
double[] partial = new double[m.length];
|
||||
for (int j = 0; j < partial.length; ++j) {
|
||||
partial[i] = m[i][j];
|
||||
}
|
||||
return partial;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction gradient(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = -43357217231860547L;
|
||||
public double[] value(double[] point) {
|
||||
return jacobian(point)[i];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateMatrixFunction jacobian() {
|
||||
return new MultivariateMatrixFunction() {
|
||||
private static final long serialVersionUID = -4340046230875165095L;
|
||||
|
|
|
@ -533,24 +533,6 @@ public class LevenbergMarquardtOptimizerTest
|
|||
return factors.operate(variables);
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction partialDerivative(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = 4868131119285501303L;
|
||||
public double[] value(double[] point) {
|
||||
return factors.getColumn(i);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction gradient(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = 6280336674474631774L;
|
||||
public double[] value(double[] point) {
|
||||
return factors.getRow(i);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateMatrixFunction jacobian() {
|
||||
return new MultivariateMatrixFunction() {
|
||||
private static final long serialVersionUID = 556396458721526234L;
|
||||
|
@ -632,29 +614,6 @@ public class LevenbergMarquardtOptimizerTest
|
|||
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction partialDerivative(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = -2884159755283203273L;
|
||||
public double[] value(double[] point) {
|
||||
double[][] m = jacobian(point);
|
||||
double[] partial = new double[m.length];
|
||||
for (int j = 0; j < partial.length; ++j) {
|
||||
partial[i] = m[i][j];
|
||||
}
|
||||
return partial;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction gradient(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = -43357217231860547L;
|
||||
public double[] value(double[] point) {
|
||||
return jacobian(point)[i];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateMatrixFunction jacobian() {
|
||||
return new MultivariateMatrixFunction() {
|
||||
private static final long serialVersionUID = -4340046230875165095L;
|
||||
|
@ -700,29 +659,6 @@ public class LevenbergMarquardtOptimizerTest
|
|||
return values;
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction partialDerivative(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = 2371658898687841192L;
|
||||
public double[] value(double[] point) {
|
||||
double[][] m = jacobian(point);
|
||||
double[] partial = new double[m.length];
|
||||
for (int j = 0; j < partial.length; ++j) {
|
||||
partial[i] = m[i][j];
|
||||
}
|
||||
return partial;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction gradient(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = 6863958501785879369L;
|
||||
public double[] value(double[] point) {
|
||||
return jacobian(point)[i];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateMatrixFunction jacobian() {
|
||||
return new MultivariateMatrixFunction() {
|
||||
private static final long serialVersionUID = -8673650298627399464L;
|
||||
|
|
|
@ -582,29 +582,6 @@ public class MinpackTest extends TestCase {
|
|||
return true;
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction partialDerivative(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = 2192585229396907068L;
|
||||
public double[] value(double[] point) {
|
||||
double[][] m = jacobian(point);
|
||||
double[] partial = new double[m.length];
|
||||
for (int j = 0; j < partial.length; ++j) {
|
||||
partial[i] = m[i][j];
|
||||
}
|
||||
return partial;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateVectorialFunction gradient(final int i) {
|
||||
return new MultivariateVectorialFunction() {
|
||||
private static final long serialVersionUID = -5562016064510078300L;
|
||||
public double[] value(double[] point) {
|
||||
return jacobian(point)[i];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MultivariateMatrixFunction jacobian() {
|
||||
return new MultivariateMatrixFunction() {
|
||||
private static final long serialVersionUID = -2435076097232923678L;
|
||||
|
|
Loading…
Reference in New Issue