Skip to content

Commit 9b01fa1

Browse files
committed
Features:
- Gauss-Seidel Convergence Rate Analyzer (16, 17, 18) Bug Fixes/Re-organization: - Off-diagonal Jacobi Iteration Elements (52) Samples: - SOR Relaxation Parameter Convergence #1 (1, 2, 3) - SOR Relaxation Parameter Convergence #2 (4, 5, 6) - SOR Relaxation Parameter Convergence #3 (7, 8, 9) - SOR Relaxation Parameter Convergence #4 (10, 11, 12) - SOR Relaxation Parameter Convergence #5 (13, 14, 15) - SOR Relaxation Parameter Convergence #6 (19, 20, 21) - SOR Matrix Conditioning Checks #1 (22, 23, 24) - SOR Matrix Conditioning Checks #2 (25, 26, 27) - SOR Matrix Conditioning Checks #3 (28, 29, 30) - SOR Matrix Conditioning Checks #4 (31, 32, 33) - SOR Matrix Conditioning Checks #5 (34, 35, 36) - SOR Matrix Conditioning Checks #6 (37, 38, 39) - SOR DUL Matrix Decomposition #1 (40, 41, 42) - SOR DUL Matrix Decomposition #2 (43, 44, 45) - SOR DUL Matrix Decomposition #3 (46, 47, 48) - SOR DUL Matrix Decomposition #4 (49, 50, 51) IdeaDRIP: - Crank-Nicolson Method (53-60) - Crank-Nicolson Method - Principle (61-74) - Crank-Nicolson Method - Example: 1D Diffusion (75-84) - Crank-Nicolson Method - Example: 1D Diffusion with Advection for Steady Flow, with Multiple Channel Connections (85-120)
1 parent 534e299 commit 9b01fa1

File tree

6 files changed

+526
-7
lines changed

6 files changed

+526
-7
lines changed

ReleaseNotes/01_11_2024.txt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Features:
3+
4+
- Gauss-Seidel Convergence Rate Analyzer (16, 17, 18)
5+
6+
7+
Bug Fixes/Re-organization:
8+
9+
- Off-diagonal Jacobi Iteration Elements (52)
10+
11+
12+
Samples:
13+
14+
- SOR Relaxation Parameter Convergence #1 (1, 2, 3)
15+
- SOR Relaxation Parameter Convergence #2 (4, 5, 6)
16+
- SOR Relaxation Parameter Convergence #3 (7, 8, 9)
17+
- SOR Relaxation Parameter Convergence #4 (10, 11, 12)
18+
- SOR Relaxation Parameter Convergence #5 (13, 14, 15)
19+
- SOR Relaxation Parameter Convergence #6 (19, 20, 21)
20+
- SOR Matrix Conditioning Checks #1 (22, 23, 24)
21+
- SOR Matrix Conditioning Checks #2 (25, 26, 27)
22+
- SOR Matrix Conditioning Checks #3 (28, 29, 30)
23+
- SOR Matrix Conditioning Checks #4 (31, 32, 33)
24+
- SOR Matrix Conditioning Checks #5 (34, 35, 36)
25+
- SOR Matrix Conditioning Checks #6 (37, 38, 39)
26+
- SOR DUL Matrix Decomposition #1 (40, 41, 42)
27+
- SOR DUL Matrix Decomposition #2 (43, 44, 45)
28+
- SOR DUL Matrix Decomposition #3 (46, 47, 48)
29+
- SOR DUL Matrix Decomposition #4 (49, 50, 51)
30+
31+
32+
IdeaDRIP:
33+
34+
- Crank-Nicolson Method (53-60)
35+
- Crank-Nicolson Method - Principle (61-74)
36+
- Crank-Nicolson Method - Example: 1D Diffusion (75-84)
37+
- Crank-Nicolson Method - Example: 1D Diffusion with Advection for Steady Flow, with Multiple Channel Connections (85-120)

src/main/java/org/drip/numerical/iterativesolver/SuccessiveOverRelaxationConvergenceAnalyzer.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,18 @@ public double optimalRelaxationParameter()
287287
return 1. + spectralRadiusTransformer * spectralRadiusTransformer;
288288
}
289289

