Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- Single Vector Norm Evaluator Annotation (1)
	- Single Vector Norm 1 Evaluator (2, 3, 4)
	- Single Vector Norm 2 Evaluator (5, 6)
	- Single Vector Norm Infinity Evaluator (7, 8, 9)
	- Double Vector Norm Evaluator #1 (10, 11, 12)
	- Double Vector Norm Evaluator #2 (13, 14, 15)
	- Single Vector Norm Evaluator Constructor (16, 17, 18)
	- Double Vector Two Infinity Evaluator Shell (19, 20, 21)
	- Double Vector Two Infinity Evaluator Constructor (22, 23, 24)
	- Double Vector Two Infinity Evaluator Norm (25, 26, 27)
	- Double Vector One Two Evaluator Shell (28, 29)
	- Double Vector One Two Evaluator Constructor (30, 31)
	- Double Vector One Two Evaluator Norm (32, 33)
	- Matrix-Matrix Sub-multiplicative Consistency Validation (37, 38, 39)
	- Matrix-Matrix Sub-additive Consistency Validation (40, 41, 42)
	- Matrix Vector Sub-multiplicative Consistency #1 (43, 44, 45)
	- Matrix Vector Sub-multiplicative Consistency #2 (46, 47, 48)
	- Matrix Vector Sub-multiplicative Consistency #3 (49, 50, 51)
	- Util Unsafe Matrix Vector Product #1 (52, 53, 54)
	- Util Safe Matrix Vector Product #1 (55, 56, 57)
	- Util Unsafe Matrix Vector Product #2 (58, 59, 60)
	- Util Safe Matrix Vector Product #2 (61, 62, 63)
	- Util Safe Matrix Vector Product #3 (64, 65, 66)
	- Square Evaluator Consistency Validator #1 (67, 68, 69)
	- Square Evaluator Consistency Validator #2 (70, 71, 72)
	- Single Compatible Vector Evaluator p-Norm (73, 74, 75)
	- Entry-wise Norm Evaluator Shell #1 (76, 77, 78)
	- Entry-wise Evaluator p Norm (79, 80, 81)
	- Entry-wise Evaluator q Norm (82, 83, 84)
	- Entry-wise Evaluator pq Norm #1 (85, 86, 87)
	- Entry-wise Evaluator pq Norm #2 (88, 89)
	- Entry-wise Evaluator pq Norm Constructor (90, 91, 92)
	- Entry-wise Evaluator pq Norm 2_1 (93, 94, 95)
	- Entry-wise Evaluator pq Norm p_p (96, 97, 98)
	- Matrix Util Unsafe Trace #1 (99, 100)
	- Matrix Util Unsafe Trace #2 (101, 102)
	- R1 Matrix Util Trace Evaluator (103, 104, 105)
	- R1 Square Matrix Trace Evaluator (106, 107, 108)
	- Entry-wise Frobenius Evaluator Shell (109, 110, 111)
	- Entry-wise Frobenius Evaluator Constructor (112, 113, 114)
	- Entry-wise Frobenius Evaluator Norm (115, 116, 117)
	- Entry-wise Frobenius Evaluator Trace Norm (118, 119, 120)


Bug Fixes/Re-organization:

	- R1 Square Consistency Validator Criteria (34, 35, 36)


Samples:

IdeaDRIP:
  • Loading branch information
Lakshmik committed Sep 1, 2024
1 parent eeb18c5 commit e9dd99d
Show file tree
Hide file tree
Showing 14 changed files with 1,170 additions and 140 deletions.
55 changes: 55 additions & 0 deletions ReleaseNotes/04_09_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

Features:

- Single Vector Norm Evaluator Annotation (1)
- Single Vector Norm 1 Evaluator (2, 3, 4)
- Single Vector Norm 2 Evaluator (5, 6)
- Single Vector Norm Infinity Evaluator (7, 8, 9)
- Double Vector Norm Evaluator #1 (10, 11, 12)
- Double Vector Norm Evaluator #2 (13, 14, 15)
- Single Vector Norm Evaluator Constructor (16, 17, 18)
- Double Vector Two Infinity Evaluator Shell (19, 20, 21)
- Double Vector Two Infinity Evaluator Constructor (22, 23, 24)
- Double Vector Two Infinity Evaluator Norm (25, 26, 27)
- Double Vector One Two Evaluator Shell (28, 29)
- Double Vector One Two Evaluator Constructor (30, 31)
- Double Vector One Two Evaluator Norm (32, 33)
- Matrix-Matrix Sub-multiplicative Consistency Validation (37, 38, 39)
- Matrix-Matrix Sub-additive Consistency Validation (40, 41, 42)
- Matrix Vector Sub-multiplicative Consistency #1 (43, 44, 45)
- Matrix Vector Sub-multiplicative Consistency #2 (46, 47, 48)
- Matrix Vector Sub-multiplicative Consistency #3 (49, 50, 51)
- Util Unsafe Matrix Vector Product #1 (52, 53, 54)
- Util Safe Matrix Vector Product #1 (55, 56, 57)
- Util Unsafe Matrix Vector Product #2 (58, 59, 60)
- Util Safe Matrix Vector Product #2 (61, 62, 63)
- Util Safe Matrix Vector Product #3 (64, 65, 66)
- Square Evaluator Consistency Validator #1 (67, 68, 69)
- Square Evaluator Consistency Validator #2 (70, 71, 72)
- Single Compatible Vector Evaluator p-Norm (73, 74, 75)
- Entry-wise Norm Evaluator Shell #1 (76, 77, 78)
- Entry-wise Evaluator p Norm (79, 80, 81)
- Entry-wise Evaluator q Norm (82, 83, 84)
- Entry-wise Evaluator pq Norm #1 (85, 86, 87)
- Entry-wise Evaluator pq Norm #2 (88, 89)
- Entry-wise Evaluator pq Norm Constructor (90, 91, 92)
- Entry-wise Evaluator pq Norm 2_1 (93, 94, 95)
- Entry-wise Evaluator pq Norm p_p (96, 97, 98)
- Matrix Util Unsafe Trace #1 (99, 100)
- Matrix Util Unsafe Trace #2 (101, 102)
- R1 Matrix Util Trace Evaluator (103, 104, 105)
- R1 Square Matrix Trace Evaluator (106, 107, 108)
- Entry-wise Frobenius Evaluator Shell (109, 110, 111)
- Entry-wise Frobenius Evaluator Constructor (112, 113, 114)
- Entry-wise Frobenius Evaluator Norm (115, 116, 117)
- Entry-wise Frobenius Evaluator Trace Norm (118, 119, 120)


Bug Fixes/Re-organization:

- R1 Square Consistency Validator Criteria (34, 35, 36)


Samples:

IdeaDRIP:
184 changes: 128 additions & 56 deletions src/main/java/org/drip/numerical/linearalgebra/R1MatrixUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,70 @@ public static final double[][] UnsafeProduct (
return product;
}

/**
* Compute the Product of an Input Matrix and a Vector. Unsafe Methods do not validate the Input
* Arguments, so <b>use caution</b> in applying these Methods
*
* @param a Matrix A
* @param b Vector B
*
* @return The Product
*/

public static final double[] UnsafeProduct (
final double[][] a,
final double[] b)
{
double[] product = new double[a.length];

for (int rowIndex = 0; rowIndex < a.length; ++rowIndex) {
product[rowIndex] = 0.;

for (int columnIndex = 0; columnIndex < a[0].length; ++columnIndex) {
if (!NumberUtil.IsValid (a[rowIndex][columnIndex]) || !NumberUtil.IsValid (b[columnIndex])) {
return null;
}

product[rowIndex] += a[rowIndex][columnIndex] * b[columnIndex];
}
}

return product;
}

/**
* Compute the Product of an Input Vector and a Matrix. Unsafe Methods do not validate the Input
* Arguments, so <b>use caution</b> in applying these Methods
*
* @param a Column A
* @param b Matrix B
*
* @return The Product
*/

public static final double[][] UnsafeProduct (
final double[] a,
final double[][] b)
{
double[][] product = new double[a.length][b.length];

for (int rowIndex = 0; rowIndex < a.length; ++rowIndex) {
for (int columnIndex = 0; columnIndex < b.length; ++columnIndex) {
product[rowIndex][columnIndex] = 0.;

for (int i = 0; i < a.length; ++i) {
if (!NumberUtil.IsValid (a[rowIndex]) || !NumberUtil.IsValid (b[i][columnIndex])) {
return null;
}

product[rowIndex][columnIndex] += a[rowIndex] * b[i][columnIndex];
}
}
}

return product;
}

/**
* Compute the Addition of the Input Matrices. Unsafe Methods do not validate the Input Arguments, so
* <b>use caution</b> in applying these Methods
Expand Down Expand Up @@ -270,6 +334,7 @@ public static final double[][] UnsafeSubtract (
* caution</b> in applying these Methods
*
* @param a Vector A
* @param k Power Exponent
*
* @return The Power Matrix
*/
Expand All @@ -289,6 +354,34 @@ public static final double[][] UnsafePower (
return aPower;
}

/**
* Compute the Trace of the Input Matrix. Unsafe Methods do not validate the Input Arguments, so <b>use
* caution</b> in applying these Methods
*
* @param a Vector A
*
* @return The Trace
*
* @throws Exception Thrown if Trace cannot be Calculated
*/

public static final double UnsafeTrace (
final double[][] a)
throws Exception
{
double trace = 0.;

for (int i = 0; i < a.length; ++i) {
if (!NumberUtil.IsValid (a[i][i])) {
throw new Exception ("R1MatrixUtil::UnsafeTrace => Invalid Matrix Entry");
}

trace += a[i][i];
}

return trace;
}

