Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- Implementation of R1/C1 Matrices (8, 9)
	- Numerical R^1 Square Matrix Re-work (10, 11, 12)
	- Numerical R^1 Tridiagonal Matrix Re-work (13, 14)
	- Numerical R^1 Non-periodic Tridiagonal Matrix Re-work (15, 16)
	- Numerical R^1 Periodic Tridiagonal Matrix Re-work (17, 18)
	- Numerical R^1 Triangular Matrix Re-work (19, 20, 21)
	- Linear Algebra R^1 Matrix Util (22, 23, 24)
	- Implementation of Complex Number Suite (25)
	- Numerical Complex C1 Shell #1 (26, 27, 28)
	- Numerical Complex C1 Shell #2 (29, 30, 31)
	- Numerical Complex Cartesian C1 Re-work (32, 33, 34)
	- Numerical Complex C1 Cartesian Re-work (35, 36)
	- C1 Matrix Util Add #1 (37, 38, 39)
	- C1 Matrix Util Add #2 (40, 41, 42)
	- C1 Matrix Util Add #3 (43, 44, 45)
	- C1 Matrix Util Add #4 (46, 47, 48)
	- C1 Matrix Util Scale #1 (49, 50, 51)
	- C1 Matrix Util Scale #2 (52, 53, 54)
	- C1 Matrix Util Scale #3 (55, 56, 57)
	- C1 Matrix Util Scale #4 (58, 59, 60)
	- C1 Matrix Util Subtract #1 (61, 62, 63)
	- C1 Matrix Util Subtract #2 (64, 65, 66)
	- C1 Matrix Util Subtract #3 (67, 68, 69)
	- C1 Matrix Util Subtract #4 (70, 71, 72)
	- C1 Matrix Util Multiply #1 (73, 74, 75)
	- C1 Matrix Util Multiply #2 (76, 77, 78)
	- C1 Matrix Util Multiply #3 (79, 80, 81)
	- C1 Matrix Util Multiply #4 (82, 83, 84)
	- C1 Matrix Util Divide #1 (85, 86, 87)
	- C1 Matrix Util Divide #2 (88, 89, 90)
	- C1 Matrix Util Divide #3 (91, 92, 93)
	- C1 Matrix Util Divide #4 (94, 95, 96)
	- C1 Matrix Util Square #1 (97, 98, 99)
	- C1 Matrix Util Square #2 (100, 101, 102)
	- C1 Matrix Util Square #3 (103, 104, 105)
	- C1 Matrix Util Square #4 (106, 107, 108)
	- C1 Matrix Util Square Root #1 (109, 110, 111)
	- C1 Matrix Util Square Root #2 (112, 113, 114)
	- C1 Matrix Util Square Root #3 (115, 116, 117)
	- C1 Matrix Util Square Root #4 (118, 119, 120)


Bug Fixes/Re-organization:

Samples:

IdeaDRIP:

	- Unitary Matrix Elementary Constructions - 2x2 (1-7)
  • Loading branch information
Lakshmik committed Aug 11, 2024
1 parent a805121 commit 9ab34b5
Show file tree
Hide file tree
Showing 223 changed files with 1,945 additions and 1,422 deletions.
211 changes: 211 additions & 0 deletions IdeaDRIP/NumericalAnalysis/NA_v0.08
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@

--------------------------
#1 - Successive Over-Relaxation
--------------------------
--------------------------
1.1) Successive Over-Relaxation Method for A.x = b; A - n x n square matrix, x - unknown vector, b - RHS vector
1.2) Decompose A into Diagonal, Lower, and upper Triangular Matrices; A = D + L + U
1.3) SOR Scheme uses omega input
1.4) Forward subsitution scheme to iteratively determine the x_i's
1.5) SOR Scheme Linear System Convergence: Inputs A and D, Jacobi Iteration Matrix Spectral Radius, omega
- Construct Jacobi Iteration Matrix: C_Jacobian = I - (Inverse D) A
- Convergence Verification #1: Ensure that Jacobi Iteration Matrix Spectral Radius is < 1
- Convergence Verification #2: Ensure omega between 0 and 2
- Optimal Relaxation Parameter Expression in terms of Jacobi Iteration Matrix Spectral Radius
- Omega Based Convergence Rate Expression
- Gauss-Seidel omega = 1; corresponding Convergence Rate
- Optimal Omega Convergence Rate
1.6) Generic Iterative Solver Method:
- Inputs: Iterator Function(x) and omega
- Unrelaxed Iterated variable: x_n+1 = f(x_n)
- SOR Based Iterated variable: x_n+1 = (1-omega).x_n + omega.f(x_n)
- SOR Based Iterated variable for Unknown Vector x: x_n+1 = (1-omega).x_n + omega.(L_star inverse)(b - U.x_n)
--------------------------

--------------------------
#2 - Successive Over-Relaxation
--------------------------
--------------------------
2.1) SSOR Algorithm - Inputs; A, omega, and gamma
- Decompose into D and L
- Pre-conditioner Matrix: Expression from SSOR
- Finally SSOR Iteration Formula
--------------------------

