Skip to content

Commit

Permalink
Sum methods in MathUtils.java.
Browse files Browse the repository at this point in the history
  • Loading branch information
dickensc committed Jun 10, 2024
1 parent 644d4d9 commit db0f3c7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions psl-core/src/main/java/org/linqs/psl/util/MathUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,26 @@ public static void toMagnitude(float[] vector, double magnitude) {
}
}

/**
* Compute the sum of the provided vector.
*/
public static float sum(float[] vector) {
float sum = 0.0f;
for (float v : vector) {
sum += v;
}
return sum;
}


public static double sum(double[] vector) {
double sum = 0.0;
for (double v : vector) {
sum += v;
}
return sum;
}

/**
* Compute the p-norm of the provided vector.
*/
Expand Down

0 comments on commit db0f3c7

Please sign in to comment.