Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- Random Matrix Generator Lower Unitriangular (82, 83, 84)
	- Random Matrix Generator Strictly Lower Triangular (106, 107, 108)
	- Random Matrix Generator Strictly Upper Triangular (109, 110, 111)


Bug Fixes/Re-organization:

	- Upper/Lower Triangular Check #1 (64, 65, 66)
	- Upper/Lower Triangular Check #2 (67, 68, 69)
	- Upper/Lower Triangular Check #3 (70, 71, 72)


Samples:

	- Lower Triangular Matrix Run #1 (1, 2, 3)
	- Lower Triangular Matrix Run #2 (4, 5, 6)
	- Lower Triangular Matrix Run #3 (7, 8, 9)
	- Lower Triangular Matrix Run #4 (10, 11, 12)
	- Lower Triangular Matrix Run #5 (13, 14, 15)
	- Lower Triangular Matrix Run #6 (16, 17, 18)
	- Lower Triangular Matrix Run #7 (19, 20, 21)
	- Lower Triangular Matrix Run #8 (22, 23, 24)
	- Lower Triangular Matrix Run #9 (25, 26, 27)
	- Lower Triangular Matrix Run #10 (28, 29, 30)
	- Lower Triangular Matrix Run #11 (31, 32, 33)
	- Lower Triangular Matrix Run #12 (34, 35, 36)
	- Lower Triangular Matrix Run #13 (37, 38, 39)
	- Lower Triangular Matrix Run #14 (40, 41, 42)
	- Lower Triangular Matrix Run #15 (43, 44, 45)
	- Lower Triangular Matrix Run #16 (46, 47, 48)
	- Lower Triangular Matrix Run #17 (49, 50, 51)
	- Lower Triangular Matrix Run #18 (52, 53, 54)
	- Lower Triangular Matrix Run #19 (55, 56, 57)
	- Lower Triangular Matrix Run #20 (58, 59, 60)
	- Lower Triangular Matrix Run #21 (61, 62, 63)
	- Lower Triangular Matrix Run #22 (73, 74, 75)
	- Lower Triangular Matrix Run #23 (76, 77, 78)
	- Lower Triangular Matrix Run #24 (79, 80, 81)
	- Lower Unitriangular Matrix Run #1 (82, 83, 84)
	- Lower Unitriangular Matrix Run #2 (85, 86, 87)
	- Lower Unitriangular Matrix Run #3 (88, 89, 90)
	- Lower Unitriangular Matrix Run #4 (91, 92, 93)
	- Upper Unitriangular Matrix Run #5 (94, 95, 96)
	- Upper Unitriangular Matrix Run #6 (97, 98, 99)
	- Upper Unitriangular Matrix Run #7 (100, 101, 102)
	- Upper Unitriangular Matrix Run #8 (103, 104, 105)
	- Upper Strictly Lower Triangular #1 (112, 113, 114)
	- Upper Strictly Lower Triangular #2 (115, 116, 117)
	- Upper Strictly Lower Triangular #3 (118, 119, 120)


IdeaDRIP:
  • Loading branch information
Lakshmik committed Jul 7, 2024
1 parent e866021 commit ff01597
Show file tree
Hide file tree
Showing 9 changed files with 2,134 additions and 33 deletions.
55 changes: 55 additions & 0 deletions ReleaseNotes/02_07_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

Features:

- Random Matrix Generator Lower Unitriangular (82, 83, 84)
- Random Matrix Generator Strictly Lower Triangular (106, 107, 108)
- Random Matrix Generator Strictly Upper Triangular (109, 110, 111)


Bug Fixes/Re-organization:

- Upper/Lower Triangular Check #1 (64, 65, 66)
- Upper/Lower Triangular Check #2 (67, 68, 69)
- Upper/Lower Triangular Check #3 (70, 71, 72)


Samples:

- Lower Triangular Matrix Run #1 (1, 2, 3)
- Lower Triangular Matrix Run #2 (4, 5, 6)
- Lower Triangular Matrix Run #3 (7, 8, 9)
- Lower Triangular Matrix Run #4 (10, 11, 12)
- Lower Triangular Matrix Run #5 (13, 14, 15)
- Lower Triangular Matrix Run #6 (16, 17, 18)
- Lower Triangular Matrix Run #7 (19, 20, 21)
- Lower Triangular Matrix Run #8 (22, 23, 24)
- Lower Triangular Matrix Run #9 (25, 26, 27)
- Lower Triangular Matrix Run #10 (28, 29, 30)
- Lower Triangular Matrix Run #11 (31, 32, 33)
- Lower Triangular Matrix Run #12 (34, 35, 36)
- Lower Triangular Matrix Run #13 (37, 38, 39)
- Lower Triangular Matrix Run #14 (40, 41, 42)
- Lower Triangular Matrix Run #15 (43, 44, 45)
- Lower Triangular Matrix Run #16 (46, 47, 48)
- Lower Triangular Matrix Run #17 (49, 50, 51)
- Lower Triangular Matrix Run #18 (52, 53, 54)
- Lower Triangular Matrix Run #19 (55, 56, 57)
- Lower Triangular Matrix Run #20 (58, 59, 60)
- Lower Triangular Matrix Run #21 (61, 62, 63)
- Lower Triangular Matrix Run #22 (73, 74, 75)
- Lower Triangular Matrix Run #23 (76, 77, 78)
- Lower Triangular Matrix Run #24 (79, 80, 81)
- Lower Unitriangular Matrix Run #1 (82, 83, 84)
- Lower Unitriangular Matrix Run #2 (85, 86, 87)
- Lower Unitriangular Matrix Run #3 (88, 89, 90)
- Lower Unitriangular Matrix Run #4 (91, 92, 93)
- Upper Unitriangular Matrix Run #5 (94, 95, 96)
- Upper Unitriangular Matrix Run #6 (97, 98, 99)
- Upper Unitriangular Matrix Run #7 (100, 101, 102)
- Upper Unitriangular Matrix Run #8 (103, 104, 105)
- Upper Strictly Lower Triangular #1 (112, 113, 114)
- Upper Strictly Lower Triangular #2 (115, 116, 117)
- Upper Strictly Lower Triangular #3 (118, 119, 120)


