Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- Matrix Util Unsafe Dot Product (68, 69)
	- Unsafe Project V On U (70, 71, 72)
	- Matrix Util Unsafe Modulus Calculation (73, 74)
	- Matrix Util Unsafe Product Calculation (75, 76)


Bug Fixes/Re-organization:

Samples:

IdeaDRIP:

	- QR Decomposition Using Givens Rotations - Example (1-15)
	- QR Decomposition Using Givens Rotations - Advantages and Disadvantages (16-18)
	- QR Decomposition Connection to a Determinant or Product of Eigenvalues (19-39)
	- QR Decomposition Column Pivoting (40-47)
	- QR Decomposition Using for Solution to Linear Inverse Problems (48-66)
	- QR Decomposition Generalization (67)
	- QR Decomposition Introduction (77-80)
	- QR Decomposition Cases and Definition - Square Matrix (81-90)
	- QR Decomposition Cases and Definition - Rectangular Matrix (91-98)
	- QR Decomposition Cases and Definition - QL, RQ, LQ (99-100)
	- Computing the QR Decomposition (101-102)
	- Computing the QR Decomposition using Gram–Schmidt Process (103-110)
	- Computing the QR Decomposition using Gram–Schmidt Process - Relation to RQ (111-114)
	- Computing the QR Decomposition using Gram–Schmidt Process - Advantages and Disadvantages (115-120)
  • Loading branch information
Lakshmik committed Jul 16, 2024
1 parent 90ab316 commit bc9cee2
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 11 deletions.
29 changes: 29 additions & 0 deletions ReleaseNotes/02_20_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

Features:

- Matrix Util Unsafe Dot Product (68, 69)
- Unsafe Project V On U (70, 71, 72)
- Matrix Util Unsafe Modulus Calculation (73, 74)
- Matrix Util Unsafe Product Calculation (75, 76)


Bug Fixes/Re-organization:

Samples:

IdeaDRIP:

- QR Decomposition Using Givens Rotations - Example (1-15)
- QR Decomposition Using Givens Rotations - Advantages and Disadvantages (16-18)
- QR Decomposition Connection to a Determinant or Product of Eigenvalues (19-39)
- QR Decomposition Column Pivoting (40-47)
- QR Decomposition Using for Solution to Linear Inverse Problems (48-66)
- QR Decomposition Generalization (67)
- QR Decomposition Introduction (77-80)
- QR Decomposition Cases and Definition - Square Matrix (81-90)
- QR Decomposition Cases and Definition - Rectangular Matrix (91-98)
- QR Decomposition Cases and Definition - QL, RQ, LQ (99-100)
- Computing the QR Decomposition (101-102)
- Computing the QR Decomposition using Gram–Schmidt Process (103-110)
- Computing the QR Decomposition using Gram–Schmidt Process - Relation to RQ (111-114)
- Computing the QR Decomposition using Gram–Schmidt Process - Advantages and Disadvantages (115-120)
62 changes: 51 additions & 11 deletions src/main/java/org/drip/numerical/linearalgebra/MatrixUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,20 @@
* @author Lakshmi Krishnamurthy
*/

public class MatrixUtil {
public class MatrixUtil
{

private static final double DotProductInternal (
/**
* Dot Product of Vectors A and E. Unsafe Methods do not validate the Input Arguments, so
* <b>use caution</b> in applying these Methods
*
* @param a Vector A
* @param e Vector E
*
* @return The Dot Product
*/

public static final double UnsafeDotProduct (
final double[] a,
final double[] e)
{
Expand All @@ -128,11 +139,21 @@ private static final double DotProductInternal (
return dotProductInternal;
}

private static final double[] ProjectVOnUInternal (
/**
* Compute the Projection Vector on V induced by U. Unsafe Methods do not validate the Input Arguments,
* so <b>use caution</b> in applying these Methods
*
* @param u Vector U
* @param v Vector V
*
* @return The Projection Vector
*/

public static final double[] UnsafeProjectVOnU (
final double[] u,
final double[] v)
{
double vDotUOverUDotU = DotProductInternal (u, v) / DotProductInternal (u, u);
double vDotUOverUDotU = UnsafeDotProduct (u, v) / UnsafeDotProduct (u, u);

double[] projectVOnU = new double[u.length];

Expand All @@ -143,7 +164,16 @@ private static final double[] ProjectVOnUInternal (
return projectVOnU;
}

private static final double ModulusInternal (
/**
* Compute the Modulus of the Vector. Unsafe Methods do not validate the Input Arguments, so
* <b>use caution</b> in applying these Methods
*
* @param v Vector V
*
* @return Modulus of the Vector
*/

public static final double UnsafeModulus (
final double[] v)
{
double modulus = 0.;
Expand All @@ -155,7 +185,17 @@ private static final double ModulusInternal (
return Math.sqrt (modulus);
}

private static final double[][] ProductInternal (
/**
* Compute the Product of the Input Matrices. Unsafe Methods do not validate the Input Arguments, so
* <b>use caution</b> in applying these Methods
*
* @param a Vector A
* @param b Vector B
*
* @return The Product Matrix
*/

private static final double[][] UnsafeProduct (
final double[][] a,
final double[][] b)
{
Expand Down Expand Up @@ -332,7 +372,7 @@ public static final double[][] Product (
{
return null == a || 0 == a.length || 0 == a[0].length ||
null == b || a[0].length != b.length || 0 == b[0].length ?
null : ProductInternal (a, b);
null : UnsafeProduct (a, b);
}

/**
Expand Down Expand Up @@ -805,7 +845,7 @@ public static final double DotProduct (
throw new Exception ("MatrixUtil::DotProduct => Invalid Inputs!");
}

return DotProductInternal (adblA, adblE);
return UnsafeDotProduct (adblA, adblE);
}

/**
Expand Down Expand Up @@ -927,7 +967,7 @@ public static final double Modulus (
throw new Exception ("MatrixUtil::Modulus => Invalid Inputs");
}

return ModulusInternal (v);
return UnsafeModulus (v);
}

/**
Expand Down Expand Up @@ -1062,7 +1102,7 @@ public static final double[][] GrahamSchmidtOrthogonalization (

for (int i = 1; i < aUsingVectorsInRows.length; ++i) {
for (int j = 0; j < i; ++j) {
double[] projectionTrimOff = ProjectVOnUInternal (u[j], aUsingVectorsInRows[i]);
double[] projectionTrimOff = UnsafeProjectVOnU (u[j], aUsingVectorsInRows[i]);

for (int k = 0; k < projectionTrimOff.length; ++k) {
u[i][k] -= projectionTrimOff[k];
Expand Down Expand Up @@ -1095,7 +1135,7 @@ public static final double[][] GrahamSchmidtOrthonormalization (
double[][] u = vectorsInColumns ? Transpose (uOrthogonal) : uOrthogonal;

for (int i = 0; i < u.length; ++i) {
double modulusReciprocal = 1. / ModulusInternal (u[i]);
double modulusReciprocal = 1. / UnsafeModulus (u[i]);

for (int j = 0; j < u.length; ++j) {
u[i][j] *= modulusReciprocal;
Expand Down

0 comments on commit bc9cee2

Please sign in to comment.