Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- Square Matrix is Triangularizable (1, 2)
	- Numerical R^1 -> R^1 Eigenvalue Characteristic Polynomial (3, 4, 5)
	- Square Matrix Eigenvalue Characteristic Polynomial (6, 7, 8)
	- Triangular Matrix Remove R2 Array (9, 10)
	- Triangular Matrix Zero Diagonal Entries (13, 14)
	- Triangular Matrix Is Uni Check (15, 16)
	- Triangular Matrix Is Triangularizable Check (19, 20)
	- Triangular Matrix Determinant and Permanent (21, 22)
	- Square Matrix Triangular Entries #1 (23, 24)
	- Square Matrix Triangular Entries #2 (25, 26)
	- Triangular Matrix Eigenvalue Multiplicity Map (27, 28, 29)
	- Triangular Matrix Eigenvalue Characteristic Polynomial (30, 31, 32)
	- Triangular Matrix Is Unit Check (33, 34)
	- Triangular Matrix Is Normed Check (35, 36)
	- Triangular Matrix Is Upper Unitriangular (37, 38)
	- Triangular Matrix Is Lower Unitriangular (39, 40)
	- Triangular Matrix Atomic Lower #1 (41, 42)
	- Triangular Matrix Atomic Lower #2 (43, 44)
	- Triangular Matrix Atomic Lower #3 (45, 46)
	- Triangular Matrix Atomic Upper #1 (47, 48)
	- Triangular Matrix Atomic Upper #2 (49, 50)
	- Triangular Matrix Is Atomic Unitriangular (51, 52)
	- Triangular Matrix Is Frobenius Unitriangular (53, 54)
	- Triangular Matrix Is Gauss Unitriangular (55, 56)
	- Triangular Matrix Gauss Transformation Unitriangular (57, 58)
	- Linear Algebra Triangular Matrix Constructor (59, 60)
	- Linear Algebra Triangular Matrix Standard (61, 62, 63)
	- Linear Algebra Triangular Matrix Type (64)
	- CRNG Random Matrix Generator Shell (65, 66)
	- Random Matrix Generator Upper Triangular (67, 68, 69)
	- Random Matrix Generator Lower Triangular (70, 71, 72)


Bug Fixes/Re-organization:

	- Linear Algebra Triangular Matrix Revamp (11, 12)
	- Triangular Matrix Determinant/Permanent Revamp (17, 18)
	- Triangular Matrix Variants and Solutions (73, 74)


Samples:

	- Lower Triangular Matrix Shell #1 (75, 76)
	- Lower Triangular Matrix Shell #2 (77, 78)
	- Lower Triangular Matrix Shell #3 (79, 80, 81)
	- Lower Triangular Matrix Shell #4 (82, 83, 84)
	- Lower Triangular Matrix Shell #5 (85, 86, 87)
	- Lower Triangular Matrix Shell #6 (88, 89, 90)
	- Lower Triangular Matrix Shell #7 (91, 92, 93)
	- Lower Triangular Matrix Shell #8 (94, 95, 96)
	- Lower Triangular Matrix Shell #9 (97, 98, 99)
	- Lower Triangular Matrix Shell #10 (100, 101, 102)
	- Lower Triangular Matrix Shell #11 (103, 104, 105)
	- Lower Triangular Matrix Shell #12 (106, 107, 108)
	- Lower Triangular Matrix Shell #13 (109, 110, 111)
	- Lower Triangular Matrix Shell #14 (112, 113, 114)
	- Lower Triangular Matrix Shell #15 (115, 116, 117)
	- Lower Triangular Matrix Shell #16 (118, 119, 120)


IdeaDRIP:
  • Loading branch information
Lakshmik committed Jul 7, 2024
1 parent be1c425 commit e866021
Show file tree
Hide file tree
Showing 8 changed files with 852 additions and 77 deletions.
64 changes: 64 additions & 0 deletions ReleaseNotes/02_06_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

Features:

