Repository: systemml
Updated Branches:
  refs/heads/master cf31ed2ab -> 87d7fee73


[SYSTEMML-2004] Covariance Kernels

Closes #719.


Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/87d7fee7
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/87d7fee7
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/87d7fee7

Branch: refs/heads/master
Commit: 87d7fee7321a70729f4272fa68f108e722ec6221
Parents: cf31ed2
Author: Janardhan <[email protected]>
Authored: Mon Jan 29 12:11:00 2018 -0800
Committer: Niketan Pansare <[email protected]>
Committed: Mon Jan 29 12:12:08 2018 -0800

----------------------------------------------------------------------
 scripts/staging/gaussian_process/covariance.dml | 40 ++++++++++++++++++++
 .../gaussian_process/test/covariance.dml        | 37 ++++++++++++++++++
 2 files changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/87d7fee7/scripts/staging/gaussian_process/covariance.dml
----------------------------------------------------------------------
diff --git a/scripts/staging/gaussian_process/covariance.dml 
b/scripts/staging/gaussian_process/covariance.dml
new file mode 100644
index 0000000..33f672e
--- /dev/null
+++ b/scripts/staging/gaussian_process/covariance.dml
@@ -0,0 +1,40 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+
+cov = function(matrix[double] X)
+  return(matrix[double] out) {
+
+  K = -2 * X %*% t(X) + rowSums(X^2) + t( rowSums(X^2) )
+  out = exp(- 0.5 * K);
+
+}
+
+/*
+# for each dimension
+for( di in 1:d) {
+
+  Xd = X[1:n,di] %*% matrix(1, rows=1, cols=n);
+
+  diff = Xd - t(Xd)
+
+}
+*/

http://git-wip-us.apache.org/repos/asf/systemml/blob/87d7fee7/scripts/staging/gaussian_process/test/covariance.dml
----------------------------------------------------------------------
diff --git a/scripts/staging/gaussian_process/test/covariance.dml 
b/scripts/staging/gaussian_process/test/covariance.dml
new file mode 100644
index 0000000..a3c8475
--- /dev/null
+++ b/scripts/staging/gaussian_process/test/covariance.dml
@@ -0,0 +1,37 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+# imports
+source("staging/gaussian_process/covariance.dml") as covariance
+
+X = matrix("1 2 3
+            4 5 6
+            7 8 9", rows=3, cols=3);
+
+# ability to give cholesky factorization, tests for the positive
+# definiteness of the covariance matrix.
+tmp = covariance::cov(X);
+
+for(ri in 1:nrow(X)) {
+  for(ci in 1:ncol(X)) {
+    print(as.scalar(tmp[ri, ci]) )
+  }
+}

Reply via email to