Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/test/java/org/surus/math/RPCA_Test.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.surus.math;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;

import org.junit.Test;

Expand All @@ -20,6 +21,11 @@ public boolean MatrixApproximatelyEquals(double[][] X, double[][] Y, double epsi
boolean testOutput = true;
int printCnt = 0;

if (!(X[0].length == Y[0].length && X.length == Y.length)) {
System.out.println("X and Y matrices had differing dimensions.");
return false;
}

for (int j = 0; j < X[0].length; j++) {
for (int i = 0; i < X.length; i++) {
if (Math.abs(X[i][j] - Y[i][j]) > epsilon) {
Expand All @@ -31,6 +37,17 @@ public boolean MatrixApproximatelyEquals(double[][] X, double[][] Y, double epsi
}
return testOutput;
}

@Test
public void testMatrixApproximatelyEquals() {
final double[] ts1 = new double[] { 1.0, 0.0, 0.0, 1.0 };
final double[] ts2 = new double[] { 1.0, 0.0, 0.0, 1.0 , 0.0, 0.0};

final double[][] X1 = VectorToMatrix(ts1, 2, 2);
final double[][] X2 = VectorToMatrix(ts1, 2, 3);

assertFalse(MatrixApproximatelyEquals(X1, X2, 0.0));
}

@Test
public void testRSVD() {
Expand Down