Skip to content

Commit 32db51d

Browse files
committed
Features:
- CRNG R^d Random Sequence Shell (1, 2, 3) - R^d Random Sequence 1D #1 (4, 5) - R^d Random Sequence 1D #2 (6, 7) - R^d Random Sequence 2D #1 (8, 9) - R^d Random Sequence 2D #2 (10, 11) - R^d Random Sequence Tridiagonal #1 (14, 15) - R^d Random Sequence Tridiagonal #2 (16, 17) - Matrix Bottom Left Location Checker (18, 19) - Matrix Top Right Location Checker (20, 21) - R^d Random Sequence Periodic Tridiagonal #1 (22, 23) - R^d Random Sequence Periodic Tridiagonal #2 (24, 25, 26) - Number Util Array Row #1 (44, 45, 46) - Number Util Array Row #2 (47, 48, 49) - Number Util Array Row #3 (50, 51) - Number Util Array Row #4 (52, 53) - Number Util Array Row #5 (54, 55) - Number Util Array Row #6 (56, 57) - Number Util Array Row #7 (58, 59, 60) Bug Fixes/Re-organization: - Matrix Bottom Left Top Right (12, 13) Samples: - Tridiagonal Non-periodic Solver #1 (27, 28) - Tridiagonal Non-periodic Solver #2 (29, 30, 31) - Tridiagonal Non-periodic Solver #3 (32, 33, 34) - Tridiagonal Non-periodic Solver #4 (35, 36, 37) - Tridiagonal Non-periodic Solver #5 (38, 39, 40) - Tridiagonal Non-periodic Solver #6 (41, 42, 43) - Tridiagonal Non-periodic Solver #7 (61, 62, 63) - Tridiagonal Non-periodic Solver #8 (64, 65, 66) - Tridiagonal Non-periodic Solver #9 (67, 68, 69) - Tridiagonal Non-periodic Solver #10 (70, 71, 72) - Tridiagonal Non-periodic Solver #11 (73, 74, 75) - Tridiagonal Non-periodic Solver #12 (76, 77, 78) - Non-periodic Solver Suite #1 (79, 80) - Non-periodic Solver Suite #2 (81, 82) - Non-periodic Solver Suite #3 (83, 84) - Non-periodic Solver Suite #4 (85, 86, 87) - Non-periodic Solver Suite #5 (88, 89, 90) - Non-periodic Solver Suite #6 (91, 92, 93) - Non-periodic Solver Suite #7 (94, 95, 96) - Non-periodic Solver Suite #8 (97, 98, 99) - Non-periodic Solver Suite #9 (100, 101, 102) - Non-periodic Solver Suite #10 (103, 104, 105) - Non-periodic Solver Suite #11 (106, 107, 108) - Non-periodic Solver Suite #12 (109, 110, 111) - Non-periodic Solver Suite #13 (112, 113, 114) - Non-periodic Solver Suite #14 (115, 116, 117) - Periodic Ryabenkii-Tsynkov Solver Shell (118, 19, 120) IdeaDRIP:
1 parent 095f50f commit 32db51d

12 files changed

+778
-67
lines changed

