You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemds.apache.org by ja...@apache.org on 2020/08/20 08:04:03 UTC

[systemds] branch master updated: [WIP][DOC] DML to R translation guide (#1007)

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

janardhan 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 2f5d3fb  [WIP][DOC] DML to R translation guide (#1007)
2f5d3fb is described below

commit 2f5d3fb3ac024bf8581cfc0369eddf56e8235a27
Author: j143 <j1...@protonmail.com>
AuthorDate: Thu Aug 20 13:33:54 2020 +0530

    [WIP][DOC] DML to R translation guide (#1007)
    
    * some common differences between R and DML
    * The examples should be runnable to make the
      guide more interesting.
---
 dev/docs/dml-vs-r-guide.md | 100 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)

diff --git a/dev/docs/dml-vs-r-guide.md b/dev/docs/dml-vs-r-guide.md
new file mode 100644
index 0000000..760d57e
--- /dev/null
+++ b/dev/docs/dml-vs-r-guide.md
@@ -0,0 +1,100 @@
+<!--
+{% comment %}
+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.
+{% endcomment %}
+-->
+
+#### `dml` to `R` translation recipes
+
+To ease the prototyping of the `dml` scripts from its `R` counterparts, this
+guide covers various practical functions or operations.
+
+NOTE: This document is still a work in progress.
+
+## Table of Contents
+
+  * [Multiple outputs](#multiple-outputs)
+  * [Order function](#order-function)
+  * [Read function](#read-function)
+  * [`Write` function](#write-function)
+
+##### Multiple-outputs
+
+```dml
+# dml
+
+A = rand(rows=10, cols=10)
+C = t(A) %*% A
+[evalues, evectors] = eigen(C);
+```
+
+```R
+# R
+
+A = rand(rows=10, cols=10)
+C = t(A) %*% A
+R <- eigen(C);
+evalues = R$values;
+evectors = R$vectors;
+```
+
+##### `order`-function
+
+```dml
+# dml
+
+decreasing_Idx = order(target=evalues,by=1,decreasing=TRUE,index.return=TRUE);
+diagmat = table(seq(1,D),decreasing_Idx);
+```
+
+```R
+# R
+
+decreasing_Idx = order(as.vector(evalues), decreasing=TRUE);
+diagmat = table(seq(1,D), decreasing_Idx);
+```
+
+##### `Read`-function
+
+```dml
+# dml
+
+A = read("")
+# A = read($INPUT)
+```
+
+```R
+# R
+
+# args[1] will the relative directory path
+A = readMM(paste(args[1], "A.mtx", sep=""))
+```
+
+##### `Write`-function
+
+```dml
+# dml
+ofmt = "TEXT"
+
+write(evalues, "evalues", format=ofmt)
+```
+
+```R
+# R
+
+# Here args[2] will be a string denoting output directory
+writeMM(as(evalues, "CsparseMatrix"), paste(args[2],"evalues", sep=""));
+```