/**
* Orthogonalize the Specified Matrix Using the RQ Graham-Schmidt Method. Unsafe Methods do not validate
* the Input Arguments, so <b>use caution</b> in applying these Methods
Expand Down Expand Up @@ -427,79 +520,37 @@ public static final boolean DiagonalizeRow (
}

/**
* Compute the Product of an Input Matrix and a Column
* Compute the Product of an Input Matrix and a Vector
*
* @param aadblA Matrix A
* @param adblB Array B
* @param a Matrix A
* @param b Array B
*
* @return The Product
*/

public static final double[] Product (
final double[][] aadblA,
final double[] adblB)
final double[][] a,
final double[] b)
{
if (null == aadblA || null == adblB) return null;

int iNumACol = aadblA[0].length;
int iNumProductCol = adblB.length;
int iNumProductRow = aadblA.length;
double[] adblProduct = new double[iNumProductRow];

if (0 == iNumACol || iNumACol != adblB.length || 0 == iNumProductRow || 0 == iNumProductCol)
return null;

for (int iRow = 0; iRow < iNumProductRow; ++iRow) {
adblProduct[iRow] = 0.;

for (int i = 0; i < iNumACol; ++i) {
if (!org.drip.numerical.common.NumberUtil.IsValid (aadblA[iRow][i]) ||
!org.drip.numerical.common.NumberUtil.IsValid (adblB[i]))
return null;

adblProduct[iRow] += aadblA[iRow][i] * adblB[i];
}
}

return adblProduct;
return null == a || null == b || 0 == a.length || 0 == a[0].length || a[0].length != b.length ?
null : UnsafeProduct (a, b);
}

/**
* Compute the Product of an input column and a matrix
* Compute the Product of an Input Vector and a Matrix
*
* @param adblA Column A
* @param aadblB Matrix B
* @param a Vector A
* @param b Matrix B
*
* @return The Product
*/

public static final double[][] Product (
final double[] adblA,
final double[][] aadblB)
final double[] a,
final double[][] b)
{
if (null == adblA || null == aadblB) return null;

int iNumACol = adblA.length;
int iNumProductCol = aadblB.length;
double[][] aadblProduct = new double[iNumACol][iNumProductCol];

if (0 == iNumACol || iNumACol != aadblB.length || 0 == iNumProductCol) return null;

for (int iRow = 0; iRow < iNumACol; ++iRow) {
for (int iCol = 0; iCol < iNumProductCol; ++iCol) {
aadblProduct[iRow][iCol] = 0.;

for (int i = 0; i < iNumACol; ++i) {
if (!org.drip.numerical.common.NumberUtil.IsValid (adblA[iRow]) ||
!org.drip.numerical.common.NumberUtil.IsValid (aadblB[i][iCol]))
return null;

aadblProduct[iRow][iCol] += adblA[iRow] * aadblB[i][iCol];
}
}
}

return aadblProduct;
return null == a || null == b || 0 == a.length || a.length != b.length || 0 == b[0].length ?
null : UnsafeProduct (a, b);
}

/**
Expand Down Expand Up @@ -572,6 +623,27 @@ public static final double[][] Power (
return null == a || 0 == a.length || 0 == a[0].length || 0 >= k ? null : UnsafePower (a, k);
}

/**
* Compute the Trace of the Input Matrix
*
* @param a Vector A
*
* @return The Trace
*
* @throws Exception Thrown if Trace cannot be Calculated
*/

public static final double Trace (
final double[][] a)
throws Exception
{
if (null == a || 0 == a.length || 0 == a[0].length) {
throw new Exception ("R1MatrixUtil::Trace => Invalid Input Matrix");
}

return UnsafeTrace (a);
}

/**
* Compute the Sum of the input matrices
*
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/org/drip/numerical/matrix/R1Square.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,23 @@ public int size()
return _r1Grid.length;
}

/**
* Compute the Trace
*
* @return The Trace
*/

public double trace()
{
double trace = 0.;

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

return trace;
}

/**
* Transpose the Square Matrix
*
Expand Down Expand Up @@ -304,6 +321,40 @@ public R1Square multiply (
return new R1Square (r1GridProduct);
}

/**
* Compute the Product with the Vector
*
* @param r1Array Vector Array
*
* @return Resulting Matrix
*/

public R1Square multiply (
final double[] r1Array)
{
if (null == r1Array || 0 == r1Array.length || r1Array.length != _r1Grid.length) {
return null;
}

double[][] r1GridProduct = new double[_r1Grid.length][_r1Grid.length];

for (int rowIndex = 0; rowIndex < r1Array.length; ++rowIndex) {
for (int columnIndex = 0; columnIndex < _r1Grid.length; ++columnIndex) {
r1GridProduct[rowIndex][columnIndex] = 0.;

for (int i = 0; i < r1Array.length; ++i) {
if (!NumberUtil.IsValid (r1Array[rowIndex])) {
return null;
}

r1GridProduct[rowIndex][columnIndex] += r1Array[rowIndex] * _r1Grid[i][columnIndex];
}
}
}

return new R1Square (r1GridProduct);
}

/**
* Calculate whether the Matrix is "Normal"
*
Expand Down
Loading

0 comments on commit e9dd99d

Please sign in to comment.