ReleaseNotes/01_18_2024.txt

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
Features:
3+
4+
- CRNG R^d Random Sequence Shell (1, 2, 3)
5+
- R^d Random Sequence 1D #1 (4, 5)
6+
- R^d Random Sequence 1D #2 (6, 7)
7+
- R^d Random Sequence 2D #1 (8, 9)
8+
- R^d Random Sequence 2D #2 (10, 11)
9+
- R^d Random Sequence Tridiagonal #1 (14, 15)
10+
- R^d Random Sequence Tridiagonal #2 (16, 17)
11+
- Matrix Bottom Left Location Checker (18, 19)
12+
- Matrix Top Right Location Checker (20, 21)
13+
- R^d Random Sequence Periodic Tridiagonal #1 (22, 23)
14+
- R^d Random Sequence Periodic Tridiagonal #2 (24, 25, 26)
15+
- Number Util Array Row #1 (44, 45, 46)
16+
- Number Util Array Row #2 (47, 48, 49)
17+
- Number Util Array Row #3 (50, 51)
18+
- Number Util Array Row #4 (52, 53)
19+
- Number Util Array Row #5 (54, 55)
20+
- Number Util Array Row #6 (56, 57)
21+
- Number Util Array Row #7 (58, 59, 60)
22+
23+
24+
Bug Fixes/Re-organization:
25+
26+
- Matrix Bottom Left Top Right (12, 13)
27+
28+
29+
Samples:
30+
31+
- Tridiagonal Non-periodic Solver #1 (27, 28)
32+
- Tridiagonal Non-periodic Solver #2 (29, 30, 31)
33+
- Tridiagonal Non-periodic Solver #3 (32, 33, 34)
34+
- Tridiagonal Non-periodic Solver #4 (35, 36, 37)
35+
- Tridiagonal Non-periodic Solver #5 (38, 39, 40)
36+
- Tridiagonal Non-periodic Solver #6 (41, 42, 43)
37+
- Tridiagonal Non-periodic Solver #7 (61, 62, 63)
38+
- Tridiagonal Non-periodic Solver #8 (64, 65, 66)
39+
- Tridiagonal Non-periodic Solver #9 (67, 68, 69)
40+
- Tridiagonal Non-periodic Solver #10 (70, 71, 72)
41+
- Tridiagonal Non-periodic Solver #11 (73, 74, 75)
42+
- Tridiagonal Non-periodic Solver #12 (76, 77, 78)
43+
- Non-periodic Solver Suite #1 (79, 80)
44+
- Non-periodic Solver Suite #2 (81, 82)
45+
- Non-periodic Solver Suite #3 (83, 84)
46+
- Non-periodic Solver Suite #4 (85, 86, 87)
47+
- Non-periodic Solver Suite #5 (88, 89, 90)
48+
- Non-periodic Solver Suite #6 (91, 92, 93)
49+
- Non-periodic Solver Suite #7 (94, 95, 96)
50+
- Non-periodic Solver Suite #8 (97, 98, 99)
51+
- Non-periodic Solver Suite #9 (100, 101, 102)
52+
- Non-periodic Solver Suite #10 (103, 104, 105)
53+
- Non-periodic Solver Suite #11 (106, 107, 108)
54+
- Non-periodic Solver Suite #12 (109, 110, 111)
55+
- Non-periodic Solver Suite #13 (112, 113, 114)
56+
- Non-periodic Solver Suite #14 (115, 116, 117)
57+
- Periodic Ryabenkii-Tsynkov Solver Shell (118, 19, 120)
58+
59+
60+
IdeaDRIP:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
2+
package org.drip.measure.crng;
3+
4+
import org.drip.numerical.linearalgebra.Matrix;
5+
6+
/*
7+
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
8+
*/
9+
10+
/*!
11+
* Copyright (C) 2022 Lakshmi Krishnamurthy
12+
* Copyright (C) 2021 Lakshmi Krishnamurthy
13+
* Copyright (C) 2020 Lakshmi Krishnamurthy
14+
* Copyright (C) 2019 Lakshmi Krishnamurthy
15+
* Copyright (C) 2018 Lakshmi Krishnamurthy
16+
* Copyright (C) 2017 Lakshmi Krishnamurthy
17+
*
18+
* This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
19+
* asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
20+
* analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
21+
* equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
22+
* numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
23+
* graph builder/navigator, and computational support.
24+
*
25+
* https://lakshmidrip.github.io/DROP/
26+
*
27+
* DROP is composed of three modules:
28+
*
29+
* - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
30+
* - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
31+
* - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
32+
*
33+
* DROP Product Core implements libraries for the following:
34+
* - Fixed Income Analytics
35+
* - Loan Analytics
36+
* - Transaction Cost Analytics
37+
*
38+
* DROP Portfolio Core implements libraries for the following:
39+
* - Asset Allocation Analytics
40+
* - Asset Liability Management Analytics
41+
* - Capital Estimation Analytics
42+
* - Exposure Analytics
43+
* - Margin Analytics
44+
* - XVA Analytics
45+
*
46+
* DROP Computational Core implements libraries for the following:
47+
* - Algorithm Support
48+
* - Computation Support
49+
* - Function Analysis
50+
* - Graph Algorithm
51+
* - Model Validation
52+
* - Numerical Analysis
53+
* - Numerical Optimizer
54+
* - Spline Builder
55+
* - Statistical Learning
56+
*
57+
* Documentation for DROP is Spread Over:
58+
*
59+
* - Main => https://lakshmidrip.github.io/DROP/
60+
* - Wiki => https://github.com/lakshmiDRIP/DROP/wiki
61+
* - GitHub => https://github.com/lakshmiDRIP/DROP
62+
* - Repo Layout Taxonomy => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
63+
* - Javadoc => https://lakshmidrip.github.io/DROP/Javadoc/index.html
64+
* - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
65+
* - Release Versions => https://lakshmidrip.github.io/DROP/version.html
66+
* - Community Credits => https://lakshmidrip.github.io/DROP/credits.html
67+
* - Issues Catalog => https://github.com/lakshmiDRIP/DROP/issues
68+
*
69+
* Licensed under the Apache License, Version 2.0 (the "License");
70+
* you may not use this file except in compliance with the License.
71+
*
72+
* You may obtain a copy of the License at
73+
* http://www.apache.org/licenses/LICENSE-2.0
74+
*
75+
* Unless required by applicable law or agreed to in writing, software
76+
* distributed under the License is distributed on an "AS IS" BASIS,
77+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
78+
*
79+
* See the License for the specific language governing permissions and
80+
* limitations under the License.
81+
*/
82+
83+
/**
84+
* <i>RdRandomSequence</i> generates 1D and 2D random arrays.
85+
*
86+
* <br><br>
87+
* <ul>
88+
* <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
89+
* <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li>
90+
* <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/measure/README.md">R<sup>d</sup> Continuous/Discrete Probability Measures</a></li>
91+
* <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/measure/crng/README.md">Continuous Random Number Stream Generator</a></li>
92+
* </ul>
93+
*
94+
* @author Lakshmi Krishnamurthy
95+
*/
96+
97+
public class RdRandomSequence
98+
{
99+
100+
/**
101+
* Construct a 1D Array of Random Elements up to the Maximum Value
102+
*
103+
* @param elementCount Number of Elements in the Array
104+
* @param maximumElement Maximum Element
105+
* @param isEntryInteger TRUE - Entry is an Integer
106+
*
107+
* @return 1D Array of Random Elements up to the Maximum Value
108+
*/
109+
110+
public static final double[] OneD (
111+
final int elementCount,
112+
final double maximumElement,
113+
final boolean isEntryInteger)
114+
{
115+
if (0 >= elementCount || 0 >= maximumElement) {
116+
return null;
117+
}
118+
119+
double[] oneDArray = new double[elementCount];
120+
121+
for (int i = 0; i < elementCount; ++i) {
122+
oneDArray[i] = Math.random() * maximumElement;
123+
124+
if (isEntryInteger) {
125+
oneDArray[i] = (int) (oneDArray[i] + 0.5);
126+
}
127+
}
128+
129+
return oneDArray;
130+
}
131+
132+
/**
133+
* Construct a 2D Matrix of Random Elements up to the Maximum Value
134+
*
135+
* @param elementCount Number of Elements in the Array
136+
* @param maximumElement Maximum Element
137+
* @param isEntryInteger TRUE - Entry is an Integer
138+
*
139+
* @return 2D Matrix of Random Elements up to the Maximum Value
140+
*/
141+
142+
public static final double[][] TwoD (
143+
final int elementCount,
144+
final double maximumElement,
145+
final boolean isEntryInteger)
146+
{
147+
double[][] twoDArray = new double[elementCount][elementCount];
148+
149+
for (int i = 0; i < elementCount; ++i) {
150+
if (null == (twoDArray[i] = OneD (elementCount, maximumElement, isEntryInteger))) {
151+
return null;
152+
}
153+
}
154+
155+
return twoDArray;
156+
}
157+
158+
/**
159+
* Construct a Tridiagonal Matrix of Random Elements up to the Maximum Value
160+
*
161+
* @param elementCount Number of Elements in the Array
162+
* @param maximumElement Maximum Element
163+
* @param isEntryInteger TRUE - Entry is an Integer
164+
*
165+
* @return Tridiagonal Matrix of Random Elements up to the Maximum Value
166+
*/
167+
168+
public static final double[][] Tridiagonal (
169+
final int elementCount,
170+
final double maximumElement,
171+
final boolean isEntryInteger)
172+
{
173+
double[][] tridiagonalMatrix = TwoD (elementCount, maximumElement, isEntryInteger);
174+
175+
if (null == tridiagonalMatrix) {
176+
return null;
177+
}
178+
179+
for (int i = 0; i < tridiagonalMatrix.length; ++i) {
180+
for (int j = 0; j < tridiagonalMatrix.length; ++j) {
181+
if (j <= i - 2 || j >= i + 2) {
182+
tridiagonalMatrix[i][j] = 0.;
183+
}
184+
}
185+
}
186+
187+
return tridiagonalMatrix;
188+
}
189+
190+
/**
191+
* Construct a Periodic Tridiagonal Matrix of Random Elements up to the Maximum Value
192+
*
193+
* @param elementCount Number of Elements in the Array
194+
* @param maximumElement Maximum Element
195+
* @param isEntryInteger TRUE - Entry is an Integer
196+
*
197+
* @return Periodic Tridiagonal Matrix of Random Elements up to the Maximum Value
198+
*/
199+
200+
public static final double[][] PeriodicTridiagonal (
201+
final int elementCount,
202+
final double maximumElement,
203+
final boolean isEntryInteger)
204+
{
205+
double[][] tridiagonalMatrix = TwoD (elementCount, maximumElement, isEntryInteger);
206+
207+
if (null == tridiagonalMatrix) {
208+
return null;
209+
}
210+
211+
for (int i = 0; i < tridiagonalMatrix.length; ++i) {
212+
for (int j = 0; j < tridiagonalMatrix.length; ++j) {
213+
if (j <= i - 2 || j >= i + 2) {
214+
if (!Matrix.TopRight (i, j, elementCount) && !Matrix.BottomLeft (i, j, elementCount)) {
215+
tridiagonalMatrix[i][j] = 0.;
216+
}
217+
}
218+
}
219+
}
220+
221+
return tridiagonalMatrix;
222+
}
223+
}

