You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by de...@apache.org on 2017/07/26 23:37:15 UTC

systemml git commit: [MINOR] Update boolean case examples in DML Language Reference

Repository: systemml
Updated Branches:
  refs/heads/master 2663ccd41 -> dbb0b48a9


[MINOR] Update boolean case examples in DML Language Reference

Update case of some boolean examples to TRUE and FALSE to match case
of DML keywords.
Add missing parentheses to examples.


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

Branch: refs/heads/master
Commit: dbb0b48a9e9aa8e7ae52e33146713fb8b09fc4a9
Parents: 2663ccd
Author: Deron Eriksson <de...@apache.org>
Authored: Wed Jul 26 16:33:58 2017 -0700
Committer: Deron Eriksson <de...@apache.org>
Committed: Wed Jul 26 16:33:58 2017 -0700

----------------------------------------------------------------------
 docs/dml-language-reference.md | 42 ++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/dbb0b48a/docs/dml-language-reference.md
----------------------------------------------------------------------
diff --git a/docs/dml-language-reference.md b/docs/dml-language-reference.md
index 26b02eb..d5e200d 100644
--- a/docs/dml-language-reference.md
+++ b/docs/dml-language-reference.md
@@ -257,21 +257,21 @@ An assignment statement consists of an expression, the result of which is assign
 
 The syntax for a while statement is as follows:
 