----------------------------
#7 - Tridiagonal matrix algorithm
----------------------------
----------------------------
7.1) Is Tridiagonal Check
7.2) Core Algorithm:
- C Prime's and D Prime's Calculation
- Back Substitution for the Result
- Modified better Book-keeping algorithm
7.3) Sherman-Morrison Algorithm:
- Choice of gamma
- Construct Tridiagonal B from A and gamma
- u Column from gamma and c_n
- v Column from a_1 and gamma
- Solve for y from By=d
- Solve for q from Bq=u
- Use Sherman Morrison Formula to extract x
7.4) Alternate Boundary Condition Algorithm:
- Solve Au=d for u
- Solve Av={-a_2, 0, ..., -c_n} for v
- Full solution is x_i = u_i + x_1 * v_i
- x_1 if computed using formula
----------------------------

----------------------------
#8 - Triangular Matrix
----------------------------
----------------------------
8.1) Description:
- Lower/Left Triangular Verification
- Upper/Right Triangular Verification
- Diagonal Matrix Verification
- Upper/Lower Trapezoidal Verification
8.2) Forward/Back Substitution:
- Inputs => L and b
- Forward Substitution
- Inputs => U and b
- Back Substitution
8.3) Properties:
- Is Matrix Normal, i.e., A times A transpose = A transpose times A
- Characteristic Polynomial
- Determinant/Permanent
8.4) Special Forms:
- Upper/Lower Unitriangular Matrix Verification
- Upper/Lower Strictly Matrix Verification
- Upper/Lower Atomic Matrix Verification
----------------------------

----------------------------
#9 - Sylvester Equation
----------------------------
----------------------------
9.1) Matrix Form:
- Inputs: A, B, and C
- Size Constraints Verification
9.2) Solution Criteria:
- Co-joint EigenSpectrum between A and B
9.3) Numerical Solution:
- Decomposition of A/B using Schur Decomposition into Triangular Form
- Forward/Back Substitution
----------------------------

----------------------------
#10 - Bartels-Stewart Algorithm
----------------------------
----------------------------
10.1) Matrix Form:
- Inputs: A, B, and C
- Size Constraints Verification
10.2) Schur Decompositions:
- R = U^T A U - emits U and R
- S = V^T B^T V - emits V and S
- F = U^T C V
- Y = U^T X V
- Solution to R.Y - Y.S^T = F
- Finally X = U.Y.V^T
10.3) Computational Costs:
- Flops cost for Schur decomposition
- Flops cost overall
10.4) Hessenberg-Schur Decompositions:
- R = U^T A U becomes H = Q^T A Q - thus emits Q and H (Upper Hessenberg)
- Computational Costs
----------------------------

----------------------------
#11 - Gershgorin Circle Theorem
----------------------------
----------------------------
11.1) Gershgorin Disc:
- Diagonal Entry
- Radius
- One disc per Row/Column in Square Matrix
- Optimal Disc based on Row/Column
11.2) Tolerance based Gershgorin Convergence Criterion
11.3) Joint and Disjoint Discs
11.4) Gershgorin Strengthener
11.5) Row/Column Diagonal Dominance
----------------------------

----------------------------
#12 - Condition Number
----------------------------
----------------------------
12.1) Condition Number Calculation:
- Absolute Error
- Relative Error
- Absolute Condition Number
- Relative Condition Number
12.2) Matrix Condition Number Calculation:
- Condition Number as a Product of Regular and Inverse Norms
- L2 Norm
- L2 Norm for Normal Matrix
- L2 Norm for Unitary Matrix
- Default Condition Number
- L Infinity Norm
- L Infinity Norm Triangular Matrix
12.3) Non-linear
- One Variable
- Basic Formula
- Condition Numbers for Common Functions
- Multi Variables
----------------------------

----------------------------
#13 - Unitary Matrix
----------------------------
----------------------------
13.1) Properties:
- U.U conjugate = I defines unitary matrix
- U.U conjugate = U conjugate.U = I
- det U = 1
- Eigenvectors are orthogonal
- U conjugate = U inverse
- Norm (U.x) = Norm (x)
- Normal Matrix U
13.2) 2x2 Elementary Matrices
- Wiki Representation #1
- Wiki Representation #2
- Wiki Representation #3
- Wiki Representation #4
----------------------------