src/main/java/org/drip/numerical/common/NumberUtil.java

+21-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
package org.drip.numerical.common;
33

4+
import org.drip.service.common.FormatUtil;
5+
46
/*
57
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
68
*/
@@ -837,31 +839,37 @@ public static final boolean Print1DArray (
837839
/**
838840
* Print the contents of the 1D array to the Specified Decimal Location as a Row
839841
*
840-
* @param adblA The 1D array
841-
* @param iNumDecimal Number of Decimal Places to Display
842-
* @param bBailOnNaN Bail on encountering an NaN
842+
* @param doubleArray The 1D array
843+
* @param preDecimalPlaces Number of Decimal Places to Display
844+
* @param postDecimalPlaces Number of Post Decimal Places to Display
845+
* @param bailOnNaN TRUE - Bail on encountering an NaN
843846
*
844847
* @return Contents of the 1D array to the Specified Decimal Location as a Row
845848
*/
846849

847-
public static final String Print1DArrayRow (
848-
final double[] adblA,
849-
final int iNumDecimal,
850-
final boolean bBailOnNaN)
850+
public static final String ArrayRow (
851+
final double[] doubleArray,
852+
final int preDecimalPlaces,
853+
final int postDecimalPlaces,
854+
final boolean bailOnNaN)
851855
{
852-
if (null == adblA || 0 == adblA.length) return "";
856+
if (null == doubleArray || 0 == doubleArray.length) {
857+
return "";
858+
}
853859

854-
int iSize = adblA.length;
860+
int size = doubleArray.length;
855861
String row = "";
856862

857-
for (int i = 0; i < iSize; ++i) {
858-
if (!org.drip.numerical.common.NumberUtil.IsValid (adblA[i]) && bBailOnNaN) return "";
863+
for (int i = 0; i < size; ++i) {
864+
if (!IsValid (doubleArray[i]) && bailOnNaN) {
865+
return "";
866+
}
859867

860868
if (0 != i) {
861-
row = row + " | ";
869+
row = row + " |";
862870
}
863871

864-
row = row + org.drip.service.common.FormatUtil.FormatDouble (adblA[i], 1, iNumDecimal, 1.);
872+
row = row + FormatUtil.FormatDouble (doubleArray[i], preDecimalPlaces, postDecimalPlaces, 1.);
865873
}
866874

867875
return row;

0 commit comments

Comments
 (0)