From 0a229c727f40cdcdb65459b7ea9eadd7def5a9d6 Mon Sep 17 00:00:00 2001 From: Lakshmi Krishnamurthy Date: Sun, 7 Jan 2024 13:50:59 -0500 Subject: [PATCH] Features: Bug Fixes/Re-organization: Samples: - Spline Params Stretch Best Fit Response - Create (1, 2, 3) - Spline Params Stretch Best Fit Response - Constructor (4, 5, 6) - Spline Params Stretch Best Fit Response - Normalize Weights (7, 8, 9) - Spline Params Stretch Best Fit Response - Weights (10, 11) - Spline Params Stretch Best Fit Response - Predictor Ordinate (12, 13, 14) - Spline Params Stretch Best Fit Response - Response Array (15, 16, 17) - Spline Params Stretch Best Fit Response - Point Count (18) - Spline Params Stretch Best Fit Response - Size To Segment (19, 20, 21) - Segment Flexure Penalty Control (22, 23, 24) - Segment Flexure Penalty Control - Derivative Order (25, 26) - Segment Flexure Penalty Control - Amplitude (27, 28) - Segment Flexure Penalty Control - Constructor (29, 30) - Spline Params Segment State Calibration Inputs (31, 32) - Spline Params Segment State Calibration Inputs - Response Value Array (33, 34) - Spline Params Segment State Calibration Inputs - Left Edge Derivative Array (35, 36) - Spline Params Segment State Calibration Inputs - Right Edge Derivative Array (37, 38) - Spline Params Segment State Calibration Inputs - Predictor Ordinate Array (39, 40) - Spline Params Segment State Calibration Inputs - Segment Best Fit Response (41, 42) - Spline Params Segment State Calibration Inputs - Segment Basis Flexure Constraint Array (43, 44) - Spline Params Segment State Calibration Inputs - Constructor (45, 46, 47) - Spline Params Segment Response Value Constraint (48, 49, 50) - Spline Params Segment Response Value Constraint - Left Of (51) - Spline Params Segment Response Value Constraint - Right Of (52) - Spline Params Segment Response Value Constraint - Splits (53) - Spline Params Segment Response Value Constraint - Predictor Ordinate Array (54, 55) - Spline Params Segment Response Value Constraint - Weight Array (56, 57) - Spline Params Segment Response Value Constraint - Weighted (58, 59) - Spline Params Segment Response Value Constraint - From Predictor Pair (60) IdeaDRIP: --- ReleaseNotes/04_18_2023.txt | 38 ++++ ScheduleSheet.xlsx | Bin 50209 -> 50200 bytes .../params/SegmentFlexurePenaltyControl.java | 62 ++++--- .../SegmentResponseValueConstraint.java | 120 +++++++------ .../params/SegmentStateCalibrationInputs.java | 151 ++++++++-------- .../spline/params/StretchBestFitResponse.java | 166 ++++++++++-------- 6 files changed, 311 insertions(+), 226 deletions(-) create mode 100644 ReleaseNotes/04_18_2023.txt diff --git a/ReleaseNotes/04_18_2023.txt b/ReleaseNotes/04_18_2023.txt new file mode 100644 index 000000000000..5aff971c6942 --- /dev/null +++ b/ReleaseNotes/04_18_2023.txt @@ -0,0 +1,38 @@ + +Features: + +Bug Fixes/Re-organization: + +Samples: + + - Spline Params Stretch Best Fit Response - Create (1, 2, 3) + - Spline Params Stretch Best Fit Response - Constructor (4, 5, 6) + - Spline Params Stretch Best Fit Response - Normalize Weights (7, 8, 9) + - Spline Params Stretch Best Fit Response - Weights (10, 11) + - Spline Params Stretch Best Fit Response - Predictor Ordinate (12, 13, 14) + - Spline Params Stretch Best Fit Response - Response Array (15, 16, 17) + - Spline Params Stretch Best Fit Response - Point Count (18) + - Spline Params Stretch Best Fit Response - Size To Segment (19, 20, 21) + - Segment Flexure Penalty Control (22, 23, 24) + - Segment Flexure Penalty Control - Derivative Order (25, 26) + - Segment Flexure Penalty Control - Amplitude (27, 28) + - Segment Flexure Penalty Control - Constructor (29, 30) + - Spline Params Segment State Calibration Inputs (31, 32) + - Spline Params Segment State Calibration Inputs - Response Value Array (33, 34) + - Spline Params Segment State Calibration Inputs - Left Edge Derivative Array (35, 36) + - Spline Params Segment State Calibration Inputs - Right Edge Derivative Array (37, 38) + - Spline Params Segment State Calibration Inputs - Predictor Ordinate Array (39, 40) + - Spline Params Segment State Calibration Inputs - Segment Best Fit Response (41, 42) + - Spline Params Segment State Calibration Inputs - Segment Basis Flexure Constraint Array (43, 44) + - Spline Params Segment State Calibration Inputs - Constructor (45, 46, 47) + - Spline Params Segment Response Value Constraint (48, 49, 50) + - Spline Params Segment Response Value Constraint - Left Of (51) + - Spline Params Segment Response Value Constraint - Right Of (52) + - Spline Params Segment Response Value Constraint - Splits (53) + - Spline Params Segment Response Value Constraint - Predictor Ordinate Array (54, 55) + - Spline Params Segment Response Value Constraint - Weight Array (56, 57) + - Spline Params Segment Response Value Constraint - Weighted (58, 59) + - Spline Params Segment Response Value Constraint - From Predictor Pair (60) + + +IdeaDRIP: diff --git a/ScheduleSheet.xlsx b/ScheduleSheet.xlsx index 610c1b99c6decc0136605c94fc2842cb1f977c05..d78d5b844608f3f452042dba3b6542bccc251c4f 100644 GIT binary patch delta 3637 zcmV-54$ASNhy$321F-A{1&%w{$^nz{1}J|`9P&XTpaKFKQnw-2wJ((_lNe%=#F_0B zs;d8e*MU%4Ub=P&{LS$>zQ@s){U2CK)Y=yxH?sxJ?S(3*tRf! zbp*TfGk718YYFRerekz07U z8NMGno?Z#Y80LzKk|;Xnr2-!wbbZ!y4fZ(W;BaF>|I|!SxLDvX&y!bD}b% z7I`0yqq{4zky*jw#n1WOi66EW8r;Gl8mzDz`f@1Oip&>aV!XHL3P-*mg-)Es)_sX2-rKXBr1h{MS^(0H;BA5+(FigxZ<3)ac(hS9BjF@x?JyIWSK zeA_5`JZW#6;airf4CIB7&ycYn`$pM11FqO^2Ep!{Qy)D|<6s&OC%zfRAlMDNwi$MY zV-t7B4i0?J4nnu#Vx5p_5+;ypYNKpSz8Ky@TGpAgIa_3iNN*r!Db{~dPL~d)r0Qfb zOI)?gbi2g@{Y%W05zB!s@MufT+B-y}AwVfS3Q7VB&D9eH1b_el2I7-#3@!o8lbj40e>TZhk=ke_ zz&2*S`DgqyyW5G**?`hq_670XDRH1@vgZA=Am6@LlZ-gp(7vXf?4clg(B$s+{kz## zs+Dd5jDv(;7o;_2$URT976jF<9H7UYMk+xKF4fZ0g92LHAklfjbeedA@}3+Bxw?iS zn}#!(OSTr!n*&5aM-A%Ne=Q&MktWzRI6>8FJxrJs10oi@<7RK6#1SliT=r7YMTd3o z{D?AVr|=5!4v%T<`-@D1GbOcbjEiLNp!u@=8}G)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I0cewG!9W4$lc~Wv0SlAl!9fAylP1DY z0pyc+!cYR|u#+CcB$MsJF9CIv9m7-t1GtlO!y+4+Gt{$H0RRAP0ssIJ0000000000 a000000Bn=6!#)A{lkdYL2D`ri0002*YAJC5 diff --git a/src/main/java/org/drip/spline/params/SegmentFlexurePenaltyControl.java b/src/main/java/org/drip/spline/params/SegmentFlexurePenaltyControl.java index b9373f5e78af..292a457edba3 100644 --- a/src/main/java/org/drip/spline/params/SegmentFlexurePenaltyControl.java +++ b/src/main/java/org/drip/spline/params/SegmentFlexurePenaltyControl.java @@ -1,6 +1,8 @@ package org.drip.spline.params; +import org.drip.numerical.common.NumberUtil; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ @@ -84,42 +86,56 @@ /** * SegmentFlexurePenaltyControl implements basis per-segment Flexure Penalty Parameter Set. Currently - * it contains the Flexure Penalty Derivative Order and the Roughness Coefficient Amplitude. Flexure Penalty - * Control may be used to implement Segment Curvature Control and/or Segment Length Control. + * it contains the Flexure Penalty Derivative Order and the Roughness Coefficient Amplitude. Flexure Penalty + * Control may be used to implement Segment Curvature Control and/or Segment Length Control. * - *

+ *
* - *

+ * + *
+ * + * + * + * + * + * + * + *
Module Product Core Module
Library Fixed Income Analytics
Project Basis Splines and Linear Compounders across a Broad Family of Spline Basis Functions
Package Spline Segment Construction Control Parameters
+ *
* * @author Lakshmi Krishnamurthy */ -public class SegmentFlexurePenaltyControl { - private int _iDerivativeOrder = -1; - private double _dblAmplitude = java.lang.Double.NaN; +public class SegmentFlexurePenaltyControl +{ + private double _amplitude = Double.NaN; + private int _derivativeOrder = Integer.MIN_VALUE; /** - * SegmentFlexurePenaltyControl constructor + * SegmentFlexurePenaltyControl constructor * - * @param iDerivativeOrder Roughness Penalty Derivative Order - * @param dblAmplitude Roughness Curvature Penalty Amplitude + * @param derivativeOrder Roughness Penalty Derivative Order + * @param amplitude Roughness Curvature Penalty Amplitude * - * @throws java.lang.Exception Thrown if the inputs are invalid + * @throws Exception Thrown if the inputs are invalid */ public SegmentFlexurePenaltyControl ( - final int iDerivativeOrder, - final double dblAmplitude) - throws java.lang.Exception + final int derivativeOrder, + final double amplitude) + throws Exception { - if (0 >= (_iDerivativeOrder = iDerivativeOrder) || !org.drip.numerical.common.NumberUtil.IsValid - (_dblAmplitude = dblAmplitude)) - throw new java.lang.Exception ("SegmentFlexurePenaltyControl ctr: Invalid Inputs"); + if (0 >= (_derivativeOrder = derivativeOrder) || !NumberUtil.IsValid (_amplitude = amplitude)) { + throw new Exception ("SegmentFlexurePenaltyControl ctr: Invalid Inputs"); + } } /** @@ -130,7 +146,7 @@ public SegmentFlexurePenaltyControl ( public int derivativeOrder() { - return _iDerivativeOrder; + return _derivativeOrder; } /** @@ -141,6 +157,6 @@ public int derivativeOrder() public double amplitude() { - return _dblAmplitude; + return _amplitude; } } diff --git a/src/main/java/org/drip/spline/params/SegmentResponseValueConstraint.java b/src/main/java/org/drip/spline/params/SegmentResponseValueConstraint.java index 574e124dac5a..28b914457e59 100644 --- a/src/main/java/org/drip/spline/params/SegmentResponseValueConstraint.java +++ b/src/main/java/org/drip/spline/params/SegmentResponseValueConstraint.java @@ -1,6 +1,8 @@ package org.drip.spline.params; +import org.drip.numerical.common.NumberUtil; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ @@ -96,45 +98,41 @@ * * SegmentResponseValueConstraint exports the following functionality: * - *

+ *
*
    - *
  • - * Retrieve the Array of Predictor Ordinates. - *
  • - *
  • - * Retrieve the Array of Response Weights at each Predictor Ordinate. - *
  • - *
  • - * Retrieve the Constraint Value. - *
  • - *
  • - * Convert the Segment Constraint onto Local Predictor Ordinates, the corresponding Response Basis - * Function, and the Shape Controller Realizations. - *
  • - *
  • - * Get the Position of the Predictor Knot relative to the Constraints. - *
  • - *
  • - * Generate a SegmentResponseValueConstraint instance from the given predictor/response pair. - *
  • + *
  • Indicator specifying that the knot is to the left of the constraint ordinates
  • + *
  • Indicator specifying that the knot is to the right of the constraint ordinates
  • + *
  • Indicator specifying that the knot splits the constraint ordinates
  • + *
  • Generate a SegmentResponseValueConstraint instance from the given predictor/response pair
  • + *
  • SegmentResponseValueConstraint constructor
  • + *
  • Retrieve the Array of Predictor Ordinates
  • + *
  • Retrieve the Array of Response Weights at each Predictor Ordinate
  • + *
  • Retrieve the Constraint Value
  • + *
  • Display the Comment Annotated State
  • + *
  • Convert the Segment Constraint onto Local Predictor Ordinates, the corresponding Response Basis Function, and the Shape Controller Realizations
  • + *
  • Get the Position of the Predictor Knot relative to the Constraints
  • *
- * - * SegmentResponseValueConstraint can be viewed as the global response point value transform of - * SegmentBasisFlexureConstraint. * - *

- * - *

+ *
+ * + * + * + * + * + * + * + *
Module Product Core Module
Library Fixed Income Analytics
Project Basis Splines and Linear Compounders across a Broad Family of Spline Basis Functions
Package Spline Segment Construction Control Parameters
+ *
* * @author Lakshmi Krishnamurthy */ -public class SegmentResponseValueConstraint { +public class SegmentResponseValueConstraint +{ /** * Indicator specifying that the knot is to the left of the constraint ordinates @@ -154,31 +152,31 @@ public class SegmentResponseValueConstraint { public static final int SPLITS_CONSTRAINT = 4; - private double[] _adblPredictorOrdinate = null; - private double[] _adblResponseValueWeight = null; - private double _dblWeightedResponseValueConstraint = java.lang.Double.NaN; + private double[] _predictorOrdinateArray = null; + private double[] _responseValueWeightArray = null; + private double _weightedResponseValueConstraint = Double.NaN; /** * Generate a SegmentResponseValueConstraint instance from the given predictor/response pair. * - * @param dblPredictorOrdinate The Predictor Ordinate - * @param dblResponseValue The Response Value + * @param predictorOrdinate The Predictor Ordinate + * @param responseValue The Response Value * * @return The SegmentResponseValueConstraint instance */ public static final SegmentResponseValueConstraint FromPredictorResponsePair ( - final double dblPredictorOrdinate, - final double dblResponseValue) + final double predictorOrdinate, + final double responseValue) { - if (!org.drip.numerical.common.NumberUtil.IsValid (dblPredictorOrdinate) || - !org.drip.numerical.common.NumberUtil.IsValid (dblResponseValue)) - return null; - try { - return new SegmentResponseValueConstraint (new double[] {dblPredictorOrdinate}, new double[] - {1.}, dblResponseValue); - } catch (java.lang.Exception e) { + return !NumberUtil.IsValid (predictorOrdinate) || !NumberUtil.IsValid (responseValue) ? null : + new SegmentResponseValueConstraint ( + new double[] {predictorOrdinate}, + new double[] {1.}, + responseValue + ); + } catch (Exception e) { e.printStackTrace(); } @@ -202,14 +200,14 @@ public SegmentResponseValueConstraint ( final double dblWeightedResponseValueConstraint) throws java.lang.Exception { - if (null == (_adblPredictorOrdinate = adblPredictorOrdinate) || null == (_adblResponseValueWeight = + if (null == (_predictorOrdinateArray = adblPredictorOrdinate) || null == (_responseValueWeightArray = adblResponseValueWeight) || !org.drip.numerical.common.NumberUtil.IsValid - (_dblWeightedResponseValueConstraint = dblWeightedResponseValueConstraint)) + (_weightedResponseValueConstraint = dblWeightedResponseValueConstraint)) throw new java.lang.Exception ("SegmentResponseValueConstraint ctr: Invalid Inputs"); int iNumPredictorOrdinate = adblPredictorOrdinate.length; - if (0 == iNumPredictorOrdinate || _adblResponseValueWeight.length != iNumPredictorOrdinate) + if (0 == iNumPredictorOrdinate || _responseValueWeightArray.length != iNumPredictorOrdinate) throw new java.lang.Exception ("SegmentResponseValueConstraint ctr: Invalid Inputs"); } @@ -221,7 +219,7 @@ public SegmentResponseValueConstraint ( public double[] predictorOrdinates() { - return _adblPredictorOrdinate; + return _predictorOrdinateArray; } /** @@ -232,7 +230,7 @@ public double[] predictorOrdinates() public double[] responseWeights() { - return _adblResponseValueWeight; + return _responseValueWeightArray; } /** @@ -243,7 +241,7 @@ public double[] responseWeights() public double constraintValue() { - return _dblWeightedResponseValueConstraint; + return _weightedResponseValueConstraint; } /** @@ -255,11 +253,11 @@ public double constraintValue() public void display ( final java.lang.String strComment) { - for (int i = 0; i < _adblPredictorOrdinate.length; ++i) + for (int i = 0; i < _predictorOrdinateArray.length; ++i) System.out.println ("\t\t" + strComment + " - " + new org.drip.analytics.date.JulianDate ((int) - _adblPredictorOrdinate[i]) + " => " + _adblResponseValueWeight[i]); + _predictorOrdinateArray[i]) + " => " + _responseValueWeightArray[i]); - System.out.println ("\tConstraint: " + _dblWeightedResponseValueConstraint); + System.out.println ("\tConstraint: " + _weightedResponseValueConstraint); } /** @@ -280,7 +278,7 @@ public org.drip.spline.params.SegmentBasisFlexureConstraint responseIndexedBasis int iNumResponseBasis = lbe.numBasis(); - int iNumPredictorOrdinate = _adblPredictorOrdinate.length; + int iNumPredictorOrdinate = _predictorOrdinateArray.length; double[] adblResponseBasisWeight = new double[iNumResponseBasis]; if (0 == iNumResponseBasis) return null; @@ -290,12 +288,12 @@ public org.drip.spline.params.SegmentBasisFlexureConstraint responseIndexedBasis adblResponseBasisWeight[i] = 0.; for (int j = 0; j < iNumPredictorOrdinate; ++j) - adblResponseBasisWeight[i] += _adblResponseValueWeight[j] * - lbe.shapedBasisFunctionResponse (_adblPredictorOrdinate[j], i); + adblResponseBasisWeight[i] += _responseValueWeightArray[j] * + lbe.shapedBasisFunctionResponse (_predictorOrdinateArray[j], i); } return new org.drip.spline.params.SegmentBasisFlexureConstraint (adblResponseBasisWeight, - _dblWeightedResponseValueConstraint); + _weightedResponseValueConstraint); } catch (java.lang.Exception e) { e.printStackTrace(); } @@ -321,9 +319,9 @@ public int knotPosition ( if (!org.drip.numerical.common.NumberUtil.IsValid (dblPredictorKnot)) throw new java.lang.Exception ("SegmentResponseValueConstraint::knotPosition => Invalid Inputs"); - if (dblPredictorKnot < _adblPredictorOrdinate[0]) return LEFT_OF_CONSTRAINT; + if (dblPredictorKnot < _predictorOrdinateArray[0]) return LEFT_OF_CONSTRAINT; - if (dblPredictorKnot > _adblPredictorOrdinate[_adblPredictorOrdinate.length - 1]) + if (dblPredictorKnot > _predictorOrdinateArray[_predictorOrdinateArray.length - 1]) return RIGHT_OF_CONSTRAINT; return SPLITS_CONSTRAINT; diff --git a/src/main/java/org/drip/spline/params/SegmentStateCalibrationInputs.java b/src/main/java/org/drip/spline/params/SegmentStateCalibrationInputs.java index 48232ab13469..7b5c263b5cde 100644 --- a/src/main/java/org/drip/spline/params/SegmentStateCalibrationInputs.java +++ b/src/main/java/org/drip/spline/params/SegmentStateCalibrationInputs.java @@ -6,6 +6,9 @@ */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -84,87 +87,93 @@ /** * SegmentStateCalibrationInputs implements basis per-segment Calibration Parameter Input Set. It - * exposes the following functionality: + * exposes the following functionality: * - *

+ *
*
    - *
  • - * Retrieve the Array of the Calibration Predictor Ordinates. - *
  • - *
  • - * Retrieve the Array of the Calibration Response Values. - *
  • - *
  • - * Retrieve the Array of the Left/Right Edge Derivatives. - *
  • - *
  • - * Retrieve the Segment Best Fit Response. - *
  • - *
  • - * Retrieve the Array of Segment Basis Flexure Constraints. - *
  • + *
  • SegmentStateCalibrationInputs Constructor
  • + *
  • Retrieve the Array of the Calibration Predictor Ordinates
  • + *
  • Retrieve the Array of the Calibration Response Values
  • + *
  • Retrieve the Array of the Left Edge Derivatives
  • + *
  • Retrieve the Array of the Right Edge Derivatives
  • + *
  • Retrieve the Segment Best Fit Response
  • + *
  • Retrieve the Array of Segment Basis Flexure Constraints
  • *
* - *

- * - *

+ *
+ * + * + * + * + * + * + * + *
Module Product Core Module
Library Fixed Income Analytics
Project Basis Splines and Linear Compounders across a Broad Family of Spline Basis Functions
Package Spline Segment Construction Control Parameters
+ *
* * @author Lakshmi Krishnamurthy */ -public class SegmentStateCalibrationInputs { - private double[] _adblResponseValue = null; - private double[] _adblLeftEdgeDeriv = null; - private double[] _adblRightEdgeDeriv = null; - private double[] _adblPredictorOrdinate = null; - private org.drip.spline.params.SegmentBestFitResponse _sbfr = null; - private org.drip.spline.params.SegmentBasisFlexureConstraint[] _aSBFC = null; +public class SegmentStateCalibrationInputs +{ + private double[] _responseValueArray = null; + private double[] _predictorOrdinateArray = null; + private double[] _leftEdgeDerivativeArray = null; + private double[] _rightEdgeDerivativeArray = null; + private SegmentBestFitResponse _segmentBestFitResponse = null; + private SegmentBasisFlexureConstraint[] _segmentBasisFlexureConstraintArray = null; /** - * SegmentStateCalibrationInputs Constructor + * SegmentStateCalibrationInputs Constructor * - * @param adblPredictorOrdinate Array of Predictor Ordinates - * @param adblResponseValue Array of Response Values - * @param adblLeftEdgeDeriv Array of the Left Edge Derivatives - * @param adblRightEdgeDeriv Array of the Right Edge Derivatives - * @param aSBFC Array of the Segment Basis Flexure Constraints - * @param sbfr Segment Basis Fit Response + * @param predictorOrdinateArray Array of Predictor Ordinates + * @param responseValueArray Array of Response Values + * @param leftEdgeDerivativeArray Array of the Left Edge Derivatives + * @param rightEdgeDerivativeArray Array of the Right Edge Derivatives + * @param segmentBasisFlexureConstraintArray Array of the Segment Basis Flexure Constraints + * @param segmentBestFitResponse Segment Basis Fit Response * - * @throws java.lang.Exception Thrown if the Inputs are invalid + * @throws Exception Thrown if the Inputs are invalid */ public SegmentStateCalibrationInputs ( - final double[] adblPredictorOrdinate, - final double[] adblResponseValue, - final double[] adblLeftEdgeDeriv, - final double[] adblRightEdgeDeriv, - final org.drip.spline.params.SegmentBasisFlexureConstraint[] aSBFC, - final org.drip.spline.params.SegmentBestFitResponse sbfr) - throws java.lang.Exception + final double[] predictorOrdinateArray, + final double[] responseValueArray, + final double[] leftEdgeDerivativeArray, + final double[] rightEdgeDerivativeArray, + final SegmentBasisFlexureConstraint[] segmentBasisFlexureConstraintArray, + final SegmentBestFitResponse segmentBestFitResponse) + throws Exception { - _sbfr = sbfr; - int iNumSBFC = null == (_aSBFC = aSBFC) ? 0 : _aSBFC.length; - int iNumLeftEdgeDeriv = null == (_adblLeftEdgeDeriv = adblLeftEdgeDeriv) ? 0 : - _adblLeftEdgeDeriv.length; - int iNumResponseValue = null == (_adblResponseValue = adblResponseValue) ? 0 : - _adblResponseValue.length; - int iNumRightEdgeDeriv = null == (_adblRightEdgeDeriv = adblRightEdgeDeriv) ? 0 : - _adblRightEdgeDeriv.length; - int iNumPredictorOrdinate = null == (_adblPredictorOrdinate = adblPredictorOrdinate) ? 0 : - _adblPredictorOrdinate.length; - - if (null == _sbfr && null == _aSBFC && null == _adblPredictorOrdinate && null == _adblResponseValue - && null == _adblLeftEdgeDeriv && null == _adblRightEdgeDeriv) - throw new java.lang.Exception ("SegmentStateCalibrationInputs ctr: Invalid Inputs"); - - if (iNumPredictorOrdinate != iNumResponseValue || (null == _sbfr && 0 == iNumSBFC && 0 == - iNumPredictorOrdinate && 0 == iNumLeftEdgeDeriv && 0 == iNumRightEdgeDeriv)) - throw new java.lang.Exception ("SegmentStateCalibrationInputs ctr: Invalid Inputs"); + _segmentBestFitResponse = segmentBestFitResponse; + int segmentBasisFlexureConstraintCount = + null == (_segmentBasisFlexureConstraintArray = segmentBasisFlexureConstraintArray) ? 0 : + _segmentBasisFlexureConstraintArray.length; + int leftEdgeDerivativeCount = null == (_leftEdgeDerivativeArray = leftEdgeDerivativeArray) ? 0 : + _leftEdgeDerivativeArray.length; + int responseValueCount = null == (_responseValueArray = responseValueArray) ? 0 : + _responseValueArray.length; + int rightEdgeDerivativeCount = null == (_rightEdgeDerivativeArray = rightEdgeDerivativeArray) ? 0 : + _rightEdgeDerivativeArray.length; + int predictorOrdinateCount = null == (_predictorOrdinateArray = predictorOrdinateArray) ? 0 : + _predictorOrdinateArray.length; + + if (null == _segmentBestFitResponse && null == _segmentBasisFlexureConstraintArray && + null == _predictorOrdinateArray && null == _responseValueArray && + null == _leftEdgeDerivativeArray && null == _rightEdgeDerivativeArray) { + throw new Exception ("SegmentStateCalibrationInputs ctr: Invalid Inputs"); + } + + if (predictorOrdinateCount != responseValueCount || ( + null == _segmentBestFitResponse && 0 == segmentBasisFlexureConstraintCount && + 0 == predictorOrdinateCount && 0 == leftEdgeDerivativeCount && 0 == rightEdgeDerivativeCount + )) { + throw new Exception ("SegmentStateCalibrationInputs ctr: Invalid Inputs"); + } } /** @@ -175,7 +184,7 @@ public SegmentStateCalibrationInputs ( public double[] predictorOrdinates() { - return _adblPredictorOrdinate; + return _predictorOrdinateArray; } /** @@ -186,7 +195,7 @@ public double[] predictorOrdinates() public double[] responseValues() { - return _adblResponseValue; + return _responseValueArray; } /** @@ -197,7 +206,7 @@ public double[] responseValues() public double[] leftEdgeDeriv() { - return _adblLeftEdgeDeriv; + return _leftEdgeDerivativeArray; } /** @@ -208,7 +217,7 @@ public double[] leftEdgeDeriv() public double[] rightEdgeDeriv() { - return _adblRightEdgeDeriv; + return _rightEdgeDerivativeArray; } /** @@ -219,7 +228,7 @@ public double[] rightEdgeDeriv() public org.drip.spline.params.SegmentBestFitResponse bestFitResponse() { - return _sbfr; + return _segmentBestFitResponse; } /** @@ -230,6 +239,6 @@ public org.drip.spline.params.SegmentBestFitResponse bestFitResponse() public org.drip.spline.params.SegmentBasisFlexureConstraint[] flexureConstraint() { - return _aSBFC; + return _segmentBasisFlexureConstraintArray; } } diff --git a/src/main/java/org/drip/spline/params/StretchBestFitResponse.java b/src/main/java/org/drip/spline/params/StretchBestFitResponse.java index ddf9c7876408..b75da1c2ddc8 100644 --- a/src/main/java/org/drip/spline/params/StretchBestFitResponse.java +++ b/src/main/java/org/drip/spline/params/StretchBestFitResponse.java @@ -1,6 +1,12 @@ package org.drip.spline.params; +import java.util.ArrayList; +import java.util.List; + +import org.drip.numerical.common.NumberUtil; +import org.drip.spline.segment.LatentStateInelastic; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ @@ -199,60 +205,70 @@ public static final StretchBestFitResponse Create ( * Construct the StretchBestFitResponse Instance from the given Predictor Ordinate/Response Pairs, * using Uniform Weightings. * - * @param adblPredictorOrdinate Array of Predictor Ordinates - * @param adblResponseValue Array of Response Values + * @param predictorOrdinateArray Array of Predictor Ordinates + * @param responseValueArray Array of Response Values * * @return Instance of StretchBestFitResponse */ public static final StretchBestFitResponse Create ( - final double[] adblPredictorOrdinate, - final double[] adblResponseValue) + final double[] predictorOrdinateArray, + final double[] responseValueArray) { - if (!org.drip.numerical.common.NumberUtil.IsValid (adblPredictorOrdinate)) return null; + if (!NumberUtil.IsValid (predictorOrdinateArray)) { + return null; + } - int iNumWeight = adblPredictorOrdinate.length; - double[] adblWeight = new double[iNumWeight]; + int weightCount = predictorOrdinateArray.length; + double[] weightArray = new double[weightCount]; - for (int i = 0; i < iNumWeight; ++i) - adblWeight[i] = 1.; + for (int weightArrayIndex = 0; weightArrayIndex < weightCount; ++weightArrayIndex) { + weightArray[weightArrayIndex] = 1.; + } - return Create (adblPredictorOrdinate, adblResponseValue, adblWeight); + return Create (predictorOrdinateArray, responseValueArray, weightArray); } private StretchBestFitResponse ( - final double[] adblWeight, - final double[] adblResponse, - final double[] adblPredictorOrdinate) - throws java.lang.Exception + final double[] weightArray, + final double[] responseArray, + final double[] predictorOrdinateArray) + throws Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (_weightArray = adblWeight) || - !org.drip.numerical.common.NumberUtil.IsValid (_responseArray = adblResponse) || - !org.drip.numerical.common.NumberUtil.IsValid (_predictorOrdinateArray = adblPredictorOrdinate)) - throw new java.lang.Exception ("StretchBestFitResponse ctr: Invalid Inputs"); + if (!NumberUtil.IsValid (_weightArray = weightArray) || + !NumberUtil.IsValid (_responseArray = responseArray) || + !NumberUtil.IsValid (_predictorOrdinateArray = predictorOrdinateArray)) { + throw new Exception ("StretchBestFitResponse ctr: Invalid Inputs"); + } - int iNumPointsToFit = _weightArray.length; + int pointsToFit = _weightArray.length; - if (0 == iNumPointsToFit || _responseArray.length != iNumPointsToFit || _predictorOrdinateArray.length - != iNumPointsToFit) - throw new java.lang.Exception ("StretchBestFitResponse ctr: Invalid Inputs"); + if (0 == pointsToFit || _responseArray.length != pointsToFit || + _predictorOrdinateArray.length != pointsToFit) { + throw new Exception ("StretchBestFitResponse ctr: Invalid Inputs"); + } } private boolean normalizeWeights() { - double dblCumulativeWeight = 0.; - int iNumPointsToFit = _weightArray.length; + double cumulativeWeight = 0.; + int pointsToFit = _weightArray.length; - for (int i = 0; i < iNumPointsToFit; ++i) { - if (_weightArray[i] < 0.) return false; + for (int pointIndex = 0; pointIndex < pointsToFit; ++pointIndex) { + if (_weightArray[pointIndex] < 0.) { + return false; + } - dblCumulativeWeight += _weightArray[i]; + cumulativeWeight += _weightArray[pointIndex]; } - if (0. >= dblCumulativeWeight) return false; + if (0. >= cumulativeWeight) { + return false; + } - for (int i = 0; i < iNumPointsToFit; ++i) - _weightArray[i] /= dblCumulativeWeight; + for (int pointIndex = 0; pointIndex < pointsToFit; ++pointIndex) { + _weightArray[pointIndex] /= cumulativeWeight; + } return true; } @@ -271,21 +287,22 @@ public double[] weight() /** * Retrieve the Indexed Fitness Weight Element * - * @param iIndex The Element Index + * @param index The Element Index * * @return The Indexed Fitness Weight Element * - * @throws java.lang.Exception Thrown if the Index is Invalid + * @throws Exception Thrown if the Index is Invalid */ public double weight ( - final int iIndex) - throws java.lang.Exception + final int index) + throws Exception { - if (iIndex >= numPoint()) - throw new java.lang.Exception ("StretchBestFitResponse::weight => Invalid Index"); + if (index >= numPoint()) { + throw new Exception ("StretchBestFitResponse::weight => Invalid Index"); + } - return _weightArray[iIndex]; + return _weightArray[index]; } /** @@ -302,21 +319,22 @@ public double[] predictorOrdinate() /** * Retrieve the Indexed Predictor Ordinate Element * - * @param iIndex The Element Index + * @param index The Element Index * * @return The Indexed Predictor Ordinate Element * - * @throws java.lang.Exception Thrown if the Index is Invalid + * @throws Exception Thrown if the Index is Invalid */ public double predictorOrdinate ( - final int iIndex) - throws java.lang.Exception + final int index) + throws Exception { - if (iIndex >= numPoint()) - throw new java.lang.Exception ("StretchBestFitResponse::predictorOrdinate => Invalid Index"); + if (index >= numPoint()) { + throw new Exception ("StretchBestFitResponse::predictorOrdinate => Invalid Index"); + } - return _predictorOrdinateArray[iIndex]; + return _predictorOrdinateArray[index]; } /** @@ -333,21 +351,22 @@ public double[] response() /** * Retrieve the Indexed Response Element * - * @param iIndex The Element Index + * @param index The Element Index * * @return The Indexed Response Element * - * @throws java.lang.Exception Thrown if the Index is Invalid + * @throws Exception Thrown if the Index is Invalid */ public double response ( - final int iIndex) - throws java.lang.Exception + final int index) + throws Exception { - if (iIndex >= numPoint()) - throw new java.lang.Exception ("StretchBestFitResponse::response => Invalid Index"); + if (index >= numPoint()) { + throw new Exception ("StretchBestFitResponse::response => Invalid Index"); + } - return _responseArray[iIndex]; + return _responseArray[index]; } /** @@ -364,46 +383,51 @@ public int numPoint() /** * Generate the Segment Local Best Fit Weighted Response contained within the specified Segment * - * @param ics The Inelastics Instance to be used for the Localization + * @param latentStateInelastic The Inelastics Instance to be used for the Localization * * @return The Segment Local Best Fit Weighted Response */ public SegmentBestFitResponse sizeToSegment ( - final org.drip.spline.segment.LatentStateInelastic ics) + final LatentStateInelastic latentStateInelastic) { - if (null == ics) return null; + if (null == latentStateInelastic) { + return null; + } - int iNumPoint = numPoint(); + int pointCount = numPoint(); - java.util.List lsIndex = new java.util.ArrayList(); + List indexList = new ArrayList(); - for (int i = 0; i < iNumPoint; ++i) { + for (int pointIndex = 0; pointIndex < pointCount; ++pointIndex) { try { - if (ics.in (_predictorOrdinateArray[i])) lsIndex.add (i); - } catch (java.lang.Exception e) { + if (latentStateInelastic.in (_predictorOrdinateArray[pointIndex])) { + indexList.add (pointIndex); + } + } catch (Exception e) { e.printStackTrace(); return null; } } - int iNumLocalPoint = lsIndex.size(); + int localPointCount = indexList.size(); - if (0 == iNumLocalPoint) return null; + if (0 == localPointCount) { + return null; + } - int iIndex = 0; - double[] adblWeight = new double[iNumLocalPoint]; - double[] adblResponse = new double[iNumLocalPoint]; - double[] adblPredictor = new double[iNumLocalPoint]; + int counter = 0; + double[] weightArray = new double[localPointCount]; + double[] responseArray = new double[localPointCount]; + double[] predictorOrdinateArray = new double[localPointCount]; - for (int i : lsIndex) { - adblWeight[iIndex] = _weightArray[i]; - adblResponse[iIndex] = _responseArray[i]; - adblPredictor[iIndex++] = _predictorOrdinateArray[i]; + for (int index : indexList) { + weightArray[counter] = _weightArray[index]; + responseArray[counter] = _responseArray[index]; + predictorOrdinateArray[counter++] = _predictorOrdinateArray[index]; } - return org.drip.spline.params.SegmentBestFitResponse.Create (adblPredictor, adblResponse, - adblWeight); + return SegmentBestFitResponse.Create (predictorOrdinateArray, responseArray, weightArray); } }