- Square Matrix is Triangularizable (1, 2)
- Numerical R^1 -> R^1 Eigenvalue Characteristic Polynomial (3, 4, 5)
- Square Matrix Eigenvalue Characteristic Polynomial (6, 7, 8)
- Triangular Matrix Remove R2 Array (9, 10)
- Triangular Matrix Zero Diagonal Entries (13, 14)
- Triangular Matrix Is Uni Check (15, 16)
- Triangular Matrix Is Triangularizable Check (19, 20)
- Triangular Matrix Determinant and Permanent (21, 22)
- Square Matrix Triangular Entries #1 (23, 24)
- Square Matrix Triangular Entries #2 (25, 26)
- Triangular Matrix Eigenvalue Multiplicity Map (27, 28, 29)
- Triangular Matrix Eigenvalue Characteristic Polynomial (30, 31, 32)
- Triangular Matrix Is Unit Check (33, 34)
- Triangular Matrix Is Normed Check (35, 36)
- Triangular Matrix Is Upper Unitriangular (37, 38)
- Triangular Matrix Is Lower Unitriangular (39, 40)
- Triangular Matrix Atomic Lower #1 (41, 42)
- Triangular Matrix Atomic Lower #2 (43, 44)
- Triangular Matrix Atomic Lower #3 (45, 46)
- Triangular Matrix Atomic Upper #1 (47, 48)
- Triangular Matrix Atomic Upper #2 (49, 50)
- Triangular Matrix Is Atomic Unitriangular (51, 52)
- Triangular Matrix Is Frobenius Unitriangular (53, 54)
- Triangular Matrix Is Gauss Unitriangular (55, 56)
- Triangular Matrix Gauss Transformation Unitriangular (57, 58)
- Linear Algebra Triangular Matrix Constructor (59, 60)
- Linear Algebra Triangular Matrix Standard (61, 62, 63)
- Linear Algebra Triangular Matrix Type (64)
- CRNG Random Matrix Generator Shell (65, 66)
- Random Matrix Generator Upper Triangular (67, 68, 69)
- Random Matrix Generator Lower Triangular (70, 71, 72)


Bug Fixes/Re-organization:

- Linear Algebra Triangular Matrix Revamp (11, 12)
- Triangular Matrix Determinant/Permanent Revamp (17, 18)
- Triangular Matrix Variants and Solutions (73, 74)


Samples:

- Lower Triangular Matrix Shell #1 (75, 76)
- Lower Triangular Matrix Shell #2 (77, 78)
- Lower Triangular Matrix Shell #3 (79, 80, 81)
- Lower Triangular Matrix Shell #4 (82, 83, 84)
- Lower Triangular Matrix Shell #5 (85, 86, 87)
- Lower Triangular Matrix Shell #6 (88, 89, 90)
- Lower Triangular Matrix Shell #7 (91, 92, 93)
- Lower Triangular Matrix Shell #8 (94, 95, 96)
- Lower Triangular Matrix Shell #9 (97, 98, 99)
- Lower Triangular Matrix Shell #10 (100, 101, 102)
- Lower Triangular Matrix Shell #11 (103, 104, 105)
- Lower Triangular Matrix Shell #12 (106, 107, 108)
- Lower Triangular Matrix Shell #13 (109, 110, 111)
- Lower Triangular Matrix Shell #14 (112, 113, 114)
- Lower Triangular Matrix Shell #15 (115, 116, 117)
- Lower Triangular Matrix Shell #16 (118, 119, 120)


IdeaDRIP:
170 changes: 170 additions & 0 deletions src/main/java/org/drip/measure/crng/RandomMatrixGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@

package org.drip.measure.crng;

import org.drip.numerical.linearalgebra.TriangularMatrix;

/*
* -*- 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>RandomMatrixGenerator</i> provides Functionality for generating different Kinds of Random Matrices. The
* References are:
*
* <br><br>
* <ul>
* <li>
* Axler, S. J. (1997): <i>Linear Algebra Done Right 2<sup>nd</sup> Edition</i> <b>Springer</b>
* New York NY
* </li>
* <li>
* Bernstein, D. S. (2009): <i>Matrix Mathematics: Theory, Facts, and Formulas 2<sup>nd</sup>
* Edition</i> <b>Princeton University Press</b> Princeton NJ
* </li>
* <li>
* Herstein, I. N. (1975): <i>Topics in Algebra 2<sup>nd</sup> Edition</i> <b>Wiley</b> New York NY
* </li>
* <li>
* Prasolov, V. V. (1994): <i>Topics in Algebra</i> <b>American Mathematical Society</b> Providence
* RI
* </li>
* <li>
* Wikipedia (2024): Triangular Matrix https://en.wikipedia.org/wiki/Triangular_matrix
* </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/numerical/README.md">Numerical Quadrature, Differentiation, Eigenization, Linear Algebra, and Utilities</a></li>
* <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/numerical/linearalgebra/README.md">Linear Algebra Matrix Transform Library</a></li>
* </ul>
* <br><br>
*
* @author Lakshmi Krishnamurthy
*/