290+
/**
291+
* Estimate the Gauss-Seidel Convergence Rate from the Relaxation Parameter and the Jacobi Iteration
292+
* Matrix Spectral Radius
293+
*
294+
* @return Gauss-Seidel Convergence Rate
295+
*/
296+
297+
public double gaussSeidelRate()
298+
{
299+
return _jacobiIterationMatrixSpectralRadius * _jacobiIterationMatrixSpectralRadius;
300+
}
301+
290302
/**
291303
* Estimate the Convergence Rate from the Relaxation Parameter and the Jacobi Iteration Matrix Spectral
292304
* Radius
@@ -296,11 +308,6 @@ public double optimalRelaxationParameter()
296308

297309
public double rate()
298310
{
299-
if (SuccessiveOverRelaxationIteratorSetting.RELAXATION_PARAMETER_GAUSS_SEIDEL == _relaxationParameter)
300-
{
301-
return _jacobiIterationMatrixSpectralRadius * _jacobiIterationMatrixSpectralRadius;
302-
}
303-
304311
double optimalRelaxationParameter = optimalRelaxationParameter();
305312

306313
if (_relaxationParameter <= optimalRelaxationParameter) {
@@ -322,7 +329,7 @@ public double rate()
322329
* @return Convergence Rate corresponding to Optimal Relaxation Parameter
323330
*/
324331

