-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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:
- Loading branch information
Showing
12 changed files
with
778 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
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: |
223 changes: 223 additions & 0 deletions
223
src/main/java/org/drip/measure/crng/RdRandomSequence.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
|
||
package org.drip.measure.crng; | ||
|
||
import org.drip.numerical.linearalgebra.Matrix; | ||
|
||
/* | ||
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | ||
*/ | ||
|
||
/*! | ||
* Copyright (C) 2022 Lakshmi Krishnamurthy | ||
* Copyright (C) 2021 Lakshmi Krishnamurthy | ||
* Copyright (C) 2020 Lakshmi Krishnamurthy | ||
* Copyright (C) 2019 Lakshmi Krishnamurthy | ||
* Copyright (C) 2018 Lakshmi Krishnamurthy | ||
* Copyright (C) 2017 Lakshmi Krishnamurthy | ||
* | ||
* This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics, | ||
* asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment | ||
* analytics, and portfolio construction analytics within and across fixed income, credit, commodity, | ||
* equity, FX, and structured products. It also includes auxiliary libraries for algorithm support, | ||
* numerical analysis, numerical optimization, spline builder, model validation, statistical learning, | ||
* graph builder/navigator, and computational support. | ||
* | ||
* https://lakshmidrip.github.io/DROP/ | ||
* | ||
* DROP is composed of three modules: | ||
* | ||
* - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/ | ||
* - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/ | ||
* - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/ | ||
* | ||
* DROP Product Core implements libraries for the following: | ||
* - Fixed Income Analytics | ||
* - Loan Analytics | ||
* - Transaction Cost Analytics | ||
* | ||
* DROP Portfolio Core implements libraries for the following: | ||
* - Asset Allocation Analytics | ||
* - Asset Liability Management Analytics | ||
* - Capital Estimation Analytics | ||
* - Exposure Analytics | ||
* - Margin Analytics | ||
* - XVA Analytics | ||
* | ||
* DROP Computational Core implements libraries for the following: | ||
* - Algorithm Support | ||
* - Computation Support | ||
* - Function Analysis | ||
* - Graph Algorithm | ||
* - Model Validation | ||
* - Numerical Analysis | ||
* - Numerical Optimizer | ||
* - Spline Builder | ||
* - Statistical Learning | ||
* | ||
* Documentation for DROP is Spread Over: | ||
* | ||
* - Main => https://lakshmidrip.github.io/DROP/ | ||
* - Wiki => https://github.com/lakshmiDRIP/DROP/wiki | ||
* - GitHub => https://github.com/lakshmiDRIP/DROP | ||
* - Repo Layout Taxonomy => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md | ||
* - Javadoc => https://lakshmidrip.github.io/DROP/Javadoc/index.html | ||
* - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal | ||
* - Release Versions => https://lakshmidrip.github.io/DROP/version.html | ||
* - Community Credits => https://lakshmidrip.github.io/DROP/credits.html | ||
* - Issues Catalog => https://github.com/lakshmiDRIP/DROP/issues | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* <i>RdRandomSequence</i> generates 1D and 2D random arrays. | ||
* | ||
* <br><br> | ||
* <ul> | ||
* <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li> | ||
* <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li> | ||
* <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> | ||
* <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> | ||
* </ul> | ||
* | ||
* @author Lakshmi Krishnamurthy | ||
*/ | ||
|
||
public class RdRandomSequence | ||
{ | ||
|
||
/** | ||
* Construct a 1D Array of Random Elements up to the Maximum Value | ||
* | ||
* @param elementCount Number of Elements in the Array | ||
* @param maximumElement Maximum Element | ||
* @param isEntryInteger TRUE - Entry is an Integer | ||
* | ||
* @return 1D Array of Random Elements up to the Maximum Value | ||
*/ | ||
|
||
public static final double[] OneD ( | ||
final int elementCount, | ||
final double maximumElement, | ||
final boolean isEntryInteger) | ||
{ | ||
if (0 >= elementCount || 0 >= maximumElement) { | ||
return null; | ||
} | ||
|
||
double[] oneDArray = new double[elementCount]; | ||
|
||
for (int i = 0; i < elementCount; ++i) { | ||
oneDArray[i] = Math.random() * maximumElement; | ||
|
||
if (isEntryInteger) { | ||
oneDArray[i] = (int) (oneDArray[i] + 0.5); | ||
} | ||
} | ||
|
||
return oneDArray; | ||
} | ||
|
||
/** | ||
* Construct a 2D Matrix of Random Elements up to the Maximum Value | ||
* | ||
* @param elementCount Number of Elements in the Array | ||
* @param maximumElement Maximum Element | ||
* @param isEntryInteger TRUE - Entry is an Integer | ||
* | ||
* @return 2D Matrix of Random Elements up to the Maximum Value | ||
*/ | ||
|
||
public static final double[][] TwoD ( | ||
final int elementCount, | ||
final double maximumElement, | ||
final boolean isEntryInteger) | ||
{ | ||
double[][] twoDArray = new double[elementCount][elementCount]; | ||
|
||
for (int i = 0; i < elementCount; ++i) { | ||
if (null == (twoDArray[i] = OneD (elementCount, maximumElement, isEntryInteger))) { | ||
return null; | ||
} | ||
} | ||
|
||
return twoDArray; | ||
} | ||
|
||
/** | ||
* Construct a Tridiagonal Matrix of Random Elements up to the Maximum Value | ||
* | ||
* @param elementCount Number of Elements in the Array | ||
* @param maximumElement Maximum Element | ||
* @param isEntryInteger TRUE - Entry is an Integer | ||
* | ||
* @return Tridiagonal Matrix of Random Elements up to the Maximum Value | ||
*/ | ||
|
||
public static final double[][] Tridiagonal ( | ||
final int elementCount, | ||
final double maximumElement, | ||
final boolean isEntryInteger) | ||
{ | ||
double[][] tridiagonalMatrix = TwoD (elementCount, maximumElement, isEntryInteger); | ||
|
||
if (null == tridiagonalMatrix) { | ||
return null; | ||
} | ||
|
||
for (int i = 0; i < tridiagonalMatrix.length; ++i) { | ||
for (int j = 0; j < tridiagonalMatrix.length; ++j) { | ||
if (j <= i - 2 || j >= i + 2) { | ||
tridiagonalMatrix[i][j] = 0.; | ||
} | ||
} | ||
} | ||
|
||
return tridiagonalMatrix; | ||
} | ||
|
||
/** | ||
* Construct a Periodic Tridiagonal Matrix of Random Elements up to the Maximum Value | ||
* | ||
* @param elementCount Number of Elements in the Array | ||
* @param maximumElement Maximum Element | ||
* @param isEntryInteger TRUE - Entry is an Integer | ||
* | ||
* @return Periodic Tridiagonal Matrix of Random Elements up to the Maximum Value | ||
*/ | ||
|
||
public static final double[][] PeriodicTridiagonal ( | ||
final int elementCount, | ||
final double maximumElement, | ||
final boolean isEntryInteger) | ||
{ | ||
double[][] tridiagonalMatrix = TwoD (elementCount, maximumElement, isEntryInteger); | ||
|
||
if (null == tridiagonalMatrix) { | ||
return null; | ||
} | ||
|
||
for (int i = 0; i < tridiagonalMatrix.length; ++i) { | ||
for (int j = 0; j < tridiagonalMatrix.length; ++j) { | ||
if (j <= i - 2 || j >= i + 2) { | ||
if (!Matrix.TopRight (i, j, elementCount) && !Matrix.BottomLeft (i, j, elementCount)) { | ||
tridiagonalMatrix[i][j] = 0.; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return tridiagonalMatrix; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.