[SYSTEMDS-2756] Improved scale built-in function

Closes #1123.
diff --git a/scripts/builtin/scale.dml b/scripts/builtin/scale.dml
index 7f371cd..4fc3ef4 100644
--- a/scripts/builtin/scale.dml
+++ b/scripts/builtin/scale.dml
@@ -19,22 +19,29 @@
 #
 #-------------------------------------------------------------
 
-m_scale = function(Matrix[Double] X, Boolean center, Boolean scale) return (Matrix[Double] Y) {
-  # This function centers scales and performs z-score on the input matrix X
+# Scale and center individual features in the input matrix 
+# (column-wise) using z-score to scale the values.
+# -----------------------------------------------------------------------------
+# NAME   TYPE    DEFAULT  MEANING
+# -----------------------------------------------------------------------------
+# X      Matrix  ---      Input feature matrix
+# center Boolean TRUE     Indicates whether or not to center the feature matrix
+# scale  Boolean TRUE     Indicates whether or not to scale the feature matrix
+# -----------------------------------------------------------------------------
+# Y            Matrix ---  Output feature matrix with K columns
+# -----------------------------------------------------------------------------
 
+m_scale = function(Matrix[Double] X, Boolean center, Boolean scale) return (Matrix[Double] Y) {
   if( center )
     X = X - colMeans(X);
 
   if (scale) {
-    N = nrow(X);
-    if( center )
-      cvars = (colSums(X^2) - N*(colMeans(X)^2))/(N-1);
-    else
-      cvars = colSums(X^2)/(N-1);
+    cvars = colSums(X^2)/(nrow(X)-1);
 
     #scale by std-dev and replace NaNs with 0's
     X = replace(target=X/sqrt(cvars),
       pattern=NaN, replacement=0);
   }
+  
   Y = X;
 }