Github user iyerr3 commented on a diff in the pull request:
https://github.com/apache/incubator-madlib/pull/10#discussion_r51927326
--- Diff: src/ports/postgres/modules/linalg/matrix_ops.py_in ---
@@ -3093,3 +3094,75 @@ def matrix_ones(schema_madlib, row_dim, col_dim,
matrix_out, out_args):
""" Create a row_dim by col_dim matrix with each element set to 1.
"""
_matrix_create_scalar(schema_madlib, row_dim, col_dim, matrix_out,
out_args, 1)
+
+
+def matrix_random(schema_madlib, distribution, row_dim, col_dim,
+ in_args, matrix_out, out_args):
+ """ Create a row_dim by col_dim random matrix from distribution.
+ """
+ _validate_output_table(matrix_out)
+ _assert(row_dim > 0 and col_dim > 0,
+ "Matrix error: Invalid dimensions for input matrices: {0} x
{1}".
+ format(row_dim, col_dim))
+
+ out_args = parse_matrix_args(
+ out_args, in_default_args={'row': 'row', 'col': 'col', 'val':
'val'})
+
+ distribution = 'uniform' if not distribution else distribution.lower()
+ supported_dist = ['uniform', 'normal']
--- End diff --
We have the same pattern in multiple places (here, kernel selection in svm,
norm selection in matrix_ops) . If you're up for it, please move this to a
function and update all locations. Else please create a JIRA to make this
update.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---