-    while (predicate){
+    while (predicate) {
         statement1
         statement2
         ...
     }
 
-The statements in the while statement body are evaluated repeatedly until the predicate evaluates to true. The while statement body must be surrounded by braces, even if the body only has a single statement.
+The statements in the while statement body are evaluated repeatedly until the predicate evaluates to TRUE. The while statement body must be surrounded by braces, even if the body only has a single statement.
 The predicate in the while statement consist of operations on scalar variables and literals. The body of a while statement may contain any sequence of statements.
 
 
 ##### Example
 
-    while( (i < 20) & (!converge) ) {
-        H = H * (t(W) %*% V) / ( t(W) %*% W %*% H);
-        W = W * (V %*% t(H) / (W %*% H %*% t(H));
+    while ((i < 20) & (!converge)) {
+        H = H * (t(W) %*% V) / (t(W) %*% W %*% H);
+        W = W * (V %*% t(H)) / (W %*% H %*% t(H));
         i = i + 1;
     }
 
@@ -284,7 +284,7 @@ The syntax for an if statement is as follows:
         statement1
         statement2
         ...
-    } [ else if (predicate2){
+    } [ else if (predicate2) {
         statement1
         statement2
         ...
@@ -295,27 +295,27 @@ The syntax for an if statement is as follows:
     } ]
 
 
-The If statement has three bodies: the `if` body (evaluated if predicate1 evaluates to true), the optional `else if` body (evaluated if predicate2 evaluates to true) and the optional `else` body (evaluated otherwise). There can be multiple `else if` bodies with different predicates but at most one `else` body. The bodies may contain any sequence of statements. If only a single statement is enclosed in a body, the braces surrounding the statement can be omitted.
+The If statement has three bodies: the `if` body (evaluated if predicate1 evaluates to TRUE), the optional `else if` body (evaluated if predicate2 evaluates to TRUE) and the optional `else` body (evaluated otherwise). There can be multiple `else if` bodies with different predicates but at most one `else` body. The bodies may contain any sequence of statements. If only a single statement is enclosed in a body, the braces surrounding the statement can be omitted.
 
 
 ##### Examples
 
     # example of if statement
-    if( i < 20 ) {
-        converge = false;
+    if (i < 20) {
+        converge = FALSE;
     } else {
-        converge = true;
+        converge = TRUE;
     }
     # example of nested control structures
-    while( !converge ) {
-        H = H * (t(W) %*% V) / ( t(W) %*% W %*% H);
-        W = W * (V %*% t(H) / (W %*% H %*% t(H));
+    while (!converge) {
+        H = H * (t(W) %*% V) / (t(W) %*% W %*% H);
+        W = W * (V %*% t(H)) / (W %*% H %*% t(H));
         i = i + 1;
         zerror = sum(z - W %*% H);
         if (zerror < maxError) {
-            converge = true;
+            converge = TRUE;
         } else {
-            converge = false;
+            converge = FALSE;
         }
     }
 
@@ -403,7 +403,7 @@ attempt to guarantee result correctness for parallel execution. For example, the
 the iterations do not act independently, so they are not parallelizable. The iterations incorrectly try to increment the same `sum` variable.
 
 	sum = 0
-	parfor(i in 1:3) {
+	parfor (i in 1:3) {
 	    sum = sum + i; # not parallelizable - generates error
 	}
 	print(sum)
@@ -490,8 +490,8 @@ userParam=value | User-defined parameter to invoke the package. | Yes | Any non-
 
 A UDF invocation specifies the function identifier, variable identifiers for calling parameters, and the variables to be populated by the returned values from the function. The syntax for function calls is as follows.
 
-    returnVal = functionName( param1, param2, ….)
-    [returnVal1, returnVal2, ...] = functionName(param1, param2, ….)
+    returnVal = functionName(param1, param2, ...)
+    [returnVal1, returnVal2, ...] = functionName(param1, param2, ...)
 
 
 #### Examples
@@ -523,7 +523,7 @@ Note: The command-line parameters are treated as constants which are introduced
     }
     print("A:" + A);
 
-This will result in parser warning, but the program will run to completion. If the expression in the "if" predicate would have evaluated to false, it would have resulted in runtime error. Also, functions need not be defined prior to its call. That is: following code will work without parser warning:
+This will result in parser warning, but the program will run to completion. If the expression in the "if" predicate would have evaluated to FALSE, it would have resulted in runtime error. Also, functions need not be defined prior to its call. That is: following code will work without parser warning:
 
     A = 2;
     C = foo(1, A)
@@ -673,7 +673,7 @@ ppred() | "parallel predicate".<br/> The relational operator specified in the th
 Function | Description | Parameters | Example
 -------- | ----------- | ---------- | -------
 as.scalar(), <br/> as.matrix() | A 1x1 matrix is cast as scalar (value type preserving), and a scalar is cast as 1x1 matrix with value type double | Input: (&lt;matrix&gt;), or (&lt;scalar&gt;) <br/> Output: &lt;scalar&gt;, or &lt;matrix&gt; | as.scalar(X) <br/> as.matrix(x)
-as.double(), <br/> as.integer(), <br/> as.logical() | A variable is cast as the respective value type, data type preserving. as.integer() performs a safe cast. For numerical inputs, as.logical() returns false if the input value is 0 or 0.0, and true otherwise. | Input: (&lt;scalar&gt;) <br/> Output: &lt;scalar&gt; | as.double(X) <br/> as.integer(x) <br/> as.logical(y)
+as.double(), <br/> as.integer(), <br/> as.logical() | A variable is cast as the respective value type, data type preserving. as.integer() performs a safe cast. For numerical inputs, as.logical() returns FALSE if the input value is 0 or 0.0, and TRUE otherwise. | Input: (&lt;scalar&gt;) <br/> Output: &lt;scalar&gt; | as.double(X) <br/> as.integer(x) <br/> as.logical(y)
 
 
 ### Statistical Built-In Functions
@@ -1538,7 +1538,7 @@ Examples:
 Function | Description | Parameters | Example
 -------- | ----------- | ---------- | -------
 append() | Append a string to another string separated by "\n" <br/> Limitation: The string may grow up to 1 MByte. | Input: (&lt;string&gt;, &lt;string&gt;) <br/> Output: &lt;string&gt; | s = "iter=" + i <br/> i = i + 1 <br/> s = append(s, "iter=" + i) <br/> write(s, "s.out")
-toString() | Formats a Matrix or Frame object into a string. <br/> "rows" & "cols" : number of rows and columns to print<br/> "decimal" : number of digits after the decimal<br/>"sparse" : set to true to print Matrix object in sparse format, i.e. _RowIndex_ _ColIndex_ _Value_<br/>"sep" and "linesep" : inter-element separator and the line separator strings| Input : (&lt;matrix&gt; or &lt;frame&gt;,<br/> &nbsp;&nbsp;rows=100,<br/> &nbsp;&nbsp;cols=100,<br/> &nbsp;&nbsp;decimal=3,<br/> &nbsp;&nbsp;sparse=FALSE,<br/> &nbsp;&nbsp;sep=" ",<br/> &nbsp;&nbsp;linesep="\n") <br/> Output: &lt;string&gt; | X = matrix(seq(1, 9), rows=3, cols=3)<br/>str = toString(X, sep=" \| ") <br/><br/>F = as.frame(X)<br/>print(toString(F, rows=2, cols=2))
+toString() | Formats a Matrix or Frame object into a string. <br/> "rows" & "cols" : number of rows and columns to print<br/> "decimal" : number of digits after the decimal<br/>"sparse" : set to TRUE to print Matrix object in sparse format, i.e. _RowIndex_ _ColIndex_ _Value_<br/>"sep" and "linesep" : inter-element separator and the line separator strings| Input : (&lt;matrix&gt; or &lt;frame&gt;,<br/> &nbsp;&nbsp;rows=100,<br/> &nbsp;&nbsp;cols=100,<br/> &nbsp;&nbsp;decimal=3,<br/> &nbsp;&nbsp;sparse=FALSE,<br/> &nbsp;&nbsp;sep=" ",<br/> &nbsp;&nbsp;linesep="\n") <br/> Output: &lt;string&gt; | X = matrix(seq(1, 9), rows=3, cols=3)<br/>str = toString(X, sep=" \| ") <br/><br/>F = as.frame(X)<br/>print(toString(F, rows=2, cols=2))
 print() | Prints a scalar variable. The print() function allows printf-style formatting by optionally allowing multiple arguments, where the first argument is the string that specifies the formatting and the additional arguments are the arguments to format. | Input: &lt;scalar&gt;<br/>or<br/>&lt;string, args...&gt; | print("hello") <br/> print("hello" + "world") <br/> print("value of x is " + x ) <br/><br/>a='hello';<br/>b=3;<br/>c=4.5;<br/>d=TRUE;<br/>print('%s %d %f %b', a, b, c, d); <br/><br/>a='hello';<br/>b='goodbye';<br/>c=4;<br/>d=3;<br/>e=3.0;<br/>f=5.0;<br/>g=FALSE;<br/>print('%s %d %f %b', (a+b), (c-d), (e*f), !g);
 stop() | Halts the execution of DML program by printing the message that is passed in as the argument. <br/> Note that the use of stop() is not allowed inside a parfor loop. |  Input: (&lt;scalar&gt;) | stop("Inputs to DML program are invalid") <br/> stop("Class labels must be either -1 or +1")
 order() | Sort a column of the matrix X in decreasing/increasing order and return either index (index.return=TRUE) or data (index.return=FALSE). | Input: (target=X, by=column, decreasing, index.return) | order(X, by=1, decreasing=FALSE, index.return=FALSE)