Fixed @Override checkstyle warnings.
@Override was forbidden at some places in Java 5, but is now mandatory at the same places in Java 7.
This commit is contained in:
parent
a06a158465
commit
8d9ddbca5f
|
@ -50,6 +50,7 @@ public class FunctionUtils {
|
|||
public static UnivariateFunction compose(final UnivariateFunction ... f) {
|
||||
return new UnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
double r = x;
|
||||
for (int i = f.length - 1; i >= 0; i--) {
|
||||
|
@ -74,6 +75,7 @@ public class FunctionUtils {
|
|||
return new UnivariateDifferentiableFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double t) {
|
||||
double r = t;
|
||||
for (int i = f.length - 1; i >= 0; i--) {
|
||||
|
@ -83,6 +85,7 @@ public class FunctionUtils {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
DerivativeStructure r = t;
|
||||
for (int i = f.length - 1; i >= 0; i--) {
|
||||
|
@ -108,6 +111,7 @@ public class FunctionUtils {
|
|||
public static DifferentiableUnivariateFunction compose(final DifferentiableUnivariateFunction ... f) {
|
||||
return new DifferentiableUnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
double r = x;
|
||||
for (int i = f.length - 1; i >= 0; i--) {
|
||||
|
@ -117,9 +121,11 @@ public class FunctionUtils {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return new UnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
double p = 1;
|
||||
double r = x;
|
||||
|
@ -143,6 +149,7 @@ public class FunctionUtils {
|
|||
public static UnivariateFunction add(final UnivariateFunction ... f) {
|
||||
return new UnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
double r = f[0].value(x);
|
||||
for (int i = 1; i < f.length; i++) {
|
||||
|
@ -164,6 +171,7 @@ public class FunctionUtils {
|
|||
return new UnivariateDifferentiableFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double t) {
|
||||
double r = f[0].value(t);
|
||||
for (int i = 1; i < f.length; i++) {
|
||||
|
@ -175,6 +183,7 @@ public class FunctionUtils {
|
|||
/** {@inheritDoc}
|
||||
* @throws DimensionMismatchException if functions are not consistent with each other
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t)
|
||||
throws DimensionMismatchException {
|
||||
DerivativeStructure r = f[0].value(t);
|
||||
|
@ -198,6 +207,7 @@ public class FunctionUtils {
|
|||
public static DifferentiableUnivariateFunction add(final DifferentiableUnivariateFunction ... f) {
|
||||
return new DifferentiableUnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
double r = f[0].value(x);
|
||||
for (int i = 1; i < f.length; i++) {
|
||||
|
@ -207,9 +217,11 @@ public class FunctionUtils {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return new UnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
double r = f[0].derivative().value(x);
|
||||
for (int i = 1; i < f.length; i++) {
|
||||
|
@ -231,6 +243,7 @@ public class FunctionUtils {
|
|||
public static UnivariateFunction multiply(final UnivariateFunction ... f) {
|
||||
return new UnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
double r = f[0].value(x);
|
||||
for (int i = 1; i < f.length; i++) {
|
||||
|
@ -252,6 +265,7 @@ public class FunctionUtils {
|
|||
return new UnivariateDifferentiableFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double t) {
|
||||
double r = f[0].value(t);
|
||||
for (int i = 1; i < f.length; i++) {
|
||||
|
@ -261,6 +275,7 @@ public class FunctionUtils {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
DerivativeStructure r = f[0].value(t);
|
||||
for (int i = 1; i < f.length; i++) {
|
||||
|
@ -283,6 +298,7 @@ public class FunctionUtils {
|
|||
public static DifferentiableUnivariateFunction multiply(final DifferentiableUnivariateFunction ... f) {
|
||||
return new DifferentiableUnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
double r = f[0].value(x);
|
||||
for (int i = 1; i < f.length; i++) {
|
||||
|
@ -292,9 +308,11 @@ public class FunctionUtils {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return new UnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
double sum = 0;
|
||||
for (int i = 0; i < f.length; i++) {
|
||||
|
@ -327,6 +345,7 @@ public class FunctionUtils {
|
|||
final UnivariateFunction g) {
|
||||
return new UnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return combiner.value(f.value(x), g.value(x));
|
||||
}
|
||||
|
@ -348,6 +367,7 @@ public class FunctionUtils {
|
|||
final double initialValue) {
|
||||
return new MultivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double[] point) {
|
||||
double result = combiner.value(initialValue, f.value(point[0]));
|
||||
for (int i = 1; i < point.length; i++) {
|
||||
|
@ -383,6 +403,7 @@ public class FunctionUtils {
|
|||
final double fixed) {
|
||||
return new UnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return f.value(fixed, x);
|
||||
}
|
||||
|
@ -399,6 +420,7 @@ public class FunctionUtils {
|
|||
final double fixed) {
|
||||
return new UnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return f.value(x, fixed);
|
||||
}
|
||||
|
@ -453,14 +475,17 @@ public class FunctionUtils {
|
|||
return new DifferentiableUnivariateFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double x) {
|
||||
return f.value(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return new UnivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double x) {
|
||||
return f.value(new DerivativeStructure(1, 1, 0, x)).getPartialDerivative(1);
|
||||
}
|
||||
|
@ -485,6 +510,7 @@ public class FunctionUtils {
|
|||
return new UnivariateDifferentiableFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double x) {
|
||||
return f.value(x);
|
||||
}
|
||||
|
@ -492,6 +518,7 @@ public class FunctionUtils {
|
|||
/** {@inheritDoc}
|
||||
* @exception NumberIsTooLargeException if derivation order is greater than 1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t)
|
||||
throws NumberIsTooLargeException {
|
||||
switch (t.getOrder()) {
|
||||
|
@ -529,14 +556,17 @@ public class FunctionUtils {
|
|||
return new DifferentiableMultivariateFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double[] x) {
|
||||
return f.value(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public MultivariateFunction partialDerivative(final int k) {
|
||||
return new MultivariateFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double[] x) {
|
||||
|
||||
final int n = x.length;
|
||||
|
@ -562,6 +592,7 @@ public class FunctionUtils {
|
|||
public MultivariateVectorFunction gradient() {
|
||||
return new MultivariateVectorFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[] value(final double[] x) {
|
||||
|
||||
final int n = x.length;
|
||||
|
@ -608,6 +639,7 @@ public class FunctionUtils {
|
|||
return new MultivariateDifferentiableFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double[] x) {
|
||||
return f.value(x);
|
||||
}
|
||||
|
@ -616,6 +648,7 @@ public class FunctionUtils {
|
|||
* @exception NumberIsTooLargeException if derivation order is higher than 1
|
||||
* @exception DimensionMismatchException if numbers of free parameters are inconsistent
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure[] t)
|
||||
throws DimensionMismatchException, NumberIsTooLargeException {
|
||||
|
||||
|
@ -676,6 +709,7 @@ public class FunctionUtils {
|
|||
return new DifferentiableMultivariateVectorFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[] value(final double[] x) {
|
||||
return f.value(x);
|
||||
}
|
||||
|
@ -683,6 +717,7 @@ public class FunctionUtils {
|
|||
public MultivariateMatrixFunction jacobian() {
|
||||
return new MultivariateMatrixFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[][] value(final double[] x) {
|
||||
|
||||
final int n = x.length;
|
||||
|
@ -731,6 +766,7 @@ public class FunctionUtils {
|
|||
return new MultivariateDifferentiableVectorFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[] value(final double[] x) {
|
||||
return f.value(x);
|
||||
}
|
||||
|
@ -739,6 +775,7 @@ public class FunctionUtils {
|
|||
* @exception NumberIsTooLargeException if derivation order is higher than 1
|
||||
* @exception DimensionMismatchException if numbers of free parameters are inconsistent
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure[] value(final DerivativeStructure[] t)
|
||||
throws DimensionMismatchException, NumberIsTooLargeException {
|
||||
|
||||
|
|
|
@ -248,6 +248,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public double getReal() {
|
||||
return data[0];
|
||||
}
|
||||
|
@ -286,6 +287,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure add(final double a) {
|
||||
final DerivativeStructure ds = new DerivativeStructure(this);
|
||||
ds.data[0] += a;
|
||||
|
@ -296,6 +298,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* @exception DimensionMismatchException if number of free parameters
|
||||
* or orders do not match
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure add(final DerivativeStructure a)
|
||||
throws DimensionMismatchException {
|
||||
compiler.checkCompatibility(a.compiler);
|
||||
|
@ -307,6 +310,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure subtract(final double a) {
|
||||
return add(-a);
|
||||
}
|
||||
|
@ -315,6 +319,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* @exception DimensionMismatchException if number of free parameters
|
||||
* or orders do not match
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure subtract(final DerivativeStructure a)
|
||||
throws DimensionMismatchException {
|
||||
compiler.checkCompatibility(a.compiler);
|
||||
|
@ -324,6 +329,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure multiply(final int n) {
|
||||
return multiply((double) n);
|
||||
}
|
||||
|
@ -331,6 +337,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure multiply(final double a) {
|
||||
final DerivativeStructure ds = new DerivativeStructure(this);
|
||||
for (int i = 0; i < ds.data.length; ++i) {
|
||||
|
@ -343,6 +350,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* @exception DimensionMismatchException if number of free parameters
|
||||
* or orders do not match
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure multiply(final DerivativeStructure a)
|
||||
throws DimensionMismatchException {
|
||||
compiler.checkCompatibility(a.compiler);
|
||||
|
@ -354,6 +362,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure divide(final double a) {
|
||||
final DerivativeStructure ds = new DerivativeStructure(this);
|
||||
for (int i = 0; i < ds.data.length; ++i) {
|
||||
|
@ -366,6 +375,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* @exception DimensionMismatchException if number of free parameters
|
||||
* or orders do not match
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure divide(final DerivativeStructure a)
|
||||
throws DimensionMismatchException {
|
||||
compiler.checkCompatibility(a.compiler);
|
||||
|
@ -375,6 +385,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure remainder(final double a) {
|
||||
final DerivativeStructure ds = new DerivativeStructure(this);
|
||||
ds.data[0] = FastMath.IEEEremainder(ds.data[0], a);
|
||||
|
@ -386,6 +397,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure remainder(final DerivativeStructure a)
|
||||
throws DimensionMismatchException {
|
||||
compiler.checkCompatibility(a.compiler);
|
||||
|
@ -395,6 +407,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure negate() {
|
||||
final DerivativeStructure ds = new DerivativeStructure(compiler);
|
||||
for (int i = 0; i < ds.data.length; ++i) {
|
||||
|
@ -406,6 +419,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure abs() {
|
||||
if (Double.doubleToLongBits(data[0]) < 0) {
|
||||
// we use the bits representation to also handle -0.0
|
||||
|
@ -418,6 +432,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure ceil() {
|
||||
return new DerivativeStructure(compiler.getFreeParameters(),
|
||||
compiler.getOrder(),
|
||||
|
@ -427,6 +442,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure floor() {
|
||||
return new DerivativeStructure(compiler.getFreeParameters(),
|
||||
compiler.getOrder(),
|
||||
|
@ -436,6 +452,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure rint() {
|
||||
return new DerivativeStructure(compiler.getFreeParameters(),
|
||||
compiler.getOrder(),
|
||||
|
@ -443,6 +460,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long round() {
|
||||
return FastMath.round(data[0]);
|
||||
}
|
||||
|
@ -450,6 +468,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure signum() {
|
||||
return new DerivativeStructure(compiler.getFreeParameters(),
|
||||
compiler.getOrder(),
|
||||
|
@ -459,6 +478,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure copySign(final DerivativeStructure sign){
|
||||
long m = Double.doubleToLongBits(data[0]);
|
||||
long s = Double.doubleToLongBits(sign.data[0]);
|
||||
|
@ -471,6 +491,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure copySign(final double sign) {
|
||||
long m = Double.doubleToLongBits(data[0]);
|
||||
long s = Double.doubleToLongBits(sign);
|
||||
|
@ -495,6 +516,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure scalb(final int n) {
|
||||
final DerivativeStructure ds = new DerivativeStructure(compiler);
|
||||
for (int i = 0; i < ds.data.length; ++i) {
|
||||
|
@ -508,6 +530,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure hypot(final DerivativeStructure y)
|
||||
throws DimensionMismatchException {
|
||||
|
||||
|
@ -593,6 +616,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure reciprocal() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.pow(data, 0, -1, result.data, 0);
|
||||
|
@ -602,6 +626,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure sqrt() {
|
||||
return rootN(2);
|
||||
}
|
||||
|
@ -609,6 +634,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure cbrt() {
|
||||
return rootN(3);
|
||||
}
|
||||
|
@ -616,6 +642,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure rootN(final int n) {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.rootN(data, 0, n, result.data, 0);
|
||||
|
@ -623,20 +650,24 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Field<DerivativeStructure> getField() {
|
||||
return new Field<DerivativeStructure>() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure getZero() {
|
||||
return new DerivativeStructure(compiler.getFreeParameters(), compiler.getOrder(), 0.0);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure getOne() {
|
||||
return new DerivativeStructure(compiler.getFreeParameters(), compiler.getOrder(), 1.0);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Class<? extends FieldElement<DerivativeStructure>> getRuntimeClass() {
|
||||
return DerivativeStructure.class;
|
||||
}
|
||||
|
@ -659,6 +690,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure pow(final double p) {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.pow(data, 0, p, result.data, 0);
|
||||
|
@ -668,6 +700,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure pow(final int n) {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.pow(data, 0, n, result.data, 0);
|
||||
|
@ -679,6 +712,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure pow(final DerivativeStructure e)
|
||||
throws DimensionMismatchException {
|
||||
compiler.checkCompatibility(e.compiler);
|
||||
|
@ -690,6 +724,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure exp() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.exp(data, 0, result.data, 0);
|
||||
|
@ -699,6 +734,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure expm1() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.expm1(data, 0, result.data, 0);
|
||||
|
@ -708,6 +744,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure log() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.log(data, 0, result.data, 0);
|
||||
|
@ -717,6 +754,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure log1p() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.log1p(data, 0, result.data, 0);
|
||||
|
@ -735,6 +773,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure cos() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.cos(data, 0, result.data, 0);
|
||||
|
@ -744,6 +783,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure sin() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.sin(data, 0, result.data, 0);
|
||||
|
@ -753,6 +793,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure tan() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.tan(data, 0, result.data, 0);
|
||||
|
@ -762,6 +803,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure acos() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.acos(data, 0, result.data, 0);
|
||||
|
@ -771,6 +813,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure asin() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.asin(data, 0, result.data, 0);
|
||||
|
@ -780,6 +823,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure atan() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.atan(data, 0, result.data, 0);
|
||||
|
@ -789,6 +833,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure atan2(final DerivativeStructure x)
|
||||
throws DimensionMismatchException {
|
||||
compiler.checkCompatibility(x.compiler);
|
||||
|
@ -813,6 +858,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure cosh() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.cosh(data, 0, result.data, 0);
|
||||
|
@ -822,6 +868,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure sinh() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.sinh(data, 0, result.data, 0);
|
||||
|
@ -831,6 +878,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure tanh() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.tanh(data, 0, result.data, 0);
|
||||
|
@ -840,6 +888,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure acosh() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.acosh(data, 0, result.data, 0);
|
||||
|
@ -849,6 +898,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure asinh() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.asinh(data, 0, result.data, 0);
|
||||
|
@ -858,6 +908,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
/** {@inheritDoc}
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure atanh() {
|
||||
final DerivativeStructure result = new DerivativeStructure(compiler);
|
||||
compiler.atanh(data, 0, result.data, 0);
|
||||
|
@ -900,6 +951,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure linearCombination(final DerivativeStructure[] a, final DerivativeStructure[] b)
|
||||
throws DimensionMismatchException {
|
||||
|
||||
|
@ -932,6 +984,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure linearCombination(final double[] a, final DerivativeStructure[] b)
|
||||
throws DimensionMismatchException {
|
||||
|
||||
|
@ -960,6 +1013,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure linearCombination(final DerivativeStructure a1, final DerivativeStructure b1,
|
||||
final DerivativeStructure a2, final DerivativeStructure b2)
|
||||
throws DimensionMismatchException {
|
||||
|
@ -983,6 +1037,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure linearCombination(final double a1, final DerivativeStructure b1,
|
||||
final double a2, final DerivativeStructure b2)
|
||||
throws DimensionMismatchException {
|
||||
|
@ -1006,6 +1061,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure linearCombination(final DerivativeStructure a1, final DerivativeStructure b1,
|
||||
final DerivativeStructure a2, final DerivativeStructure b2,
|
||||
final DerivativeStructure a3, final DerivativeStructure b3)
|
||||
|
@ -1031,6 +1087,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure linearCombination(final double a1, final DerivativeStructure b1,
|
||||
final double a2, final DerivativeStructure b2,
|
||||
final double a3, final DerivativeStructure b3)
|
||||
|
@ -1056,6 +1113,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure linearCombination(final DerivativeStructure a1, final DerivativeStructure b1,
|
||||
final DerivativeStructure a2, final DerivativeStructure b2,
|
||||
final DerivativeStructure a3, final DerivativeStructure b3,
|
||||
|
@ -1083,6 +1141,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* or orders do not match
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure linearCombination(final double a1, final DerivativeStructure b1,
|
||||
final double a2, final DerivativeStructure b2,
|
||||
final double a3, final DerivativeStructure b3,
|
||||
|
|
|
@ -240,15 +240,18 @@ public class FiniteDifferencesDifferentiator
|
|||
* derivation order is larger or equal to the number of points.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public UnivariateDifferentiableFunction differentiate(final UnivariateFunction function) {
|
||||
return new UnivariateDifferentiableFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double x) throws MathIllegalArgumentException {
|
||||
return function.value(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t)
|
||||
throws MathIllegalArgumentException {
|
||||
|
||||
|
@ -280,15 +283,18 @@ public class FiniteDifferencesDifferentiator
|
|||
* derivation order is larger or equal to the number of points.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public UnivariateDifferentiableVectorFunction differentiate(final UnivariateVectorFunction function) {
|
||||
return new UnivariateDifferentiableVectorFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[]value(final double x) throws MathIllegalArgumentException {
|
||||
return function.value(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure[] value(final DerivativeStructure t)
|
||||
throws MathIllegalArgumentException {
|
||||
|
||||
|
@ -331,15 +337,18 @@ public class FiniteDifferencesDifferentiator
|
|||
* derivation order is larger or equal to the number of points.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public UnivariateDifferentiableMatrixFunction differentiate(final UnivariateMatrixFunction function) {
|
||||
return new UnivariateDifferentiableMatrixFunction() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[][] value(final double x) throws MathIllegalArgumentException {
|
||||
return function.value(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DerivativeStructure[][] value(final DerivativeStructure t)
|
||||
throws MathIllegalArgumentException {
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ public class GradientFunction implements MultivariateVectorFunction {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[] value(double[] point) {
|
||||
|
||||
// set up parameters
|
||||
|
|
|
@ -40,6 +40,7 @@ public class JacobianFunction implements MultivariateMatrixFunction {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[][] value(double[] point) {
|
||||
|
||||
// set up parameters
|
||||
|
|
|
@ -130,11 +130,13 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getReal() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient add(final SparseGradient a) {
|
||||
final SparseGradient out = new SparseGradient(value + a.value, derivatives);
|
||||
for (Map.Entry<Integer, Double> entry : a.derivatives.entrySet()) {
|
||||
|
@ -176,12 +178,14 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient add(final double c) {
|
||||
final SparseGradient out = new SparseGradient(value + c, derivatives);
|
||||
return out;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient subtract(final SparseGradient a) {
|
||||
final SparseGradient out = new SparseGradient(value - a.value, derivatives);
|
||||
for (Map.Entry<Integer, Double> entry : a.derivatives.entrySet()) {
|
||||
|
@ -197,11 +201,13 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient subtract(double c) {
|
||||
return new SparseGradient(value - c, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient multiply(final SparseGradient a) {
|
||||
final SparseGradient out =
|
||||
new SparseGradient(value * a.value, Collections.<Integer, Double> emptyMap());
|
||||
|
@ -252,16 +258,19 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient multiply(final double c) {
|
||||
return new SparseGradient(value * c, c, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient multiply(final int n) {
|
||||
return new SparseGradient(value * n, n, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient divide(final SparseGradient a) {
|
||||
final SparseGradient out = new SparseGradient(value / a.value, Collections.<Integer, Double> emptyMap());
|
||||
|
||||
|
@ -282,30 +291,36 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient divide(final double c) {
|
||||
return new SparseGradient(value / c, 1.0 / c, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient negate() {
|
||||
return new SparseGradient(-value, -1.0, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Field<SparseGradient> getField() {
|
||||
return new Field<SparseGradient>() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient getZero() {
|
||||
return createConstant(0);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient getOne() {
|
||||
return createConstant(1);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Class<? extends FieldElement<SparseGradient>> getRuntimeClass() {
|
||||
return SparseGradient.class;
|
||||
}
|
||||
|
@ -314,11 +329,13 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient remainder(final double a) {
|
||||
return new SparseGradient(FastMath.IEEEremainder(value, a), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient remainder(final SparseGradient a) {
|
||||
|
||||
// compute k such that lhs % rhs = lhs - k rhs
|
||||
|
@ -330,6 +347,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient abs() {
|
||||
if (Double.doubleToLongBits(value) < 0) {
|
||||
// we use the bits representation to also handle -0.0
|
||||
|
@ -340,31 +358,37 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient ceil() {
|
||||
return createConstant(FastMath.ceil(value));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient floor() {
|
||||
return createConstant(FastMath.floor(value));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient rint() {
|
||||
return createConstant(FastMath.rint(value));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long round() {
|
||||
return FastMath.round(value);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient signum() {
|
||||
return createConstant(FastMath.signum(value));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient copySign(final SparseGradient sign) {
|
||||
final long m = Double.doubleToLongBits(value);
|
||||
final long s = Double.doubleToLongBits(sign.value);
|
||||
|
@ -375,6 +399,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient copySign(final double sign) {
|
||||
final long m = Double.doubleToLongBits(value);
|
||||
final long s = Double.doubleToLongBits(sign);
|
||||
|
@ -385,6 +410,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient scalb(final int n) {
|
||||
final SparseGradient out = new SparseGradient(FastMath.scalb(value, n), Collections.<Integer, Double> emptyMap());
|
||||
for (Map.Entry<Integer, Double> entry : derivatives.entrySet()) {
|
||||
|
@ -394,6 +420,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient hypot(final SparseGradient y) {
|
||||
if (Double.isInfinite(value) || Double.isInfinite(y.value)) {
|
||||
return createConstant(Double.POSITIVE_INFINITY);
|
||||
|
@ -449,23 +476,27 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient reciprocal() {
|
||||
return new SparseGradient(1.0 / value, -1.0 / (value * value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient sqrt() {
|
||||
final double sqrt = FastMath.sqrt(value);
|
||||
return new SparseGradient(sqrt, 0.5 / sqrt, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient cbrt() {
|
||||
final double cbrt = FastMath.cbrt(value);
|
||||
return new SparseGradient(cbrt, 1.0 / (3 * cbrt * cbrt), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient rootN(final int n) {
|
||||
if (n == 2) {
|
||||
return sqrt();
|
||||
|
@ -478,11 +509,13 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient pow(final double p) {
|
||||
return new SparseGradient(FastMath.pow(value, p), p * FastMath.pow(value, p - 1), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient pow(final int n) {
|
||||
if (n == 0) {
|
||||
return getField().getOne();
|
||||
|
@ -493,6 +526,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient pow(final SparseGradient e) {
|
||||
return log().multiply(e).exp();
|
||||
}
|
||||
|
@ -518,17 +552,20 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient exp() {
|
||||
final double e = FastMath.exp(value);
|
||||
return new SparseGradient(e, e, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient expm1() {
|
||||
return new SparseGradient(FastMath.expm1(value), FastMath.exp(value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient log() {
|
||||
return new SparseGradient(FastMath.log(value), 1.0 / value, derivatives);
|
||||
}
|
||||
|
@ -541,42 +578,50 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient log1p() {
|
||||
return new SparseGradient(FastMath.log1p(value), 1.0 / (1.0 + value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient cos() {
|
||||
return new SparseGradient(FastMath.cos(value), -FastMath.sin(value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient sin() {
|
||||
return new SparseGradient(FastMath.sin(value), FastMath.cos(value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient tan() {
|
||||
final double t = FastMath.tan(value);
|
||||
return new SparseGradient(t, 1 + t * t, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient acos() {
|
||||
return new SparseGradient(FastMath.acos(value), -1.0 / FastMath.sqrt(1 - value * value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient asin() {
|
||||
return new SparseGradient(FastMath.asin(value), 1.0 / FastMath.sqrt(1 - value * value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient atan() {
|
||||
return new SparseGradient(FastMath.atan(value), 1.0 / (1 + value * value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient atan2(final SparseGradient x) {
|
||||
|
||||
// compute r = sqrt(x^2+y^2)
|
||||
|
@ -613,32 +658,38 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient cosh() {
|
||||
return new SparseGradient(FastMath.cosh(value), FastMath.sinh(value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient sinh() {
|
||||
return new SparseGradient(FastMath.sinh(value), FastMath.cosh(value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient tanh() {
|
||||
final double t = FastMath.tanh(value);
|
||||
return new SparseGradient(t, 1 - t * t, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient acosh() {
|
||||
return new SparseGradient(FastMath.acosh(value), 1.0 / FastMath.sqrt(value * value - 1.0), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient asinh() {
|
||||
return new SparseGradient(FastMath.asinh(value), 1.0 / FastMath.sqrt(value * value + 1.0), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient atanh() {
|
||||
return new SparseGradient(FastMath.atanh(value), 1.0 / (1.0 - value * value), derivatives);
|
||||
}
|
||||
|
@ -680,6 +731,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient linearCombination(final SparseGradient[] a,
|
||||
final SparseGradient[] b)
|
||||
throws DimensionMismatchException {
|
||||
|
@ -706,6 +758,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient linearCombination(final double[] a, final SparseGradient[] b) {
|
||||
|
||||
// compute a simple value, with all partial derivatives
|
||||
|
@ -726,6 +779,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1,
|
||||
final SparseGradient a2, final SparseGradient b2) {
|
||||
|
||||
|
@ -740,6 +794,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient linearCombination(final double a1, final SparseGradient b1,
|
||||
final double a2, final SparseGradient b2) {
|
||||
|
||||
|
@ -754,6 +809,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1,
|
||||
final SparseGradient a2, final SparseGradient b2,
|
||||
final SparseGradient a3, final SparseGradient b3) {
|
||||
|
@ -771,6 +827,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient linearCombination(final double a1, final SparseGradient b1,
|
||||
final double a2, final SparseGradient b2,
|
||||
final double a3, final SparseGradient b3) {
|
||||
|
@ -788,6 +845,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient linearCombination(final SparseGradient a1, final SparseGradient b1,
|
||||
final SparseGradient a2, final SparseGradient b2,
|
||||
final SparseGradient a3, final SparseGradient b3,
|
||||
|
@ -807,6 +865,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient linearCombination(final double a1, final SparseGradient b1,
|
||||
final double a2, final SparseGradient b2,
|
||||
final double a3, final SparseGradient b3,
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Abs implements UnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.abs(x);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Acos implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.acos(x);
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ public class Acos implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
}
|
||||
|
@ -46,6 +48,7 @@ public class Acos implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.acos();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Acosh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.acosh(x);
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ public class Acosh implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
}
|
||||
|
@ -46,6 +48,7 @@ public class Acosh implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.acosh();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.commons.math4.analysis.BivariateFunction;
|
|||
*/
|
||||
public class Add implements BivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return x + y;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Asin implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.asin(x);
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ public class Asin implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
}
|
||||
|
@ -46,6 +48,7 @@ public class Asin implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.asin();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Asinh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.asinh(x);
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ public class Asinh implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
}
|
||||
|
@ -46,6 +48,7 @@ public class Asinh implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.asinh();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Atan implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.atan(x);
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ public class Atan implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
}
|
||||
|
@ -46,6 +48,7 @@ public class Atan implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.atan();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Atan2 implements BivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return FastMath.atan2(x, y);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Atanh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.atanh(x);
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ public class Atanh implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
}
|
||||
|
@ -46,6 +48,7 @@ public class Atanh implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.atanh();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Cbrt implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.cbrt(x);
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ public class Cbrt implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
}
|
||||
|
@ -46,6 +48,7 @@ public class Cbrt implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.cbrt();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Ceil implements UnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.ceil(x);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public class Constant implements UnivariateDifferentiableFunction, Differentiabl
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return c;
|
||||
}
|
||||
|
@ -46,6 +47,7 @@ public class Constant implements UnivariateDifferentiableFunction, Differentiabl
|
|||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public DifferentiableUnivariateFunction derivative() {
|
||||
return new Constant(0);
|
||||
}
|
||||
|
@ -53,6 +55,7 @@ public class Constant implements UnivariateDifferentiableFunction, Differentiabl
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return new DerivativeStructure(t.getFreeParameters(), t.getOrder(), c);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Cos implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.cos(x);
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ public class Cos implements UnivariateDifferentiableFunction, DifferentiableUniv
|
|||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
}
|
||||
|
@ -46,6 +48,7 @@ public class Cos implements UnivariateDifferentiableFunction, DifferentiableUniv
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.cos();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Cosh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.cosh(x);
|
||||
}
|
||||
|
@ -37,6 +38,7 @@ public class Cosh implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public DifferentiableUnivariateFunction derivative() {
|
||||
return new Sinh();
|
||||
}
|
||||
|
@ -44,6 +46,7 @@ public class Cosh implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.cosh();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.commons.math4.analysis.BivariateFunction;
|
|||
*/
|
||||
public class Divide implements BivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return x / y;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Exp implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.exp(x);
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ public class Exp implements UnivariateDifferentiableFunction, DifferentiableUniv
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -46,6 +48,7 @@ public class Exp implements UnivariateDifferentiableFunction, DifferentiableUniv
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.exp();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Expm1 implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.expm1(x);
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ public class Expm1 implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -46,6 +48,7 @@ public class Expm1 implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.expm1();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Floor implements UnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.floor(x);
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ public class Gaussian implements UnivariateDifferentiableFunction, Differentiabl
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return value(x - mean, norm, i2s2);
|
||||
}
|
||||
|
@ -97,6 +98,7 @@ public class Gaussian implements UnivariateDifferentiableFunction, Differentiabl
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -208,6 +210,7 @@ public class Gaussian implements UnivariateDifferentiableFunction, Differentiabl
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t)
|
||||
throws DimensionMismatchException {
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ public class HarmonicOscillator implements UnivariateDifferentiableFunction, Dif
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return value(omega * x + phase, amplitude);
|
||||
}
|
||||
|
@ -64,6 +65,7 @@ public class HarmonicOscillator implements UnivariateDifferentiableFunction, Dif
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -161,6 +163,7 @@ public class HarmonicOscillator implements UnivariateDifferentiableFunction, Dif
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t)
|
||||
throws DimensionMismatchException {
|
||||
final double x = t.getValue();
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiabl
|
|||
*/
|
||||
public class Identity implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return x;
|
||||
}
|
||||
|
@ -35,6 +36,7 @@ public class Identity implements UnivariateDifferentiableFunction, Differentiabl
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public DifferentiableUnivariateFunction derivative() {
|
||||
return new Constant(1);
|
||||
|
@ -43,6 +45,7 @@ public class Identity implements UnivariateDifferentiableFunction, Differentiabl
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiabl
|
|||
*/
|
||||
public class Inverse implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return 1 / x;
|
||||
}
|
||||
|
@ -37,6 +38,7 @@ public class Inverse implements UnivariateDifferentiableFunction, Differentiable
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -45,6 +47,7 @@ public class Inverse implements UnivariateDifferentiableFunction, Differentiable
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.reciprocal();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Log implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.log(x);
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ public class Log implements UnivariateDifferentiableFunction, DifferentiableUniv
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -46,6 +48,7 @@ public class Log implements UnivariateDifferentiableFunction, DifferentiableUniv
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.log();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
public class Log10 implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.log10(x);
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ public class Log10 implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -47,6 +49,7 @@ public class Log10 implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.log10();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Log1p implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.log1p(x);
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ public class Log1p implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -46,6 +48,7 @@ public class Log1p implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.log1p();
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ public class Logistic implements UnivariateDifferentiableFunction, Differentiabl
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return value(m - x, k, b, q, a, oneOverN);
|
||||
}
|
||||
|
@ -88,6 +89,7 @@ public class Logistic implements UnivariateDifferentiableFunction, Differentiabl
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -221,6 +223,7 @@ public class Logistic implements UnivariateDifferentiableFunction, Differentiabl
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.negate().add(m).multiply(b).exp().multiply(q).add(1).pow(oneOverN).reciprocal().multiply(k - a).add(a);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public class Logit implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x)
|
||||
throws OutOfRangeException {
|
||||
return value(x, lo, hi);
|
||||
|
@ -70,6 +71,7 @@ public class Logit implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -168,6 +170,7 @@ public class Logit implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
* @since 3.1
|
||||
* @exception OutOfRangeException if parameter is outside of function domain
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t)
|
||||
throws OutOfRangeException {
|
||||
final double x = t.getValue();
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Max implements BivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return FastMath.max(x, y);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Min implements BivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return FastMath.min(x, y);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiabl
|
|||
*/
|
||||
public class Minus implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return -x;
|
||||
}
|
||||
|
@ -35,6 +36,7 @@ public class Minus implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public DifferentiableUnivariateFunction derivative() {
|
||||
return new Constant(-1);
|
||||
|
@ -43,6 +45,7 @@ public class Minus implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.negate();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.commons.math4.analysis.BivariateFunction;
|
|||
*/
|
||||
public class Multiply implements BivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return x * y;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Pow implements BivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return FastMath.pow(x, y);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public class Power implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.pow(x, p);
|
||||
}
|
||||
|
@ -48,6 +49,7 @@ public class Power implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -56,6 +58,7 @@ public class Power implements UnivariateDifferentiableFunction, DifferentiableUn
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.pow(p);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Rint implements UnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.rint(x);
|
||||
}
|
||||
|
|
|
@ -67,12 +67,14 @@ public class Sigmoid implements UnivariateDifferentiableFunction, Differentiable
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return value(x, lo, hi);
|
||||
}
|
||||
|
@ -164,6 +166,7 @@ public class Sigmoid implements UnivariateDifferentiableFunction, Differentiable
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t)
|
||||
throws DimensionMismatchException {
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Signum implements UnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.signum(x);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Sin implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.sin(x);
|
||||
}
|
||||
|
@ -36,6 +37,7 @@ public class Sin implements UnivariateDifferentiableFunction, DifferentiableUniv
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public DifferentiableUnivariateFunction derivative() {
|
||||
return new Cos();
|
||||
|
@ -44,6 +46,7 @@ public class Sin implements UnivariateDifferentiableFunction, DifferentiableUniv
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.sin();
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ public class Sinc implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double x) {
|
||||
final double scaledX = normalized ? FastMath.PI * x : x;
|
||||
if (FastMath.abs(scaledX) <= SHORTCUT) {
|
||||
|
@ -97,6 +98,7 @@ public class Sinc implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -105,6 +107,7 @@ public class Sinc implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t)
|
||||
throws DimensionMismatchException {
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Sinh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.sinh(x);
|
||||
}
|
||||
|
@ -36,6 +37,7 @@ public class Sinh implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public DifferentiableUnivariateFunction derivative() {
|
||||
return new Cosh();
|
||||
|
@ -44,6 +46,7 @@ public class Sinh implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.sinh();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Sqrt implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.sqrt(x);
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ public class Sqrt implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -46,6 +48,7 @@ public class Sqrt implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.sqrt();
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ public class StepFunction implements UnivariateFunction {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
int index = Arrays.binarySearch(abscissa, x);
|
||||
double fx = 0;
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.commons.math4.analysis.BivariateFunction;
|
|||
*/
|
||||
public class Subtract implements BivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return x - y;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Tan implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.tan(x);
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ public class Tan implements UnivariateDifferentiableFunction, DifferentiableUniv
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -46,6 +48,7 @@ public class Tan implements UnivariateDifferentiableFunction, DifferentiableUniv
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.tan();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Tanh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.tanh(x);
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ public class Tanh implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public UnivariateFunction derivative() {
|
||||
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
|
||||
|
@ -46,6 +48,7 @@ public class Tanh implements UnivariateDifferentiableFunction, DifferentiableUni
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
return t.tanh();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
*/
|
||||
public class Ulp implements UnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return FastMath.ulp(x);
|
||||
}
|
||||
|
|
|
@ -159,31 +159,37 @@ public abstract class BaseAbstractUnivariateIntegrator implements UnivariateInte
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getRelativeAccuracy() {
|
||||
return relativeAccuracy;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getAbsoluteAccuracy() {
|
||||
return absoluteAccuracy;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getMinimalIterationCount() {
|
||||
return minimalIterationCount;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getMaximalIterationCount() {
|
||||
return iterations.getMaximalCount();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getEvaluations() {
|
||||
return evaluations.getCount();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getIterations() {
|
||||
return iterations.getCount();
|
||||
}
|
||||
|
@ -251,6 +257,7 @@ public abstract class BaseAbstractUnivariateIntegrator implements UnivariateInte
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double integrate(final int maxEval, final UnivariateFunction f,
|
||||
final double lower, final double upper)
|
||||
throws TooManyEvaluationsException, MaxCountExceededException,
|
||||
|
|
|
@ -154,6 +154,7 @@ public class BicubicInterpolatingFunction
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public double value(double x, double y)
|
||||
throws OutOfRangeException {
|
||||
final int i = searchIndex(x, xval);
|
||||
|
@ -287,6 +288,7 @@ class BicubicFunction implements BivariateFunction {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
if (x < 0 || x > 1) {
|
||||
throw new OutOfRangeException(x, 0, 1);
|
||||
|
|
|
@ -44,6 +44,7 @@ public class BicubicInterpolator
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public BicubicInterpolatingFunction interpolate(final double[] xval,
|
||||
final double[] yval,
|
||||
final double[][] fval)
|
||||
|
|
|
@ -87,6 +87,7 @@ public class MicrosphereInterpolator
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MultivariateFunction interpolate(final double[][] xval,
|
||||
final double[] yval)
|
||||
throws DimensionMismatchException,
|
||||
|
|
|
@ -112,6 +112,7 @@ public class PiecewiseBicubicSplineInterpolatingFunction
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public double value(double x,
|
||||
double y)
|
||||
throws OutOfRangeException {
|
||||
|
|
|
@ -33,6 +33,7 @@ public class PiecewiseBicubicSplineInterpolator
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public PiecewiseBicubicSplineInterpolatingFunction interpolate( final double[] xval,
|
||||
final double[] yval,
|
||||
final double[][] fval)
|
||||
|
|
|
@ -309,6 +309,7 @@ public class TricubicInterpolatingFunction
|
|||
*
|
||||
* @throws OutOfRangeException if any of the variables is outside its interpolation range.
|
||||
*/
|
||||
@Override
|
||||
public double value(double x, double y, double z)
|
||||
throws OutOfRangeException {
|
||||
final int i = searchIndex(x, xval);
|
||||
|
|
|
@ -32,6 +32,7 @@ public class TricubicInterpolator
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public TricubicInterpolatingFunction interpolate(final double[] xval,
|
||||
final double[] yval,
|
||||
final double[] zval,
|
||||
|
|
|
@ -81,6 +81,7 @@ public class UnivariatePeriodicInterpolator
|
|||
* @throws NumberIsTooSmallException if the number of extension points
|
||||
* is larger than the size of {@code xval}.
|
||||
*/
|
||||
@Override
|
||||
public UnivariateFunction interpolate(double[] xval,
|
||||
double[] yval)
|
||||
throws NumberIsTooSmallException, NonMonotonicSequenceException {
|
||||
|
|
|
@ -144,6 +144,7 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Dif
|
|||
* @throws NoDataException if {@code coefficients} is empty.
|
||||
* @throws NullArgumentException if {@code coefficients} is {@code null}.
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t)
|
||||
throws NullArgumentException, NoDataException {
|
||||
MathUtils.checkNotNull(coefficients);
|
||||
|
@ -393,6 +394,7 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Dif
|
|||
*/
|
||||
public static class Parametric implements ParametricUnivariateFunction {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[] gradient(double x, double ... parameters) {
|
||||
final double[] gradient = new double[parameters.length];
|
||||
double xn = 1.0;
|
||||
|
@ -404,6 +406,7 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Dif
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double x, final double ... parameters)
|
||||
throws NoDataException {
|
||||
return PolynomialFunction.evaluate(parameters, x);
|
||||
|
|
|
@ -100,6 +100,7 @@ public class PolynomialFunctionNewtonForm implements UnivariateDifferentiableFun
|
|||
* {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
verifyInputArray(a, c);
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@ public class PolynomialSplineFunction implements UnivariateDifferentiableFunctio
|
|||
/** {@inheritDoc}
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public DerivativeStructure value(final DerivativeStructure t) {
|
||||
final double t0 = t.getValue();
|
||||
if (t0 < knots[0] || t0 > knots[n]) {
|
||||
|
|
|
@ -106,6 +106,7 @@ public class PolynomialsUtils {
|
|||
new RecurrenceCoefficientsGenerator() {
|
||||
private final BigFraction[] coeffs = { BigFraction.ZERO, BigFraction.TWO, BigFraction.ONE };
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public BigFraction[] generate(int k) {
|
||||
return coeffs;
|
||||
}
|
||||
|
@ -130,6 +131,7 @@ public class PolynomialsUtils {
|
|||
return buildPolynomial(degree, HERMITE_COEFFICIENTS,
|
||||
new RecurrenceCoefficientsGenerator() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public BigFraction[] generate(int k) {
|
||||
return new BigFraction[] {
|
||||
BigFraction.ZERO,
|
||||
|
@ -156,6 +158,7 @@ public class PolynomialsUtils {
|
|||
return buildPolynomial(degree, LAGUERRE_COEFFICIENTS,
|
||||
new RecurrenceCoefficientsGenerator() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public BigFraction[] generate(int k) {
|
||||
final int kP1 = k + 1;
|
||||
return new BigFraction[] {
|
||||
|
@ -183,6 +186,7 @@ public class PolynomialsUtils {
|
|||
return buildPolynomial(degree, LEGENDRE_COEFFICIENTS,
|
||||
new RecurrenceCoefficientsGenerator() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public BigFraction[] generate(int k) {
|
||||
final int kP1 = k + 1;
|
||||
return new BigFraction[] {
|
||||
|
@ -233,6 +237,7 @@ public class PolynomialsUtils {
|
|||
return buildPolynomial(degree, JACOBI_COEFFICIENTS.get(key),
|
||||
new RecurrenceCoefficientsGenerator() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public BigFraction[] generate(int k) {
|
||||
k++;
|
||||
final int kvw = k + v + w;
|
||||
|
|
|
@ -101,10 +101,12 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getMaxEvaluations() {
|
||||
return evaluations.getMaximalCount();
|
||||
}
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getEvaluations() {
|
||||
return evaluations.getCount();
|
||||
}
|
||||
|
@ -129,18 +131,21 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public double getAbsoluteAccuracy() {
|
||||
return absoluteAccuracy;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public double getRelativeAccuracy() {
|
||||
return relativeAccuracy;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public double getFunctionValueAccuracy() {
|
||||
return functionValueAccuracy;
|
||||
}
|
||||
|
@ -189,6 +194,7 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double solve(int maxEval, FUNC f, double min, double max, double startValue)
|
||||
throws TooManyEvaluationsException,
|
||||
NoBracketingException {
|
||||
|
@ -200,11 +206,13 @@ public abstract class BaseAbstractUnivariateSolver<FUNC extends UnivariateFuncti
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double solve(int maxEval, FUNC f, double min, double max) {
|
||||
return solve(maxEval, f, min, max, min + 0.5 * (max - min));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double solve(int maxEval, FUNC f, double startValue)
|
||||
throws TooManyEvaluationsException,
|
||||
NoBracketingException {
|
||||
|
|
|
@ -103,6 +103,7 @@ public abstract class BaseSecantSolver
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double solve(final int maxEval, final UnivariateFunction f,
|
||||
final double min, final double max,
|
||||
final AllowedSolution allowedSolution) {
|
||||
|
@ -110,6 +111,7 @@ public abstract class BaseSecantSolver
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double solve(final int maxEval, final UnivariateFunction f,
|
||||
final double min, final double max, final double startValue,
|
||||
final AllowedSolution allowedSolution) {
|
||||
|
|
|
@ -389,6 +389,7 @@ public class BracketingNthOrderBrentSolver
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double solve(int maxEval, UnivariateFunction f, double min,
|
||||
double max, AllowedSolution allowedSolution)
|
||||
throws TooManyEvaluationsException,
|
||||
|
@ -399,6 +400,7 @@ public class BracketingNthOrderBrentSolver
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double solve(int maxEval, UnivariateFunction f, double min,
|
||||
double max, double startValue,
|
||||
AllowedSolution allowedSolution)
|
||||
|
|
|
@ -116,6 +116,7 @@ public abstract class AbstractCurveFitter {
|
|||
public MultivariateVectorFunction getModelFunction() {
|
||||
return new MultivariateVectorFunction() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[] value(double[] p) {
|
||||
final int len = points.length;
|
||||
final double[] values = new double[len];
|
||||
|
|
|
@ -48,6 +48,7 @@ public abstract class AbstractEvaluation implements Evaluation {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix getCovariances(double threshold) {
|
||||
// Set up the Jacobian.
|
||||
final RealMatrix j = this.getJacobian();
|
||||
|
@ -62,6 +63,7 @@ public abstract class AbstractEvaluation implements Evaluation {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getSigma(double covarianceSingularityThreshold) {
|
||||
final RealMatrix cov = this.getCovariances(covarianceSingularityThreshold);
|
||||
final int nC = cov.getColumnDimension();
|
||||
|
@ -73,22 +75,26 @@ public abstract class AbstractEvaluation implements Evaluation {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getRMS() {
|
||||
return FastMath.sqrt(getReducedChiSquare(1));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getCost() {
|
||||
return FastMath.sqrt(getChiSquare());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getChiSquare() {
|
||||
final ArrayRealVector r = new ArrayRealVector(getResiduals());
|
||||
return r.dotProduct(r);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getReducedChiSquare(int numberOfFittedParameters) {
|
||||
return getChiSquare() / (observationSize - numberOfFittedParameters + 1);
|
||||
}
|
||||
|
|
|
@ -49,11 +49,13 @@ class DenseWeightedEvaluation extends AbstractEvaluation {
|
|||
/* apply weights */
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix getJacobian() {
|
||||
return weightSqrt.multiply(this.unweighted.getJacobian());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getResiduals() {
|
||||
return this.weightSqrt.operate(this.unweighted.getResiduals());
|
||||
}
|
||||
|
@ -61,6 +63,7 @@ class DenseWeightedEvaluation extends AbstractEvaluation {
|
|||
/* delegate */
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getPoint() {
|
||||
return unweighted.getPoint();
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ public class EvaluationRmsChecker implements ConvergenceChecker<Evaluation> {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean converged(final int iteration,
|
||||
final Evaluation previous,
|
||||
final Evaluation current) {
|
||||
|
|
|
@ -204,6 +204,7 @@ public class GaussNewtonOptimizer implements LeastSquaresOptimizer {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Optimum optimize(final LeastSquaresProblem lsp) {
|
||||
//create local evaluation and iteration counts
|
||||
final Incrementor evaluationCounter = lsp.getEvaluationCounter();
|
||||
|
|
|
@ -40,37 +40,44 @@ public class LeastSquaresAdapter implements LeastSquaresProblem {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getStart() {
|
||||
return problem.getStart();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getObservationSize() {
|
||||
return problem.getObservationSize();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getParameterSize() {
|
||||
return problem.getParameterSize();
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
* @param point*/
|
||||
@Override
|
||||
public Evaluation evaluate(final RealVector point) {
|
||||
return problem.evaluate(point);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Incrementor getEvaluationCounter() {
|
||||
return problem.getEvaluationCounter();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Incrementor getIterationCounter() {
|
||||
return problem.getIterationCounter();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ConvergenceChecker<Evaluation> getConvergenceChecker() {
|
||||
return problem.getConvergenceChecker();
|
||||
}
|
||||
|
|
|
@ -321,6 +321,7 @@ public class LeastSquaresFactory {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Pair<RealVector, RealMatrix> value(final RealVector point) {
|
||||
//TODO get array from RealVector without copying?
|
||||
final double[] p = point.toArray();
|
||||
|
@ -331,11 +332,13 @@ public class LeastSquaresFactory {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector computeValue(final double[] params) {
|
||||
return new ArrayRealVector(value.value(params), false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix computeJacobian(final double[] params) {
|
||||
return new Array2DRowRealMatrix(jacobian.value(params), false);
|
||||
}
|
||||
|
@ -400,21 +403,25 @@ public class LeastSquaresFactory {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getObservationSize() {
|
||||
return target.getDimension();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getParameterSize() {
|
||||
return start.getDimension();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getStart() {
|
||||
return start == null ? null : start.copy();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Evaluation evaluate(final RealVector point) {
|
||||
// Copy so optimizer can change point without changing our instance.
|
||||
final RealVector p = paramValidator == null ?
|
||||
|
@ -465,16 +472,19 @@ public class LeastSquaresFactory {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix getJacobian() {
|
||||
return jacobian;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getResiduals() {
|
||||
return residuals;
|
||||
}
|
||||
|
@ -509,16 +519,19 @@ public class LeastSquaresFactory {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix getJacobian() {
|
||||
return model.computeJacobian(point.toArray());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getResiduals() {
|
||||
return target.subtract(model.computeValue(point.toArray()));
|
||||
}
|
||||
|
|
|
@ -293,6 +293,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Optimum optimize(final LeastSquaresProblem problem) {
|
||||
// Pull in relevant data from the problem as locals.
|
||||
final int nR = problem.getObservationSize(); // Number of observed data.
|
||||
|
|
|
@ -51,56 +51,67 @@ class OptimumImpl implements Optimum {
|
|||
/* auto-generated implementations */
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getEvaluations() {
|
||||
return evaluations;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getIterations() {
|
||||
return iterations;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix getCovariances(double threshold) {
|
||||
return value.getCovariances(threshold);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getSigma(double covarianceSingularityThreshold) {
|
||||
return value.getSigma(covarianceSingularityThreshold);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getRMS() {
|
||||
return value.getRMS();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix getJacobian() {
|
||||
return value.getJacobian();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getCost() {
|
||||
return value.getCost();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getChiSquare() {
|
||||
return value.getChiSquare();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getReducedChiSquare(int n) {
|
||||
return value.getReducedChiSquare(n);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getResiduals() {
|
||||
return value.getResiduals();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getPoint() {
|
||||
return value.getPoint();
|
||||
}
|
||||
|
|
|
@ -124,19 +124,23 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Field<T> getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract FieldMatrix<T> createMatrix(final int rowDimension,
|
||||
final int columnDimension)
|
||||
throws NotStrictlyPositiveException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract FieldMatrix<T> copy();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> add(FieldMatrix<T> m)
|
||||
throws MatrixDimensionMismatchException {
|
||||
// safety check
|
||||
|
@ -155,6 +159,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> subtract(final FieldMatrix<T> m)
|
||||
throws MatrixDimensionMismatchException {
|
||||
// safety check
|
||||
|
@ -173,6 +178,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> scalarAdd(final T d) {
|
||||
|
||||
final int rowCount = getRowDimension();
|
||||
|
@ -188,6 +194,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> scalarMultiply(final T d) {
|
||||
final int rowCount = getRowDimension();
|
||||
final int columnCount = getColumnDimension();
|
||||
|
@ -202,6 +209,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> multiply(final FieldMatrix<T> m)
|
||||
throws DimensionMismatchException {
|
||||
// safety check
|
||||
|
@ -225,12 +233,14 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> preMultiply(final FieldMatrix<T> m)
|
||||
throws DimensionMismatchException {
|
||||
return m.multiply(this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> power(final int p) throws NonSquareMatrixException,
|
||||
NotPositiveException {
|
||||
if (p < 0) {
|
||||
|
@ -290,6 +300,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T[][] getData() {
|
||||
final T[][] data = MathArrays.buildArray(field, getRowDimension(), getColumnDimension());
|
||||
|
||||
|
@ -304,6 +315,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> getSubMatrix(final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
throws NumberIsTooSmallException, OutOfRangeException {
|
||||
|
@ -322,6 +334,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> getSubMatrix(final int[] selectedRows,
|
||||
final int[] selectedColumns)
|
||||
throws NoDataException, NullArgumentException, OutOfRangeException {
|
||||
|
@ -347,6 +360,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void copySubMatrix(final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn,
|
||||
final T[][] destination)
|
||||
|
@ -392,6 +406,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void copySubMatrix(int[] selectedRows, int[] selectedColumns, T[][] destination)
|
||||
throws MatrixDimensionMismatchException, NoDataException,
|
||||
NullArgumentException, OutOfRangeException {
|
||||
|
@ -416,6 +431,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setSubMatrix(final T[][] subMatrix, final int row,
|
||||
final int column)
|
||||
throws DimensionMismatchException, OutOfRangeException,
|
||||
|
@ -452,6 +468,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> getRowMatrix(final int row) throws OutOfRangeException {
|
||||
checkRowIndex(row);
|
||||
final int nCols = getColumnDimension();
|
||||
|
@ -465,6 +482,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setRowMatrix(final int row, final FieldMatrix<T> matrix)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
checkRowIndex(row);
|
||||
|
@ -482,6 +500,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> getColumnMatrix(final int column)
|
||||
throws OutOfRangeException {
|
||||
|
||||
|
@ -497,6 +516,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setColumnMatrix(final int column, final FieldMatrix<T> matrix)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
checkColumnIndex(column);
|
||||
|
@ -514,12 +534,14 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> getRowVector(final int row)
|
||||
throws OutOfRangeException {
|
||||
return new ArrayFieldVector<T>(field, getRow(row), false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setRowVector(final int row, final FieldVector<T> vector)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
checkRowIndex(row);
|
||||
|
@ -535,12 +557,14 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> getColumnVector(final int column)
|
||||
throws OutOfRangeException {
|
||||
return new ArrayFieldVector<T>(field, getColumn(column), false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setColumnVector(final int column, final FieldVector<T> vector)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
|
||||
|
@ -557,6 +581,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T[] getRow(final int row) throws OutOfRangeException {
|
||||
checkRowIndex(row);
|
||||
final int nCols = getColumnDimension();
|
||||
|
@ -570,6 +595,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setRow(final int row, final T[] array)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
checkRowIndex(row);
|
||||
|
@ -584,6 +610,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T[] getColumn(final int column) throws OutOfRangeException {
|
||||
checkColumnIndex(column);
|
||||
final int nRows = getRowDimension();
|
||||
|
@ -597,6 +624,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setColumn(final int column, final T[] array)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
checkColumnIndex(column);
|
||||
|
@ -610,18 +638,23 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract T getEntry(int row, int column) throws OutOfRangeException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract void setEntry(int row, int column, T value) throws OutOfRangeException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract void addToEntry(int row, int column, T increment) throws OutOfRangeException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract void multiplyEntry(int row, int column, T factor) throws OutOfRangeException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> transpose() {
|
||||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
|
@ -638,17 +671,21 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isSquare() {
|
||||
return getColumnDimension() == getRowDimension();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract int getRowDimension();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract int getColumnDimension();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T getTrace() throws NonSquareMatrixException {
|
||||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
|
@ -663,6 +700,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T[] operate(final T[] v) throws DimensionMismatchException {
|
||||
|
||||
final int nRows = getRowDimension();
|
||||
|
@ -684,6 +722,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> operate(final FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
try {
|
||||
|
@ -709,6 +748,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T[] preMultiply(final T[] v) throws DimensionMismatchException {
|
||||
|
||||
final int nRows = getRowDimension();
|
||||
|
@ -730,6 +770,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> preMultiply(final FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
try {
|
||||
|
@ -755,6 +796,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInRowOrder(final FieldMatrixChangingVisitor<T> visitor) {
|
||||
final int rows = getRowDimension();
|
||||
final int columns = getColumnDimension();
|
||||
|
@ -770,6 +812,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInRowOrder(final FieldMatrixPreservingVisitor<T> visitor) {
|
||||
final int rows = getRowDimension();
|
||||
final int columns = getColumnDimension();
|
||||
|
@ -783,6 +826,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInRowOrder(final FieldMatrixChangingVisitor<T> visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
|
@ -801,6 +845,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInRowOrder(final FieldMatrixPreservingVisitor<T> visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
|
@ -817,6 +862,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInColumnOrder(final FieldMatrixChangingVisitor<T> visitor) {
|
||||
final int rows = getRowDimension();
|
||||
final int columns = getColumnDimension();
|
||||
|
@ -832,6 +878,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInColumnOrder(final FieldMatrixPreservingVisitor<T> visitor) {
|
||||
final int rows = getRowDimension();
|
||||
final int columns = getColumnDimension();
|
||||
|
@ -845,6 +892,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInColumnOrder(final FieldMatrixChangingVisitor<T> visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
|
@ -863,6 +911,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInColumnOrder(final FieldMatrixPreservingVisitor<T> visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
|
@ -879,16 +928,19 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInOptimizedOrder(final FieldMatrixChangingVisitor<T> visitor) {
|
||||
return walkInRowOrder(visitor);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInOptimizedOrder(final FieldMatrixPreservingVisitor<T> visitor) {
|
||||
return walkInRowOrder(visitor);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInOptimizedOrder(final FieldMatrixChangingVisitor<T> visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
|
@ -897,6 +949,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T walkInOptimizedOrder(final FieldMatrixPreservingVisitor<T> visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
|
|
|
@ -73,6 +73,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix add(RealMatrix m)
|
||||
throws MatrixDimensionMismatchException {
|
||||
MatrixUtils.checkAdditionCompatible(this, m);
|
||||
|
@ -90,6 +91,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix subtract(final RealMatrix m)
|
||||
throws MatrixDimensionMismatchException {
|
||||
MatrixUtils.checkSubtractionCompatible(this, m);
|
||||
|
@ -107,6 +109,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix scalarAdd(final double d) {
|
||||
final int rowCount = getRowDimension();
|
||||
final int columnCount = getColumnDimension();
|
||||
|
@ -121,6 +124,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix scalarMultiply(final double d) {
|
||||
final int rowCount = getRowDimension();
|
||||
final int columnCount = getColumnDimension();
|
||||
|
@ -135,6 +139,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix multiply(final RealMatrix m)
|
||||
throws DimensionMismatchException {
|
||||
MatrixUtils.checkMultiplicationCompatible(this, m);
|
||||
|
@ -157,12 +162,14 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix preMultiply(final RealMatrix m)
|
||||
throws DimensionMismatchException {
|
||||
return m.multiply(this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix power(final int p)
|
||||
throws NotPositiveException, NonSquareMatrixException {
|
||||
if (p < 0) {
|
||||
|
@ -223,6 +230,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[][] getData() {
|
||||
final double[][] data = new double[getRowDimension()][getColumnDimension()];
|
||||
|
||||
|
@ -237,6 +245,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getNorm() {
|
||||
return walkInColumnOrder(new RealMatrixPreservingVisitor() {
|
||||
|
||||
|
@ -250,6 +259,7 @@ public abstract class AbstractRealMatrix
|
|||
private double maxColSum;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void start(final int rows, final int columns,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn) {
|
||||
|
@ -259,6 +269,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void visit(final int row, final int column, final double value) {
|
||||
columnSum += FastMath.abs(value);
|
||||
if (row == endRow) {
|
||||
|
@ -268,6 +279,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double end() {
|
||||
return maxColSum;
|
||||
}
|
||||
|
@ -275,6 +287,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getFrobeniusNorm() {
|
||||
return walkInOptimizedOrder(new RealMatrixPreservingVisitor() {
|
||||
|
||||
|
@ -282,6 +295,7 @@ public abstract class AbstractRealMatrix
|
|||
private double sum;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void start(final int rows, final int columns,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn) {
|
||||
|
@ -289,11 +303,13 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void visit(final int row, final int column, final double value) {
|
||||
sum += value * value;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double end() {
|
||||
return FastMath.sqrt(sum);
|
||||
}
|
||||
|
@ -301,6 +317,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix getSubMatrix(final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
throws OutOfRangeException, NumberIsTooSmallException {
|
||||
|
@ -318,6 +335,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix getSubMatrix(final int[] selectedRows,
|
||||
final int[] selectedColumns)
|
||||
throws NullArgumentException, NoDataException, OutOfRangeException {
|
||||
|
@ -339,6 +357,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void copySubMatrix(final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn,
|
||||
final double[][] destination)
|
||||
|
@ -386,6 +405,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void copySubMatrix(int[] selectedRows, int[] selectedColumns,
|
||||
double[][] destination)
|
||||
throws OutOfRangeException, NullArgumentException, NoDataException,
|
||||
|
@ -411,6 +431,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setSubMatrix(final double[][] subMatrix, final int row, final int column)
|
||||
throws NoDataException, OutOfRangeException,
|
||||
DimensionMismatchException, NullArgumentException {
|
||||
|
@ -444,6 +465,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix getRowMatrix(final int row) throws OutOfRangeException {
|
||||
MatrixUtils.checkRowIndex(this, row);
|
||||
final int nCols = getColumnDimension();
|
||||
|
@ -456,6 +478,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setRowMatrix(final int row, final RealMatrix matrix)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
MatrixUtils.checkRowIndex(this, row);
|
||||
|
@ -472,6 +495,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix getColumnMatrix(final int column)
|
||||
throws OutOfRangeException {
|
||||
MatrixUtils.checkColumnIndex(this, column);
|
||||
|
@ -485,6 +509,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setColumnMatrix(final int column, final RealMatrix matrix)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
MatrixUtils.checkColumnIndex(this, column);
|
||||
|
@ -501,12 +526,14 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getRowVector(final int row)
|
||||
throws OutOfRangeException {
|
||||
return new ArrayRealVector(getRow(row), false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setRowVector(final int row, final RealVector vector)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
MatrixUtils.checkRowIndex(this, row);
|
||||
|
@ -521,12 +548,14 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector getColumnVector(final int column)
|
||||
throws OutOfRangeException {
|
||||
return new ArrayRealVector(getColumn(column), false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setColumnVector(final int column, final RealVector vector)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
MatrixUtils.checkColumnIndex(this, column);
|
||||
|
@ -541,6 +570,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[] getRow(final int row) throws OutOfRangeException {
|
||||
MatrixUtils.checkRowIndex(this, row);
|
||||
final int nCols = getColumnDimension();
|
||||
|
@ -553,6 +583,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setRow(final int row, final double[] array)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
MatrixUtils.checkRowIndex(this, row);
|
||||
|
@ -566,6 +597,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[] getColumn(final int column) throws OutOfRangeException {
|
||||
MatrixUtils.checkColumnIndex(this, column);
|
||||
final int nRows = getRowDimension();
|
||||
|
@ -578,6 +610,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setColumn(final int column, final double[] array)
|
||||
throws OutOfRangeException, MatrixDimensionMismatchException {
|
||||
MatrixUtils.checkColumnIndex(this, column);
|
||||
|
@ -591,6 +624,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void addToEntry(int row, int column, double increment)
|
||||
throws OutOfRangeException {
|
||||
MatrixUtils.checkMatrixIndex(this, row, column);
|
||||
|
@ -598,6 +632,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void multiplyEntry(int row, int column, double factor)
|
||||
throws OutOfRangeException {
|
||||
MatrixUtils.checkMatrixIndex(this, row, column);
|
||||
|
@ -605,6 +640,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix transpose() {
|
||||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
|
@ -623,6 +659,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isSquare() {
|
||||
return getColumnDimension() == getRowDimension();
|
||||
}
|
||||
|
@ -644,6 +681,7 @@ public abstract class AbstractRealMatrix
|
|||
public abstract int getColumnDimension();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getTrace() throws NonSquareMatrixException {
|
||||
final int nRows = getRowDimension();
|
||||
final int nCols = getColumnDimension();
|
||||
|
@ -658,6 +696,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[] operate(final double[] v)
|
||||
throws DimensionMismatchException {
|
||||
final int nRows = getRowDimension();
|
||||
|
@ -705,6 +744,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double[] preMultiply(final double[] v) throws DimensionMismatchException {
|
||||
|
||||
final int nRows = getRowDimension();
|
||||
|
@ -726,6 +766,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector preMultiply(final RealVector v) throws DimensionMismatchException {
|
||||
try {
|
||||
return new ArrayRealVector(preMultiply(((ArrayRealVector) v).getDataRef()), false);
|
||||
|
@ -751,6 +792,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInRowOrder(final RealMatrixChangingVisitor visitor) {
|
||||
final int rows = getRowDimension();
|
||||
final int columns = getColumnDimension();
|
||||
|
@ -766,6 +808,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInRowOrder(final RealMatrixPreservingVisitor visitor) {
|
||||
final int rows = getRowDimension();
|
||||
final int columns = getColumnDimension();
|
||||
|
@ -779,6 +822,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInRowOrder(final RealMatrixChangingVisitor visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
|
@ -797,6 +841,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInRowOrder(final RealMatrixPreservingVisitor visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
|
@ -813,6 +858,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInColumnOrder(final RealMatrixChangingVisitor visitor) {
|
||||
final int rows = getRowDimension();
|
||||
final int columns = getColumnDimension();
|
||||
|
@ -828,6 +874,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInColumnOrder(final RealMatrixPreservingVisitor visitor) {
|
||||
final int rows = getRowDimension();
|
||||
final int columns = getColumnDimension();
|
||||
|
@ -841,6 +888,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInColumnOrder(final RealMatrixChangingVisitor visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
|
@ -859,6 +907,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInColumnOrder(final RealMatrixPreservingVisitor visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn, final int endColumn)
|
||||
|
@ -875,16 +924,19 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInOptimizedOrder(final RealMatrixChangingVisitor visitor) {
|
||||
return walkInRowOrder(visitor);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInOptimizedOrder(final RealMatrixPreservingVisitor visitor) {
|
||||
return walkInRowOrder(visitor);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInOptimizedOrder(final RealMatrixChangingVisitor visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn,
|
||||
|
@ -894,6 +946,7 @@ public abstract class AbstractRealMatrix
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double walkInOptimizedOrder(final RealMatrixPreservingVisitor visitor,
|
||||
final int startRow, final int endRow,
|
||||
final int startColumn,
|
||||
|
@ -976,17 +1029,21 @@ public abstract class AbstractRealMatrix
|
|||
*/
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract RealMatrix createMatrix(int rowDimension, int columnDimension)
|
||||
throws NotStrictlyPositiveException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract RealMatrix copy();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract double getEntry(int row, int column)
|
||||
throws OutOfRangeException;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public abstract void setEntry(int row, int column, double value)
|
||||
throws OutOfRangeException;
|
||||
}
|
||||
|
|
|
@ -380,16 +380,19 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Field<T> getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> copy() {
|
||||
return new ArrayFieldVector<T>(this, true);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> add(FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
try {
|
||||
|
@ -422,6 +425,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> subtract(FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
try {
|
||||
|
@ -454,6 +458,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapAdd(T d) throws NullArgumentException {
|
||||
T[] out = MathArrays.buildArray(field, data.length);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
|
@ -463,6 +468,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapAddToSelf(T d) throws NullArgumentException {
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = data[i].add(d);
|
||||
|
@ -471,6 +477,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapSubtract(T d) throws NullArgumentException {
|
||||
T[] out = MathArrays.buildArray(field, data.length);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
|
@ -480,6 +487,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapSubtractToSelf(T d) throws NullArgumentException {
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = data[i].subtract(d);
|
||||
|
@ -488,6 +496,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapMultiply(T d) throws NullArgumentException {
|
||||
T[] out = MathArrays.buildArray(field, data.length);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
|
@ -497,6 +506,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapMultiplyToSelf(T d) throws NullArgumentException {
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = data[i].multiply(d);
|
||||
|
@ -505,6 +515,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapDivide(T d)
|
||||
throws NullArgumentException, MathArithmeticException {
|
||||
MathUtils.checkNotNull(d);
|
||||
|
@ -516,6 +527,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapDivideToSelf(T d)
|
||||
throws NullArgumentException, MathArithmeticException {
|
||||
MathUtils.checkNotNull(d);
|
||||
|
@ -526,6 +538,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapInv() throws MathArithmeticException {
|
||||
T[] out = MathArrays.buildArray(field, data.length);
|
||||
final T one = field.getOne();
|
||||
|
@ -540,6 +553,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapInvToSelf() throws MathArithmeticException {
|
||||
final T one = field.getOne();
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
|
@ -553,6 +567,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> ebeMultiply(FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
try {
|
||||
|
@ -585,6 +600,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> ebeDivide(FieldVector<T> v)
|
||||
throws DimensionMismatchException, MathArithmeticException {
|
||||
try {
|
||||
|
@ -635,6 +651,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T dotProduct(FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
try {
|
||||
|
@ -667,6 +684,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> projection(FieldVector<T> v)
|
||||
throws DimensionMismatchException, MathArithmeticException {
|
||||
return v.mapMultiply(dotProduct(v).divide(v.dotProduct(v)));
|
||||
|
@ -685,6 +703,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> outerProduct(FieldVector<T> v) {
|
||||
try {
|
||||
return outerProduct((ArrayFieldVector<T>) v);
|
||||
|
@ -719,16 +738,19 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T getEntry(int index) {
|
||||
return data[index];
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getDimension() {
|
||||
return data.length;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> append(FieldVector<T> v) {
|
||||
try {
|
||||
return append((ArrayFieldVector<T>) v);
|
||||
|
@ -747,6 +769,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> append(T in) {
|
||||
final T[] out = MathArrays.buildArray(field, data.length + 1);
|
||||
System.arraycopy(data, 0, out, 0, data.length);
|
||||
|
@ -755,6 +778,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> getSubVector(int index, int n)
|
||||
throws OutOfRangeException, NotPositiveException {
|
||||
if (n < 0) {
|
||||
|
@ -771,6 +795,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setEntry(int index, T value) {
|
||||
try {
|
||||
data[index] = value;
|
||||
|
@ -780,6 +805,7 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setSubVector(int index, FieldVector<T> v) throws OutOfRangeException {
|
||||
try {
|
||||
try {
|
||||
|
@ -812,11 +838,13 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector<
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void set(T value) {
|
||||
Arrays.fill(data, value);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T[] toArray(){
|
||||
return data.clone();
|
||||
}
|
||||
|
|
|
@ -216,12 +216,14 @@ public class CholeskyDecomposition {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isNonSingular() {
|
||||
// if we get this far, the matrix was positive definite, hence non-singular
|
||||
return true;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector solve(final RealVector b) {
|
||||
final int m = lTData.length;
|
||||
if (b.getDimension() != m) {
|
||||
|
@ -253,6 +255,7 @@ public class CholeskyDecomposition {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix solve(RealMatrix b) {
|
||||
final int m = lTData.length;
|
||||
if (b.getRowDimension() != m) {
|
||||
|
|
|
@ -42,16 +42,19 @@ public class DefaultFieldMatrixChangingVisitor<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void start(int rows, int columns,
|
||||
int startRow, int endRow, int startColumn, int endColumn) {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T visit(int row, int column, T value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T end() {
|
||||
return zero;
|
||||
}
|
||||
|
|
|
@ -42,14 +42,17 @@ public class DefaultFieldMatrixPreservingVisitor<T extends FieldElement<T>>
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void start(int rows, int columns,
|
||||
int startRow, int endRow, int startColumn, int endColumn) {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void visit(int row, int column, T value) {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T end() {
|
||||
return zero;
|
||||
}
|
||||
|
|
|
@ -28,16 +28,19 @@ package org.apache.commons.math4.linear;
|
|||
*/
|
||||
public class DefaultRealMatrixChangingVisitor implements RealMatrixChangingVisitor {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void start(int rows, int columns,
|
||||
int startRow, int endRow, int startColumn, int endColumn) {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double visit(int row, int column, double value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double end() {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -28,14 +28,17 @@ package org.apache.commons.math4.linear;
|
|||
*/
|
||||
public class DefaultRealMatrixPreservingVisitor implements RealMatrixPreservingVisitor {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void start(int rows, int columns,
|
||||
int startRow, int endRow, int startColumn, int endColumn) {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void visit(int row, int column, double value) {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double end() {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -434,6 +434,7 @@ public class EigenDecomposition {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix solve(RealMatrix b) {
|
||||
|
||||
if (!isNonSingular()) {
|
||||
|
|
|
@ -287,11 +287,13 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isNonSingular() {
|
||||
return !singular;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> solve(FieldVector<T> b) {
|
||||
try {
|
||||
return solve((ArrayFieldVector<T>) b);
|
||||
|
@ -377,6 +379,7 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> solve(FieldMatrix<T> b) {
|
||||
final int m = pivot.length;
|
||||
if (b.getRowDimension() != m) {
|
||||
|
@ -431,6 +434,7 @@ public class FieldLUDecomposition<T extends FieldElement<T>> {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> getInverse() {
|
||||
final int m = pivot.length;
|
||||
final T one = field.getOne();
|
||||
|
|
|
@ -282,11 +282,13 @@ public class LUDecomposition {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isNonSingular() {
|
||||
return !singular;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector solve(RealVector b) {
|
||||
final int m = pivot.length;
|
||||
if (b.getDimension() != m) {
|
||||
|
@ -324,6 +326,7 @@ public class LUDecomposition {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix solve(RealMatrix b) {
|
||||
|
||||
final int m = pivot.length;
|
||||
|
|
|
@ -791,17 +791,20 @@ public class OpenMapRealVector extends SparseRealVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return iter.hasNext();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Entry next() {
|
||||
iter.advance();
|
||||
return current;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Not supported");
|
||||
}
|
||||
|
|
|
@ -219,16 +219,19 @@ public class RRQRDecomposition extends QRDecomposition {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isNonSingular() {
|
||||
return upper.isNonSingular();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector solve(RealVector b) {
|
||||
return p.operate(upper.solve(b));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealMatrix solve(RealMatrix b) {
|
||||
return p.multiply(upper.solve(b));
|
||||
}
|
||||
|
@ -237,6 +240,7 @@ public class RRQRDecomposition extends QRDecomposition {
|
|||
* {@inheritDoc}
|
||||
* @throws SingularMatrixException if the decomposed matrix is singular.
|
||||
*/
|
||||
@Override
|
||||
public RealMatrix getInverse() {
|
||||
return solve(MatrixUtils.createRealIdentityMatrix(p.getRowDimension()));
|
||||
}
|
||||
|
|
|
@ -759,11 +759,13 @@ public abstract class RealVector {
|
|||
private Entry e = new Entry();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return i < dim;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Entry next() {
|
||||
if (i < dim) {
|
||||
e.setIndex(i++);
|
||||
|
@ -778,6 +780,7 @@ public abstract class RealVector {
|
|||
*
|
||||
* @throws MathUnsupportedOperationException in all circumstances.
|
||||
*/
|
||||
@Override
|
||||
public void remove() throws MathUnsupportedOperationException {
|
||||
throw new MathUnsupportedOperationException();
|
||||
}
|
||||
|
@ -1159,11 +1162,13 @@ public abstract class RealVector {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return next.getIndex() >= 0;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Entry next() {
|
||||
int index = next.getIndex();
|
||||
if (index < 0) {
|
||||
|
@ -1179,6 +1184,7 @@ public abstract class RealVector {
|
|||
*
|
||||
* @throws MathUnsupportedOperationException in all circumstances.
|
||||
*/
|
||||
@Override
|
||||
public void remove() throws MathUnsupportedOperationException {
|
||||
throw new MathUnsupportedOperationException();
|
||||
}
|
||||
|
@ -1239,11 +1245,13 @@ public abstract class RealVector {
|
|||
private final UnmodifiableEntry e = new UnmodifiableEntry();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return i.hasNext();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Entry next() {
|
||||
e.setIndex(i.next().getIndex());
|
||||
return e;
|
||||
|
@ -1255,6 +1263,7 @@ public abstract class RealVector {
|
|||
* @throws MathUnsupportedOperationException in all
|
||||
* circumstances.
|
||||
*/
|
||||
@Override
|
||||
public void remove() throws MathUnsupportedOperationException {
|
||||
throw new MathUnsupportedOperationException();
|
||||
}
|
||||
|
@ -1271,11 +1280,13 @@ public abstract class RealVector {
|
|||
private final UnmodifiableEntry e = new UnmodifiableEntry();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return i.hasNext();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Entry next() {
|
||||
e.setIndex(i.next().getIndex());
|
||||
return e;
|
||||
|
@ -1287,6 +1298,7 @@ public abstract class RealVector {
|
|||
* @throws MathUnsupportedOperationException in all
|
||||
* circumstances.
|
||||
*/
|
||||
@Override
|
||||
public void remove()
|
||||
throws MathUnsupportedOperationException {
|
||||
throw new MathUnsupportedOperationException();
|
||||
|
|
|
@ -189,6 +189,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> append(FieldVector<T> v) {
|
||||
if (v instanceof SparseFieldVector<?>) {
|
||||
return append((SparseFieldVector<T>) v);
|
||||
|
@ -205,6 +206,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
/** {@inheritDoc}
|
||||
* @exception NullArgumentException if d is null
|
||||
*/
|
||||
@Override
|
||||
public FieldVector<T> append(T d) throws NullArgumentException {
|
||||
MathUtils.checkNotNull(d);
|
||||
FieldVector<T> res = new SparseFieldVector<T>(this, 1);
|
||||
|
@ -213,11 +215,13 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> copy() {
|
||||
return new SparseFieldVector<T>(this);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T dotProduct(FieldVector<T> v) throws DimensionMismatchException {
|
||||
checkVectorDimensions(v.getDimension());
|
||||
T res = field.getZero();
|
||||
|
@ -230,6 +234,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> ebeDivide(FieldVector<T> v)
|
||||
throws DimensionMismatchException, MathArithmeticException {
|
||||
checkVectorDimensions(v.getDimension());
|
||||
|
@ -243,6 +248,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> ebeMultiply(FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
checkVectorDimensions(v.getDimension());
|
||||
|
@ -256,22 +262,26 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getDimension() {
|
||||
return virtualSize;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T getEntry(int index) throws OutOfRangeException {
|
||||
checkIndex(index);
|
||||
return entries.get(index);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Field<T> getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> getSubVector(int index, int n)
|
||||
throws OutOfRangeException, NotPositiveException {
|
||||
if (n < 0) {
|
||||
|
@ -293,11 +303,13 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapAdd(T d) throws NullArgumentException {
|
||||
return copy().mapAddToSelf(d);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapAddToSelf(T d) throws NullArgumentException {
|
||||
for (int i = 0; i < virtualSize; i++) {
|
||||
setEntry(i, getEntry(i).add(d));
|
||||
|
@ -306,12 +318,14 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapDivide(T d)
|
||||
throws NullArgumentException, MathArithmeticException {
|
||||
return copy().mapDivideToSelf(d);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapDivideToSelf(T d)
|
||||
throws NullArgumentException, MathArithmeticException {
|
||||
OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
|
||||
|
@ -323,11 +337,13 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapInv() throws MathArithmeticException {
|
||||
return copy().mapInvToSelf();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapInvToSelf() throws MathArithmeticException {
|
||||
for (int i = 0; i < virtualSize; i++) {
|
||||
setEntry(i, field.getOne().divide(getEntry(i)));
|
||||
|
@ -336,11 +352,13 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapMultiply(T d) throws NullArgumentException {
|
||||
return copy().mapMultiplyToSelf(d);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapMultiplyToSelf(T d) throws NullArgumentException {
|
||||
OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -351,11 +369,13 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapSubtract(T d) throws NullArgumentException {
|
||||
return copy().mapSubtractToSelf(d);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> mapSubtractToSelf(T d) throws NullArgumentException {
|
||||
return mapAddToSelf(field.getZero().subtract(d));
|
||||
}
|
||||
|
@ -381,6 +401,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldMatrix<T> outerProduct(FieldVector<T> v) {
|
||||
if (v instanceof SparseFieldVector<?>) {
|
||||
return outerProduct((SparseFieldVector<T>)v);
|
||||
|
@ -401,6 +422,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> projection(FieldVector<T> v)
|
||||
throws DimensionMismatchException, MathArithmeticException {
|
||||
checkVectorDimensions(v.getDimension());
|
||||
|
@ -410,6 +432,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
/** {@inheritDoc}
|
||||
* @exception NullArgumentException if value is null
|
||||
*/
|
||||
@Override
|
||||
public void set(T value) {
|
||||
MathUtils.checkNotNull(value);
|
||||
for (int i = 0; i < virtualSize; i++) {
|
||||
|
@ -420,6 +443,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
/** {@inheritDoc}
|
||||
* @exception NullArgumentException if value is null
|
||||
*/
|
||||
@Override
|
||||
public void setEntry(int index, T value) throws NullArgumentException, OutOfRangeException {
|
||||
MathUtils.checkNotNull(value);
|
||||
checkIndex(index);
|
||||
|
@ -427,6 +451,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setSubVector(int index, FieldVector<T> v)
|
||||
throws OutOfRangeException {
|
||||
checkIndex(index);
|
||||
|
@ -462,6 +487,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> subtract(FieldVector<T> v)
|
||||
throws DimensionMismatchException {
|
||||
if (v instanceof SparseFieldVector<?>) {
|
||||
|
@ -482,6 +508,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public T[] toArray() {
|
||||
T[] res = MathArrays.buildArray(field, virtualSize);
|
||||
OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator();
|
||||
|
@ -544,6 +571,7 @@ public class SparseFieldVector<T extends FieldElement<T>> implements FieldVector
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public FieldVector<T> add(FieldVector<T> v) throws DimensionMismatchException {
|
||||
if (v instanceof SparseFieldVector<?>) {
|
||||
return add((SparseFieldVector<T>) v);
|
||||
|
|
|
@ -86,6 +86,7 @@ public class FeatureInitializerFactory {
|
|||
private double arg = init;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value() {
|
||||
final double result = f.value(arg);
|
||||
arg += inc;
|
||||
|
@ -106,6 +107,7 @@ public class FeatureInitializerFactory {
|
|||
final FeatureInitializer orig) {
|
||||
return new FeatureInitializer() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value() {
|
||||
return orig.value() + random.sample();
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ public class Network
|
|||
private static final long serialVersionUID = 20130207L;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int compare(Neuron a,
|
||||
Neuron b) {
|
||||
final long aId = a.getIdentifier();
|
||||
|
@ -138,6 +139,7 @@ public class Network
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Neuron> iterator() {
|
||||
return neuronMap.values().iterator();
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public class KohonenTrainingTask implements Runnable {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
while (featuresIterator.hasNext()) {
|
||||
updateAction.update(net, featuresIterator.next());
|
||||
|
|
|
@ -92,6 +92,7 @@ public class KohonenUpdateAction implements UpdateAction {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void update(Network net,
|
||||
double[] features) {
|
||||
final long numCalls = numberOfCalls.incrementAndGet();
|
||||
|
|
|
@ -68,6 +68,7 @@ public class LearningFactorFunctionFactory {
|
|||
= new ExponentialDecayFunction(initValue, valueAtNumCall, numCall);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(long n) {
|
||||
return decay.value(n);
|
||||
}
|
||||
|
@ -109,6 +110,7 @@ public class LearningFactorFunctionFactory {
|
|||
= new QuasiSigmoidDecayFunction(initValue, slope, numCall);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(long n) {
|
||||
return decay.value(n);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ public class NeighbourhoodSizeFunctionFactory {
|
|||
= new ExponentialDecayFunction(initValue, valueAtNumCall, numCall);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int value(long n) {
|
||||
return (int) FastMath.rint(decay.value(n));
|
||||
}
|
||||
|
@ -99,6 +100,7 @@ public class NeighbourhoodSizeFunctionFactory {
|
|||
= new QuasiSigmoidDecayFunction(initValue, slope, numCall);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int value(long n) {
|
||||
return (int) FastMath.rint(decay.value(n));
|
||||
}
|
||||
|
|
|
@ -99,26 +99,31 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void addStepHandler(final StepHandler handler) {
|
||||
stepHandlers.add(handler);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Collection<StepHandler> getStepHandlers() {
|
||||
return Collections.unmodifiableCollection(stepHandlers);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void clearStepHandlers() {
|
||||
stepHandlers.clear();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void addEventHandler(final EventHandler handler,
|
||||
final double maxCheckInterval,
|
||||
final double convergence,
|
||||
|
@ -129,6 +134,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void addEventHandler(final EventHandler handler,
|
||||
final double maxCheckInterval,
|
||||
final double convergence,
|
||||
|
@ -139,6 +145,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Collection<EventHandler> getEventHandlers() {
|
||||
final List<EventHandler> list = new ArrayList<EventHandler>(eventsStates.size());
|
||||
for (EventState state : eventsStates) {
|
||||
|
@ -148,31 +155,37 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void clearEventHandlers() {
|
||||
eventsStates.clear();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getCurrentStepStart() {
|
||||
return stepStart;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getCurrentSignedStepsize() {
|
||||
return stepSize;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setMaxEvaluations(int maxEvaluations) {
|
||||
evaluations.setMaximalCount((maxEvaluations < 0) ? Integer.MAX_VALUE : maxEvaluations);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getMaxEvaluations() {
|
||||
return evaluations.getMaximalCount();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getEvaluations() {
|
||||
return evaluations.getCount();
|
||||
}
|
||||
|
@ -223,6 +236,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double integrate(final FirstOrderDifferentialEquations equations,
|
||||
final double t0, final double[] y0, final double t, final double[] y)
|
||||
throws DimensionMismatchException, NumberIsTooSmallException,
|
||||
|
@ -329,6 +343,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
SortedSet<EventState> occurringEvents = new TreeSet<EventState>(new Comparator<EventState>() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int compare(EventState es0, EventState es1) {
|
||||
return orderingSign * Double.compare(es0.getEventTime(), es1.getEventTime());
|
||||
}
|
||||
|
|
|
@ -48,11 +48,13 @@ public abstract class AbstractParameterizable implements Parameterizable {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Collection<String> getParametersNames() {
|
||||
return parametersNames;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isSupported(final String name) {
|
||||
for (final String supportedName : parametersNames) {
|
||||
if (supportedName.equals(name)) {
|
||||
|
|
|
@ -169,6 +169,7 @@ public class ContinuousOutputModel
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void init(double t0, double[] y0, double t) {
|
||||
initialTime = Double.NaN;
|
||||
finalTime = Double.NaN;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue