Skip to content

Commit

Permalink
tighten rules for constants naming conventions
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@810196 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Luc Maisonobe committed Sep 1, 2009
1 parent 966160f commit a0943be
Show file tree
Hide file tree
Showing 21 changed files with 217 additions and 206 deletions.
9 changes: 8 additions & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@
<module name="FallThrough" />
<module name="MissingSwitchDefault" />

<!--
<!-- Constant names should obey the traditional all uppercase naming convention -->
<module name="ConstantName" />

<!--
<module name="HiddenField">
<property name="ignoreConstructorParameter" value="true" />
<property name="ignoreSetter" value="true" />
Expand All @@ -109,6 +111,11 @@
<property name="onCommentFormat" value="CHECKSTYLE\: resume JavadocMethodCheck"/>
<property name="checkFormat" value="JavadocMethodCheck"/>
</module>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE\: stop ConstantName"/>
<property name="onCommentFormat" value="CHECKSTYLE\: resume ConstantName"/>
<property name="checkFormat" value="ConstantName"/>
</module>

</module>

Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public MessagesResources_fr() {
*/
@Override
public Object[][] getContents() {
return contents.clone();
return CONTENTS.clone();
}

/** Non-translated/translated messages arrays. */
private static final Object[][] contents = {
private static final Object[][] CONTENTS = {

// org.apache.commons.math.util.MathUtils
{ "must have n >= k for binomial coefficient (n,k), got n = {0}, k = {1}",
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/apache/commons/math/complex/Complex.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public class Complex implements FieldElement<Complex>, Serializable {

/** The square root of -1. A number representing "0.0 + 1.0i" */
public static final Complex I = new Complex(0.0, 1.0);


// CHECKSTYLE: stop ConstantName
/** A complex number representing "NaN + NaNi" */
public static final Complex NaN = new Complex(Double.NaN, Double.NaN);
// CHECKSTYLE: resume ConstantName

/** A complex number representing "+INF + INFi" */
public static final Complex INF = new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/apache/commons/math/geometry/Vector3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ public class Vector3D
/** Opposite of the third canonical vector (coordinates: 0, 0, -1). */
public static final Vector3D MINUS_K = new Vector3D(0, 0, -1);

// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
public static final Vector3D NaN = new Vector3D(Double.NaN, Double.NaN, Double.NaN);
// CHECKSTYLE: resume ConstantName

/** A vector with all coordinates set to positive infinity. */
public static final Vector3D POSITIVE_INFINITY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
public class AdamsNordsieckTransformer {

/** Cache for already computed coefficients. */
private static final Map<Integer, AdamsNordsieckTransformer> cache =
private static final Map<Integer, AdamsNordsieckTransformer> CACHE =
new HashMap<Integer, AdamsNordsieckTransformer>();

/** Initialization matrix for the higher order derivatives wrt y'', y''' ... */
Expand Down Expand Up @@ -200,11 +200,11 @@ public BigFraction visit(int row, int column, BigFraction value) {
* @return Nordsieck transformer for the specified number of steps
*/
public static AdamsNordsieckTransformer getInstance(final int nSteps) {
synchronized(cache) {
AdamsNordsieckTransformer t = cache.get(nSteps);
synchronized(CACHE) {
AdamsNordsieckTransformer t = CACHE.get(nSteps);
if (t == null) {
t = new AdamsNordsieckTransformer(nSteps);
cache.put(nSteps, t);
CACHE.put(nSteps, t);
}
return t;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@
public class ClassicalRungeKuttaIntegrator extends RungeKuttaIntegrator {

/** Time steps Butcher array. */
private static final double[] c = {
private static final double[] STATIC_C = {
1.0 / 2.0, 1.0 / 2.0, 1.0
};

/** Internal weights Butcher array. */
private static final double[][] a = {
private static final double[][] STATIC_A = {
{ 1.0 / 2.0 },
{ 0.0, 1.0 / 2.0 },
{ 0.0, 0.0, 1.0 }
};

/** Propagation weights Butcher array. */
private static final double[] b = {
private static final double[] STATIC_B = {
1.0 / 6.0, 1.0 / 3.0, 1.0 / 3.0, 1.0 / 6.0
};

Expand All @@ -68,7 +68,7 @@ public class ClassicalRungeKuttaIntegrator extends RungeKuttaIntegrator {
* @param step integration step
*/
public ClassicalRungeKuttaIntegrator(final double step) {
super("classical Runge-Kutta", c, a, b,
super("classical Runge-Kutta", STATIC_C, STATIC_A, STATIC_B,
new ClassicalRungeKuttaStepInterpolator(), step);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public class DormandPrince54Integrator extends EmbeddedRungeKuttaIntegrator {
private static final String METHOD_NAME = "Dormand-Prince 5(4)";

/** Time steps Butcher array. */
private static final double[] staticC = {
private static final double[] STATIC_C = {
1.0/5.0, 3.0/10.0, 4.0/5.0, 8.0/9.0, 1.0, 1.0
};

/** Internal weights Butcher array. */
private static final double[][] staticA = {
private static final double[][] STATIC_A = {
{1.0/5.0},
{3.0/40.0, 9.0/40.0},
{44.0/45.0, -56.0/15.0, 32.0/9.0},
Expand All @@ -65,29 +65,29 @@ public class DormandPrince54Integrator extends EmbeddedRungeKuttaIntegrator {
};

/** Propagation weights Butcher array. */
private static final double[] staticB = {
private static final double[] STATIC_B = {
35.0/384.0, 0.0, 500.0/1113.0, 125.0/192.0, -2187.0/6784.0, 11.0/84.0, 0.0
};

/** Error array, element 1. */
private static final double e1 = 71.0 / 57600.0;
private static final double E1 = 71.0 / 57600.0;

// element 2 is zero, so it is neither stored nor used

/** Error array, element 3. */
private static final double e3 = -71.0 / 16695.0;
private static final double E3 = -71.0 / 16695.0;

/** Error array, element 4. */
private static final double e4 = 71.0 / 1920.0;
private static final double E4 = 71.0 / 1920.0;

/** Error array, element 5. */
private static final double e5 = -17253.0 / 339200.0;
private static final double E5 = -17253.0 / 339200.0;

/** Error array, element 6. */
private static final double e6 = 22.0 / 525.0;
private static final double E6 = 22.0 / 525.0;

/** Error array, element 7. */
private static final double e7 = -1.0 / 40.0;
private static final double E7 = -1.0 / 40.0;

/** Simple constructor.
* Build a fifth order Dormand-Prince integrator with the given step bounds
Expand All @@ -101,7 +101,7 @@ public class DormandPrince54Integrator extends EmbeddedRungeKuttaIntegrator {
public DormandPrince54Integrator(final double minStep, final double maxStep,
final double scalAbsoluteTolerance,
final double scalRelativeTolerance) {
super(METHOD_NAME, true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
super(METHOD_NAME, true, STATIC_C, STATIC_A, STATIC_B, new DormandPrince54StepInterpolator(),
minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
}

Expand All @@ -117,7 +117,7 @@ public DormandPrince54Integrator(final double minStep, final double maxStep,
public DormandPrince54Integrator(final double minStep, final double maxStep,
final double[] vecAbsoluteTolerance,
final double[] vecRelativeTolerance) {
super(METHOD_NAME, true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
super(METHOD_NAME, true, STATIC_C, STATIC_A, STATIC_B, new DormandPrince54StepInterpolator(),
minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
}

Expand All @@ -136,9 +136,9 @@ protected double estimateError(final double[][] yDotK,
double error = 0;

for (int j = 0; j < y0.length; ++j) {
final double errSum = e1 * yDotK[0][j] + e3 * yDotK[2][j] +
e4 * yDotK[3][j] + e5 * yDotK[4][j] +
e6 * yDotK[5][j] + e7 * yDotK[6][j];
final double errSum = E1 * yDotK[0][j] + E3 * yDotK[2][j] +
E4 * yDotK[3][j] + E5 * yDotK[4][j] +
E6 * yDotK[5][j] + E7 * yDotK[6][j];

final double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
final double tol = (vecAbsoluteTolerance == null) ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ protected void computeInterpolatedStateAndDerivatives(final double theta,
final double yDot4 = yDotK[4][i];
final double yDot5 = yDotK[5][i];
final double yDot6 = yDotK[6][i];
v1[i] = a70 * yDot0 + a72 * yDot2 + a73 * yDot3 + a74 * yDot4 + a75 * yDot5;
v1[i] = A70 * yDot0 + A72 * yDot2 + A73 * yDot3 + A74 * yDot4 + A75 * yDot5;
v2[i] = yDot0 - v1[i];
v3[i] = v1[i] - v2[i] - yDot6;
v4[i] = d0 * yDot0 + d2 * yDot2 + d3 * yDot3 + d4 * yDot4 + d5 * yDot5 + d6 * yDot6;
v4[i] = D0 * yDot0 + D2 * yDot2 + D3 * yDot3 + D4 * yDot4 + D5 * yDot5 + D6 * yDot6;
}

vectorsInitialized = true;
Expand Down Expand Up @@ -172,41 +172,41 @@ protected void computeInterpolatedStateAndDerivatives(final double theta,
private boolean vectorsInitialized;

/** Last row of the Butcher-array internal weights, element 0. */
private static final double a70 = 35.0 / 384.0;
private static final double A70 = 35.0 / 384.0;

// element 1 is zero, so it is neither stored nor used

/** Last row of the Butcher-array internal weights, element 2. */
private static final double a72 = 500.0 / 1113.0;
private static final double A72 = 500.0 / 1113.0;

/** Last row of the Butcher-array internal weights, element 3. */
private static final double a73 = 125.0 / 192.0;
private static final double A73 = 125.0 / 192.0;

/** Last row of the Butcher-array internal weights, element 4. */
private static final double a74 = -2187.0 / 6784.0;
private static final double A74 = -2187.0 / 6784.0;

/** Last row of the Butcher-array internal weights, element 5. */
private static final double a75 = 11.0 / 84.0;
private static final double A75 = 11.0 / 84.0;

/** Shampine (1986) Dense output, element 0. */
private static final double d0 = -12715105075.0 / 11282082432.0;
private static final double D0 = -12715105075.0 / 11282082432.0;

// element 1 is zero, so it is neither stored nor used

/** Shampine (1986) Dense output, element 2. */
private static final double d2 = 87487479700.0 / 32700410799.0;
private static final double D2 = 87487479700.0 / 32700410799.0;

/** Shampine (1986) Dense output, element 3. */
private static final double d3 = -10690763975.0 / 1880347072.0;
private static final double D3 = -10690763975.0 / 1880347072.0;

/** Shampine (1986) Dense output, element 4. */
private static final double d4 = 701980252875.0 / 199316789632.0;
private static final double D4 = 701980252875.0 / 199316789632.0;

/** Shampine (1986) Dense output, element 5. */
private static final double d5 = -1453857185.0 / 822651844.0;
private static final double D5 = -1453857185.0 / 822651844.0;

/** Shampine (1986) Dense output, element 6. */
private static final double d6 = 69997945.0 / 29380423.0;
private static final double D6 = 69997945.0 / 29380423.0;

/** Serializable version identifier */
private static final long serialVersionUID = 4104157279605906956L;
Expand Down
Loading

0 comments on commit a0943be

Please sign in to comment.