IdeaDRIP:
148 changes: 148 additions & 0 deletions src/main/java/org/drip/measure/crng/RandomMatrixGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,152 @@ public static final TriangularMatrix UpperTriangular (

return TriangularMatrix.Standard (r2Array);
}

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

public static final TriangularMatrix Diagonal (
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 < r2Array.length; ++j) {
if (i != j) {
r2Array[i][j] = 0.;
}
}
}

return TriangularMatrix.Standard (r2Array);
}

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

public static final TriangularMatrix LowerUnitriangular (
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.;
}
}

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

return TriangularMatrix.Standard (r2Array);
}

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

public static final TriangularMatrix UpperUnitriangular (
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.;
}
}

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

return TriangularMatrix.Standard (r2Array);
}

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

public static final TriangularMatrix StrictlyLowerTriangular (
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.;
}
}

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

return TriangularMatrix.Standard (r2Array);
}

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

public static final TriangularMatrix StrictlyUpperTriangular (
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.;
}
}

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

return TriangularMatrix.Standard (r2Array);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,16 @@ public static final int Type (

for (int i = 0; i < r2Array.length; ++i) {
for (int j = 0; j < r2Array.length; ++j) {
if (i < j) {
if (NumberUtil.WithinTolerance (r2Array[i][j], 0.)) {
if (i > j) {
if (!NumberUtil.WithinTolerance (r2Array[i][j], 0.)) {
upperTriangular = false;

if (!lowerTriangular) {
break;
}
}
} else if (i > j) {
if (NumberUtil.WithinTolerance (r2Array[i][j], 0.)) {
} else if (i < j) {
if (!NumberUtil.WithinTolerance (r2Array[i][j], 0.)) {
lowerTriangular = false;

if (!upperTriangular) {
Expand Down Expand Up @@ -231,6 +231,8 @@ public static TriangularMatrix Standard (
{
int type = Type (r2Array);

if (NON_TRIANGULAR == type) System.out.println ("Type is " + type);

return NON_TRIANGULAR == type ? null : new TriangularMatrix (r2Array, type);
}

Expand Down Expand Up @@ -262,7 +264,7 @@ public int type()

public boolean isUpper()
{
return UPPER_TRIANGULAR == _type;
return UPPER_TRIANGULAR == _type || LOWER_AND_UPPER_TRIANGULAR == _type;
}

/**
Expand All @@ -273,7 +275,7 @@ public boolean isUpper()

public boolean isLower()
{
return LOWER_TRIANGULAR == _type;
return LOWER_TRIANGULAR == _type || LOWER_AND_UPPER_TRIANGULAR == _type;
}

/**
Expand All @@ -284,7 +286,7 @@ public boolean isLower()

public boolean isDiagonal()
{
return LOWER_TRIANGULAR == _type && UPPER_TRIANGULAR == _type;
return LOWER_AND_UPPER_TRIANGULAR == _type;
}

/**
Expand Down Expand Up @@ -367,7 +369,7 @@ public boolean isLowerUnitriangular()
* @return TRUE - Matrix is Strictly Upper Triangular
*/

public boolean strictlyUpper()
public boolean isStrictlyUpper()
{
return zeroDiagonalEntries() && UPPER_TRIANGULAR == _type;
}
Expand All @@ -378,7 +380,7 @@ public boolean strictlyUpper()
* @return TRUE - Matrix is Strictly Lower Triangular
*/

public boolean strictlyLower()
public boolean isStrictlyLower()
{
return zeroDiagonalEntries() && LOWER_TRIANGULAR == _type;
}
Expand All @@ -400,11 +402,13 @@ public boolean isAtomicLower()
double[][] r2Array = r2Array();

for (int columnIndex = 0; columnIndex < r2Array.length - 1; ++columnIndex) {
if (0 != r2Array[r2Array.length][columnIndex] && 1. != r2Array[r2Array.length][columnIndex]) {
if (0. != r2Array[r2Array.length - 1][columnIndex] &&
1. != r2Array[r2Array.length - 1][columnIndex])
{
return false;
}

if (1. == r2Array[r2Array.length][columnIndex]) {
if (1. == r2Array[r2Array.length - 1][columnIndex]) {
if (-1 != unitValueColumnIndex) {
return false;
}
Expand Down
Loading

0 comments on commit ff01597

Please sign in to comment.