-
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.
- 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)
- Loading branch information
Showing
6 changed files
with
526 additions
and
7 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,37 @@ | ||
|
||
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) |
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
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
224 changes: 224 additions & 0 deletions
224
src/main/java/org/drip/sample/sor/DULDecomposition.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,224 @@ | ||
|
||
package org.drip.sample.sor; | ||
|
||
import org.drip.numerical.common.NumberUtil; | ||
import org.drip.numerical.linearalgebra.Matrix; | ||
import org.drip.service.env.EnvManager; | ||
|
||
/* | ||
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | ||
*/ | ||
|
||
/*! | ||
* Copyright (C) 2025 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>DULDecomposition</i> demonstrates the Decomposition of a Square Matrix into Diagonal, Lower, and Upper | ||
* Triangular Matrices. The References are: | ||
* | ||
* <br><br> | ||
* <ul> | ||
* <li> | ||
* Greenbaum, A. (1997): <i>Iterative Methods for Solving Linear Systems</i> <b>Society for | ||
* Industrial and Applied Mathematics</b> Philadelphia, PA | ||
* </li> | ||
* <li> | ||
* Hackbusch, W. (2016): <i>Iterative Solution of Large Sparse Systems of Equations</i> | ||
* <b>Spring-Verlag</b> Berlin, Germany | ||
* </li> | ||
* <li> | ||
* Wikipedia (2023): Symmetric Successive Over-Relaxation | ||
* https://en.wikipedia.org/wiki/Symmetric_successive_over-relaxation | ||
* </li> | ||
* <li> | ||
* Wikipedia (2024): Successive Over-Relaxation | ||
* https://en.wikipedia.org/wiki/Successive_over-relaxation | ||
* </li> | ||
* <li> | ||
* Young, D. M. (1950): <i>Iterative methods for solving partial difference equations of elliptical | ||
* type</i> <b>Harvard University</b> Cambridge, MA | ||
* </li> | ||
* </ul> | ||
* | ||
* <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/sample/README.md">DROP API Construction and Usage</a></li> | ||
* <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> | ||
* </ul> | ||
* <br><br> | ||
* | ||
* @author Lakshmi Krishnamurthy | ||
*/ | ||
|
||
public class DULDecomposition | ||
{ | ||
|
||
/** | ||
* Entry Point | ||
* | ||
* @param argumentArray Command Line Argument Array | ||
* | ||
* @throws Exception Thrown on Error/Exception Situation | ||
*/ | ||
|
||
public static final void main ( | ||
final String[] argumentArray) | ||
throws Exception | ||
{ | ||
EnvManager.InitEnv ( | ||
"" | ||
); | ||
|
||
double[][] squareMatrix = new double[][] { | ||
{ 4., -1., -6., 0.}, | ||
{-5., -4., 10., 8.}, | ||
{ 0., 9., 4., -2.}, | ||
{ 1., 0., -7., 5.}, | ||
}; | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
System.out.println ("\t| JACOBI ITERATION MATRIX "); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
NumberUtil.Print2DArrayPair ( | ||
"\t| SQUARE", | ||
" JACOBI ITERATION", | ||
squareMatrix, | ||
Matrix.JacobiIteration (squareMatrix), | ||
false | ||
); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
System.out.println(); | ||
|
||
System.out.println(); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
System.out.println ("\t| DIAGONALIZED MATRIX "); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
NumberUtil.Print2DArrayPair ( | ||
"\t| SQUARE", | ||
" DIAGONAL", | ||
squareMatrix, | ||
Matrix.Diagonal (squareMatrix), | ||
false | ||
); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
System.out.println(); | ||
|
||
System.out.println(); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
System.out.println ("\t| STRICTLY LOWER TRIANGULAR MATRIX "); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
NumberUtil.Print2DArrayPair ( | ||
"\t| SQUARE", | ||
" LOWER TRIANGULAR", | ||
squareMatrix, | ||
Matrix.StrictlyLowerTriangular (squareMatrix), | ||
false | ||
); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
System.out.println(); | ||
|
||
System.out.println(); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
System.out.println ("\t| STRICTLY UPPER TRIANGULAR MATRIX "); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
NumberUtil.Print2DArrayPair ( | ||
"\t| SQUARE", | ||
" UPPER TRIANGULAR", | ||
squareMatrix, | ||
Matrix.StrictlyUpperTriangular (squareMatrix), | ||
false | ||
); | ||
|
||
System.out.println ("\t|----------------------------------------------------------------------"); | ||
|
||
EnvManager.TerminateEnv(); | ||
} | ||
} |
Oops, something went wrong.