This is an automated email from the ASF dual-hosted git repository.

mboehm7 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c12ead  [MINOR] Simplification of dist builtin function (avoid 
unnecessary ops)
3c12ead is described below

commit 3c12eade6f14ff711c1b5549652be3ab26267540
Author: Matthias Boehm <[email protected]>
AuthorDate: Mon Aug 9 23:28:09 2021 +0200

    [MINOR] Simplification of dist builtin function (avoid unnecessary ops)
---
 scripts/builtin/dist.dml | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/scripts/builtin/dist.dml b/scripts/builtin/dist.dml
index 1245087..54db438 100644
--- a/scripts/builtin/dist.dml
+++ b/scripts/builtin/dist.dml
@@ -21,9 +21,7 @@
 # Returns Euclidian distance matrix (distances between N n-dimensional points)
 
 m_dist = function(Matrix[Double] X) return (Matrix[Double] Y) {
-    G = X %*% t(X);
-    I = matrix(1, rows = nrow(G), cols = ncol(G));
-    Y = -2 * (G) + (diag(G) * I) + (I * t(diag(G)));
-    Y = sqrt(Y);
-    Y = replace(target = Y, pattern=0/0, replacement = 0);
+  G = X %*% t(X);
+  Y = sqrt(-2 * G + outer(diag(G), t(diag(G)), "+"));
+  Y = replace(target = Y, pattern=0/0, replacement = 0);
 }

Reply via email to