Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rrowwise var #2244

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix out of bounds exception
  • Loading branch information
Frxms committed Feb 26, 2025
commit 38735536febf380a051091f43dd331be1355e973
Original file line number Diff line number Diff line change
@@ -2153,15 +2153,15 @@ public static double[] vectConv2dmmWrite(double[] a, double[] b, int ai, int bi,
}

public static double vectVar(double[] a, int ai, int len) {
double meanVal = vectMean(a, ai, len);
double meanVal = Math.pow(vectMean(a, ai, len), 2);
double[] aSqr = vectPow2Write(a, ai, len);
return ((double) 1 /len)*(vectSum(aSqr, ai, len)-meanVal);
return ((double) 1 /len)*(vectSum(aSqr, 0, len)-meanVal);
}

public static double vectVar(double[] avals, int[] aix, int ai, int alen, int len) {
double meanVal = vectMean(avals, aix, ai, alen, len);
double meanVal = Math.pow(vectMean(avals, aix, ai, alen, len), 2);
double[] avalsSqr = vectPow2Write(avals, aix, ai, alen, len);
return ((double) 1 /len)*(vectSum(avalsSqr, ai, len)-meanVal);
return ((double) 1 /len)*(vectSum(avalsSqr, 0, alen)-meanVal);
}

//complex builtin functions that are not directly generated
3 changes: 2 additions & 1 deletion src/test/scripts/functions/codegen/rowAggPattern47.R
Original file line number Diff line number Diff line change
@@ -28,7 +28,8 @@ rowVars <- function(X) {
apply(X, 1, var)
}

X = matrix(seq(1,6000)/6000, 600, 10, byrow=TRUE);
# X = matrix(seq(1,6000)/6000, 600, 10, byrow=TRUE);
X = matrix(2, 10, 10);

R = as.matrix(sum(rowVars(X)));

3 changes: 2 additions & 1 deletion src/test/scripts/functions/codegen/rowAggPattern47.dml
Original file line number Diff line number Diff line change
@@ -19,8 +19,9 @@
#
#-------------------------------------------------------------

#X = matrix(seq(1,6000)/6000, 600, 10);
X = matrix(2, 10, 10)

X = matrix(seq(1,6000)/6000, 600, 10);
while(FALSE){}

R = as.matrix(sum(rowVars(X)));