public class RandomMatrixGenerator
{

/**
* Construct a Lower Triangular 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 Lower Triangular Matrix of Random Elements up to the Maximum Value
*/

public static final TriangularMatrix LowerTriangular (
final int elementCount,
final double maximumElement,
final boolean isEntryInteger)
{
double[][] r2Array = RdRandomSequence.TwoD (elementCount, maximumElement, isEntryInteger);

for (int i = 0; i < r2Array.length; ++i) {
for (int j = i + 1; j < r2Array.length; ++j) {
r2Array[i][j] = 0.;
}
}

return TriangularMatrix.Standard (r2Array);
}

/**
* Construct an Upper Triangular 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 Upper Triangular Matrix of Random Elements up to the Maximum Value
*/

public static final TriangularMatrix UpperTriangular (
final int elementCount,
final double maximumElement,
final boolean isEntryInteger)
{
double[][] r2Array = RdRandomSequence.TwoD (elementCount, maximumElement, isEntryInteger);

for (int i = 0; i < r2Array.length; ++i) {
for (int j = 0; j < i; ++j) {
r2Array[i][j] = 0.;
}
}

return TriangularMatrix.Standard (r2Array);
}
}
27 changes: 27 additions & 0 deletions src/main/java/org/drip/numerical/eigen/EigenOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.HashMap;
import java.util.Map;

import org.drip.function.definition.R1ToR1;

/*
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*/
Expand Down Expand Up @@ -197,4 +199,29 @@ public double determinant()

return determinant;
}

/**
* Retrieve the Characteristic Polynomial of the Eigenvalues
*
* @return Characteristic Polynomial of the Eigenvalues
*/

public R1ToR1 characteristicPolynomial()
{
return new R1ToR1 (null)
{
@Override public double evaluate (
final double x)
throws Exception
{
double value = 1.;

for (double eigenValue : _eigenValueArray) {
value *= (x - eigenValue);
}

return value;
}
};
}
}
44 changes: 43 additions & 1 deletion src/main/java/org/drip/numerical/linearalgebra/SquareMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import java.util.Map;

import org.drip.function.definition.R1ToR1;
import org.drip.numerical.common.NumberUtil;
import org.drip.numerical.eigen.EigenOutput;
import org.drip.numerical.eigen.QREigenComponentExtractor;
Expand Down Expand Up @@ -129,7 +130,7 @@ public class SquareMatrix
* @return Standard Instance of <i>SquareMatrix</i>
*/

public static final SquareMatrix Standard (
public static SquareMatrix Standard (
final double[][] r2Array)
{
if (!MatrixUtil.IsSquare (r2Array)) {
Expand Down Expand Up @@ -253,6 +254,17 @@ public boolean isNormal()
return true;
}

/**
* Calculate whether the Matrix is "Triangularizable"
*
* @return TRUE - Matrix is "Triangularizable"
*/

public boolean isTriangularizable()
{
return true;
}

/**
* Eigenize and Extract the Components of the Specified Matrix
*
Expand All @@ -264,6 +276,23 @@ public EigenOutput eigenize()
return QREigenComponentExtractor.Standard().eigenize (_r2Array);
}

/**
* Retrieve the Array of Diagonal Entries
*
* @return Array of Diagonal Entries
*/

public double[] diagonalEntryArray()
{
double[] diagonalEntryArray = new double[_r2Array.length];

for (int i = 0; i < _r2Array.length; ++i) {
diagonalEntryArray[i] = _r2Array[i][i];
}

return diagonalEntryArray;
}

/**
* Retrieve the Eigenvalue Multiplicity Map
*
Expand Down Expand Up @@ -296,4 +325,17 @@ public double determinant()

return eigenOutput.determinant();
}

/**
* Retrieve the Characteristic Polynomial of the Eigenvalues
*
* @return Characteristic Polynomial of the Eigenvalues
*/

public R1ToR1 characteristicPolynomial()
{
EigenOutput eigenOutput = QREigenComponentExtractor.Standard().eigenize (_r2Array);

return null == eigenOutput ? null : eigenOutput.characteristicPolynomial();
}
}
Loading

0 comments on commit e866021

Please sign in to comment.