From 83dfde345f855cfee7f43229448903eb27d2eb2a Mon Sep 17 00:00:00 2001 From: j143 Date: Fri, 7 May 2021 03:03:27 +0530 Subject: [PATCH 1/2] DML style guide initial guide --- docs/site/dml-vs-r-guide.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/site/dml-vs-r-guide.md b/docs/site/dml-vs-r-guide.md index 77807043633..b1e62b8fa05 100644 --- a/docs/site/dml-vs-r-guide.md +++ b/docs/site/dml-vs-r-guide.md @@ -26,6 +26,29 @@ guide covers various practical functions or operations. NOTE: This document is still a work in progress. +## DML styleguide + +Indentation: `2 spaces` +Semi-colons: `Optional` +Spaces between words and parenthesis: `if( check & (it%%2 == 0) )` +Example variable naming: + ``` + # matrices named in Capitals + X = read(fileX) + + # double values named in small letters + m = nrow(X) + + # constructed matrices (general use) + row_nonzeros = matrix(0,rows=1,cols=1) + + # Assign aggregated values for clear & readable naming + norm_G2 = sum (G ^ 2) + + # Boolean flags + converged = FALSE +``` + ## Table of Contents * [Multiple outputs](#multiple-outputs) From c0607bce9c5c61fcb39b0e86153ee25f6c0d1180 Mon Sep 17 00:00:00 2001 From: j143 Date: Fri, 7 May 2021 03:06:51 +0530 Subject: [PATCH 2/2] Add custom udf --- docs/site/dml-vs-r-guide.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/site/dml-vs-r-guide.md b/docs/site/dml-vs-r-guide.md index b1e62b8fa05..73fbe1533e4 100644 --- a/docs/site/dml-vs-r-guide.md +++ b/docs/site/dml-vs-r-guide.md @@ -49,6 +49,18 @@ Example variable naming: converged = FALSE ``` +Custom user defined functions + +```dml +m_csplineDS = function (Matrix[Double] X, Matrix[Double] Y, Double inp_x) + return (Matrix[Double] pred_Y) +{ + print("This is a builtin function") + pred_Y = matrix(y, 1, 1) +} +``` + + ## Table of Contents * [Multiple outputs](#multiple-outputs)