325-
public double optimalRelaxationParameterRate()
332+
public double optimalRate()
326333
{
327334
double sqrtOneMinusMuSquared =
328335
Math.sqrt (1. - _jacobiIterationMatrixSpectralRadius * _jacobiIterationMatrixSpectralRadius);

src/main/java/org/drip/numerical/linearalgebra/Matrix.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ public static final double[][] JacobiIteration (
13421342

13431343
for (int i = 0; i < size; ++i) {
13441344
for (int j = 0; j < size; ++j) {
1345-
jacobiIterationMatrix[i][j] = i == j ? 0. : 1. - squareMatrix[i][j];
1345+
jacobiIterationMatrix[i][j] = i == j ? 0. : squareMatrix[i][j];
13461346
}
13471347
}
13481348

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
2+
package org.drip.sample.sor;
3+
4+
import org.drip.numerical.common.NumberUtil;
5+
import org.drip.numerical.linearalgebra.Matrix;
6+
import org.drip.service.env.EnvManager;
7+
8+
/*
9+
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
10+
*/
11+
12+
/*!
13+
* Copyright (C) 2025 Lakshmi Krishnamurthy
14+
*
15+
* This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
16+
* asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
17+
* analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
18+
* equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
19+
* numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
20+
* graph builder/navigator, and computational support.
21+
*
22+
* https://lakshmidrip.github.io/DROP/
23+
*
24+
* DROP is composed of three modules:
25+
*
26+
* - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
27+
* - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
28+
* - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
29+
*
30+
* DROP Product Core implements libraries for the following:
31+
* - Fixed Income Analytics
32+
* - Loan Analytics
33+
* - Transaction Cost Analytics
34+
*
35+
* DROP Portfolio Core implements libraries for the following:
36+
* - Asset Allocation Analytics
37+
* - Asset Liability Management Analytics
38+
* - Capital Estimation Analytics
39+
* - Exposure Analytics
40+
* - Margin Analytics
41+
* - XVA Analytics
42+
*
43+
* DROP Computational Core implements libraries for the following:
44+
* - Algorithm Support
45+
* - Computation Support
46+
* - Function Analysis
47+
* - Graph Algorithm
48+
* - Model Validation
49+
* - Numerical Analysis
50+
* - Numerical Optimizer
51+
* - Spline Builder
52+
* - Statistical Learning
53+
*
54+
* Documentation for DROP is Spread Over:
55+
*
56+
* - Main => https://lakshmidrip.github.io/DROP/
57+
* - Wiki => https://github.com/lakshmiDRIP/DROP/wiki
58+
* - GitHub => https://github.com/lakshmiDRIP/DROP
59+
* - Repo Layout Taxonomy => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
60+
* - Javadoc => https://lakshmidrip.github.io/DROP/Javadoc/index.html
61+
* - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
62+
* - Release Versions => https://lakshmidrip.github.io/DROP/version.html
63+
* - Community Credits => https://lakshmidrip.github.io/DROP/credits.html
64+
* - Issues Catalog => https://github.com/lakshmiDRIP/DROP/issues
65+
*
66+
* Licensed under the Apache License, Version 2.0 (the "License");
67+
* you may not use this file except in compliance with the License.
68+
*
69+
* You may obtain a copy of the License at
70+
* http://www.apache.org/licenses/LICENSE-2.0
71+
*
72+
* Unless required by applicable law or agreed to in writing, software
73+
* distributed under the License is distributed on an "AS IS" BASIS,
74+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
75+
*
76+
* See the License for the specific language governing permissions and
77+
* limitations under the License.
78+
*/
79+
80+
/**
81+
* <i>DULDecomposition</i> demonstrates the Decomposition of a Square Matrix into Diagonal, Lower, and Upper
82+
* Triangular Matrices. The References are:
83+
*
84+
* <br><br>
85+
* <ul>
86+
* <li>
87+
* Greenbaum, A. (1997): <i>Iterative Methods for Solving Linear Systems</i> <b>Society for
88+
* Industrial and Applied Mathematics</b> Philadelphia, PA
89+
* </li>
90+
* <li>
91+
* Hackbusch, W. (2016): <i>Iterative Solution of Large Sparse Systems of Equations</i>
92+
* <b>Spring-Verlag</b> Berlin, Germany
93+
* </li>
94+
* <li>
95+
* Wikipedia (2023): Symmetric Successive Over-Relaxation
96+
* https://en.wikipedia.org/wiki/Symmetric_successive_over-relaxation
97+
* </li>
98+
* <li>
99+
* Wikipedia (2024): Successive Over-Relaxation
100+
* https://en.wikipedia.org/wiki/Successive_over-relaxation
101+
* </li>
102+
* <li>
103+
* Young, D. M. (1950): <i>Iterative methods for solving partial difference equations of elliptical
104+
* type</i> <b>Harvard University</b> Cambridge, MA
105+
* </li>
106+
* </ul>
107+
*
108+
* <br><br>
109+
* <ul>
110+
* <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
111+
* <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li>
112+
* <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">DROP API Construction and Usage</a></li>
113+
* <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/sor/README.md">Successive Over-relaxation Customization/Usage</a></li>
114+
* </ul>
115+
* <br><br>
116+
*
117+
* @author Lakshmi Krishnamurthy
118+
*/
119+
120+
public class DULDecomposition
121+
{
122+
123+
/**
124+
* Entry Point
125+
*
126+
* @param argumentArray Command Line Argument Array
127+
*
128+
* @throws Exception Thrown on Error/Exception Situation
129+
*/
130+
131+
public static final void main (
132+
final String[] argumentArray)
133+
throws Exception
134+
{
135+
EnvManager.InitEnv (
136+
""
137+
);
138+
139+
double[][] squareMatrix = new double[][] {
140+
{ 4., -1., -6., 0.},
141+
{-5., -4., 10., 8.},
142+
{ 0., 9., 4., -2.},
143+
{ 1., 0., -7., 5.},
144+
};
145+
146+
System.out.println ("\t|----------------------------------------------------------------------");
147+
148+
System.out.println ("\t| JACOBI ITERATION MATRIX ");
149+
150+
System.out.println ("\t|----------------------------------------------------------------------");
151+
152+
NumberUtil.Print2DArrayPair (
153+
"\t| SQUARE",
154+
" JACOBI ITERATION",
155+
squareMatrix,
156+
Matrix.JacobiIteration (squareMatrix),
157+
false
158+
);
159+
160+
System.out.println ("\t|----------------------------------------------------------------------");
161+
162+
System.out.println();
163+
164+
System.out.println();
165+
166+
System.out.println ("\t|----------------------------------------------------------------------");
167+
168+
System.out.println ("\t| DIAGONALIZED MATRIX ");
169+
170+
System.out.println ("\t|----------------------------------------------------------------------");
171+
172+
NumberUtil.Print2DArrayPair (
173+
"\t| SQUARE",
174+
" DIAGONAL",
175+
squareMatrix,
176+
Matrix.Diagonal (squareMatrix),
177+
false
178+
);
179+
180+
System.out.println ("\t|----------------------------------------------------------------------");
181+
182+
System.out.println();
183+
184+
System.out.println();
185+
186+
System.out.println ("\t|----------------------------------------------------------------------");
187+
188+
System.out.println ("\t| STRICTLY LOWER TRIANGULAR MATRIX ");
189+
190+
System.out.println ("\t|----------------------------------------------------------------------");
191+
192+
NumberUtil.Print2DArrayPair (
193+
"\t| SQUARE",
194+
" LOWER TRIANGULAR",
195+
squareMatrix,
196+
Matrix.StrictlyLowerTriangular (squareMatrix),
197+
false
198+
);
199+
200+
System.out.println ("\t|----------------------------------------------------------------------");
201+
202+
System.out.println();
203+
204+
System.out.println();
205+
206+
System.out.println ("\t|----------------------------------------------------------------------");
207+
208+
System.out.println ("\t| STRICTLY UPPER TRIANGULAR MATRIX ");
209+
210+
System.out.println ("\t|----------------------------------------------------------------------");
211+
212+
NumberUtil.Print2DArrayPair (
213+
"\t| SQUARE",
214+
" UPPER TRIANGULAR",
215+
squareMatrix,
216+
Matrix.StrictlyUpperTriangular (squareMatrix),
217+
false
218+
);
219+
220+
System.out.println ("\t|----------------------------------------------------------------------");
221+
222+
EnvManager.TerminateEnv();
223+
}
224+
}

0 commit comments

Comments
 (0)