--------------------------
#14 - Crank–Nicolson method
--------------------------
--------------------------
14.1) von Neumann Stability Validator - Inputs; time-step, diffusivity, space step
- 1D => time step * diffusivity / space step ^2 < 0.5
- nD => time step * diffusivity / (space step hypotenuse) ^ 2 < 0.5
14.2) Set up:
- Input: Spatial variable x
- Input: Time variable t
- Inputs: State variable u, du/dx, d2u/dx2 - all at time t
- Second Order, 1D => du/dt = F (u, x, t, du/dx, d2u/dx2)
14.3) Finite Difference Evolution Scheme:
- Time Step delta_t, space step delta_x
- Forward Difference: F calculated at x
- Backward Difference: F calculated at x + delta_x
- Crank Nicolson: Average of Forward/Backward
14.4) 1D Diffusion:
- Inputs: 1D von Neumann Stability Validator, Number of time/space steps
- Time Index n, Space Index i
- Explicit Tridiagonal form for the discretization - State concentration at n+1 given state concentration at n
- Non-linear diffusion coefficient:
- Linearization across x_i and x_i+1
- Quasi-explicit forms accommodation
14.5) 2D Diffusion:
- Inputs: 2D von Neumann Stability Validator, Number of time/space steps
- Time Index n, Space Index i, j
- Explicit Tridiagonal form for the discretization - State concentration at n+1 given state concentration at n
- Explicit Solution using the Alternative Difference Implicit Scheme
14.6) Extension to Iterative Solver Schemes above:
- Input: State Space "velocity" dF/du
- Input: State "Step Size" delta_u
- Fixed Point Iterative Location Scheme
- Relaxation Scheme based Robustness => Input: Relaxation Parameter
--------------------------
52 changes: 52 additions & 0 deletions ReleaseNotes/03_13_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

Features:

- Implementation of R1/C1 Matrices (8, 9)
- Numerical R^1 Square Matrix Re-work (10, 11, 12)
- Numerical R^1 Tridiagonal Matrix Re-work (13, 14)
- Numerical R^1 Non-periodic Tridiagonal Matrix Re-work (15, 16)
- Numerical R^1 Periodic Tridiagonal Matrix Re-work (17, 18)
- Numerical R^1 Triangular Matrix Re-work (19, 20, 21)
- Linear Algebra R^1 Matrix Util (22, 23, 24)
- Implementation of Complex Number Suite (25)
- Numerical Complex C1 Shell #1 (26, 27, 28)
- Numerical Complex C1 Shell #2 (29, 30, 31)
- Numerical Complex Cartesian C1 Re-work (32, 33, 34)
- Numerical Complex C1 Cartesian Re-work (35, 36)
- C1 Matrix Util Add #1 (37, 38, 39)
- C1 Matrix Util Add #2 (40, 41, 42)
- C1 Matrix Util Add #3 (43, 44, 45)
- C1 Matrix Util Add #4 (46, 47, 48)
- C1 Matrix Util Scale #1 (49, 50, 51)
- C1 Matrix Util Scale #2 (52, 53, 54)
- C1 Matrix Util Scale #3 (55, 56, 57)
- C1 Matrix Util Scale #4 (58, 59, 60)
- C1 Matrix Util Subtract #1 (61, 62, 63)
- C1 Matrix Util Subtract #2 (64, 65, 66)
- C1 Matrix Util Subtract #3 (67, 68, 69)
- C1 Matrix Util Subtract #4 (70, 71, 72)
- C1 Matrix Util Multiply #1 (73, 74, 75)
- C1 Matrix Util Multiply #2 (76, 77, 78)
- C1 Matrix Util Multiply #3 (79, 80, 81)
- C1 Matrix Util Multiply #4 (82, 83, 84)
- C1 Matrix Util Divide #1 (85, 86, 87)
- C1 Matrix Util Divide #2 (88, 89, 90)
- C1 Matrix Util Divide #3 (91, 92, 93)
- C1 Matrix Util Divide #4 (94, 95, 96)
- C1 Matrix Util Square #1 (97, 98, 99)
- C1 Matrix Util Square #2 (100, 101, 102)
- C1 Matrix Util Square #3 (103, 104, 105)
- C1 Matrix Util Square #4 (106, 107, 108)
- C1 Matrix Util Square Root #1 (109, 110, 111)
- C1 Matrix Util Square Root #2 (112, 113, 114)
- C1 Matrix Util Square Root #3 (115, 116, 117)
- C1 Matrix Util Square Root #4 (118, 119, 120)


Bug Fixes/Re-organization:

Samples:

IdeaDRIP:

- Unitary Matrix Elementary Constructions - 2x2 (1-7)
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public org.drip.function.definition.RdToR1 steadyStatePDF()
);

final double[][] omegaInverse =
org.drip.numerical.linearalgebra.MatrixUtil.InvertUsingGaussianElimination (
org.drip.numerical.linearalgebra.R1MatrixUtil.InvertUsingGaussianElimination (
omega
);

Expand Down Expand Up @@ -406,9 +406,9 @@ public org.drip.function.definition.RdToR1 steadyStatePDF()
throws java.lang.Exception
{
return rdNormalizerFinal * r1ToR1Exponential.evaluate (
org.drip.numerical.linearalgebra.MatrixUtil.DotProduct (
org.drip.numerical.linearalgebra.R1MatrixUtil.DotProduct (
xArray,
org.drip.numerical.linearalgebra.MatrixUtil.Product (
org.drip.numerical.linearalgebra.R1MatrixUtil.Product (
omegaInverse,
xArray
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public org.drip.dynamics.ito.TimeRdVertex evolve (
return null;
}

double[] volatilityShiftArray = org.drip.numerical.linearalgebra.MatrixUtil.Product (
double[] volatilityShiftArray = org.drip.numerical.linearalgebra.R1MatrixUtil.Product (
pointVolatilityGrid (
currentVertex
),
Expand Down
Loading

0 comments on commit 9ab34b5

Please sign in to comment.