Skip to content

Commit 26d33a1

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents 4cd49c4 + aca805d commit 26d33a1

84 files changed

Lines changed: 507 additions & 191 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

hipparchus-core/src/changes/changes.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ If the output is not quite correct, check for invisible trailing spaces!
4949
<title>Hipparchus Core Release Notes</title>
5050
</properties>
5151
<body>
52-
<release version="TBD" date="TBD" description="TBD">
52+
<release version="4.1" date="TBD" description="TBD">
53+
<action dev="serrof" type="update" issue="issues/398">
54+
Implement non-trivial norm for CalculusField inheritors.
55+
</action>
5356
<action dev="ryan" type="update" issue="issues/391">
5457
Replaced custom FastMath implementations of
5558
sin, cos, tan, sinCos, log1p, log10, log, exp, hypot, cbrt, pow, floor, ceil, and abs
5659
with delegates to Math
5760
</action>
58-
</release>
59-
<release version="4.1" date="TBD" description="TBD">
6061
<action dev="luc" type="fix" issue="issues/394">
6162
Prevent stack overflow in digamma function.
6263
</action>

hipparchus-core/src/main/java/org/hipparchus/analysis/differentiation/DerivativeStructure.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,16 @@ public DerivativeStructure linearCombination(final double a1, final DerivativeSt
10851085

10861086
}
10871087

1088+
/** {@inheritDoc} */
1089+
@Override
1090+
public double norm() {
1091+
double sum = 0;
1092+
for (final double derivative: data) {
1093+
sum += FastMath.abs(derivative);
1094+
}
1095+
return sum;
1096+
}
1097+
10881098
/** {@inheritDoc}
10891099
*/
10901100
@Override

hipparchus-core/src/main/java/org/hipparchus/analysis/differentiation/FieldDerivativeStructure.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,16 @@ public FieldDerivativeStructure<T> linearCombination(final double a1, final Fiel
13041304

13051305
}
13061306

1307+
/** {@inheritDoc} */
1308+
@Override
1309+
public double norm() {
1310+
double sum = 0.;
1311+
for (final T derivative: data) {
1312+
sum += derivative.norm();
1313+
}
1314+
return sum;
1315+
}
1316+
13071317
/** {@inheritDoc}
13081318
*/
13091319
@Override

hipparchus-core/src/main/java/org/hipparchus/analysis/differentiation/FieldGradient.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,16 @@ public FieldGradient<T> linearCombination(final double a1, final FieldGradient<T
877877
return result;
878878
}
879879

880+
/** {@inheritDoc} */
881+
@Override
882+
public double norm() {
883+
double sum = getValue().norm();
884+
for (int i = 0; i < getFreeParameters(); i++) {
885+
sum += getPartialDerivative(i).norm();
886+
}
887+
return sum;
888+
}
889+
880890
/**
881891
* Add an independent variable to the Taylor expansion.
882892
* @return object with one more variable

hipparchus-core/src/main/java/org/hipparchus/analysis/differentiation/FieldUnivariateDerivative.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,13 @@ public S getPartialDerivative(final int ... orders) throws MathIllegalArgumentEx
6868
*/
6969
public abstract FieldDerivativeStructure<S> toDerivativeStructure();
7070

71+
/** {@inheritDoc} */
72+
@Override
73+
public double norm() {
74+
double sum = 0.;
75+
for (int i = 0; i <= getOrder(); i++) {
76+
sum += getDerivative(i).norm();
77+
}
78+
return sum;
79+
}
7180
}

hipparchus-core/src/main/java/org/hipparchus/analysis/differentiation/Gradient.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,16 @@ public Gradient linearCombination(final double a1, final Gradient b1,
712712
return result;
713713
}
714714

715+
/** {@inheritDoc} */
716+
@Override
717+
public double norm() {
718+
double sum = getValue();
719+
for (int i = 0; i < getFreeParameters(); i++) {
720+
sum += FastMath.abs(getPartialDerivative(i));
721+
}
722+
return sum;
723+
}
724+
715725
/**
716726
* Add an independent variable to the Taylor expansion.
717727
* @return object with one more variable

hipparchus-core/src/main/java/org/hipparchus/analysis/differentiation/SparseGradient.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,16 @@ public SparseGradient linearCombination(final double a1, final SparseGradient b1
753753

754754
}
755755

756+
/** {@inheritDoc} */
757+
@Override
758+
public double norm() {
759+
double sum = getValue();
760+
for (final double derivative: derivatives.values()) {
761+
sum += FastMath.abs(derivative);
762+
}
763+
return sum;
764+
}
765+
756766
/** {@inheritDoc} */
757767
@Override
758768
public SparseGradient getPi() {

hipparchus-core/src/main/java/org/hipparchus/analysis/differentiation/UnivariateDerivative.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.hipparchus.exception.LocalizedCoreFormats;
2222
import org.hipparchus.exception.MathIllegalArgumentException;
23+
import org.hipparchus.util.FastMath;
2324

2425
/** Abstract class representing both the value and the differentials of a function.
2526
* @param <T> the type of the function derivative
@@ -71,4 +72,13 @@ public double getPartialDerivative(final int ... orders) throws MathIllegalArgum
7172
*/
7273
public abstract DerivativeStructure toDerivativeStructure();
7374

75+
/** {@inheritDoc} */
76+
@Override
77+
public double norm() {
78+
double sum = 0.;
79+
for (int i = 0; i <= getOrder(); i++) {
80+
sum += FastMath.abs(getDerivative(i));
81+
}
82+
return sum;
83+
}
7484
}

hipparchus-core/src/main/java/org/hipparchus/util/FieldTuple.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class FieldTuple<T extends CalculusFieldElement<T>> implements CalculusFi
3333
private final T[] values;
3434

3535
/** Field the instance belongs to. */
36-
private final transient FieldTupleField<T> field;
36+
private final FieldTupleField<T> field;
3737

3838
/** Creates a new instance from its components.
3939
* @param x components of the tuple
@@ -766,6 +766,16 @@ public FieldTuple<T> linearCombination(final double a1, final FieldTuple<T> b1,
766766
return result;
767767
}
768768

769+
/** {@inheritDoc} */
770+
@Override
771+
public double norm() {
772+
double sum = 0;
773+
for (final T value: values) {
774+
sum += value.norm();
775+
}
776+
return sum;
777+
}
778+
769779
/** {@inheritDoc} */
770780
@Override
771781
public FieldTuple<T> getPi() {

hipparchus-core/src/main/java/org/hipparchus/util/Tuple.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,16 @@ public Tuple linearCombination(final double a1, final Tuple b1,
769769
return result;
770770
}
771771

772+
/** {@inheritDoc} */
773+
@Override
774+
public double norm() {
775+
double sum = 0;
776+
for (final double value : values) {
777+
sum += FastMath.abs(value);
778+
}
779+
return sum;
780+
}
781+
772782
/** {@inheritDoc} */
773783
@Override
774784
public Tuple getPi() {

0 commit comments

Comments
 (0)