juliale-15 commented on a change in pull request #975:
URL: https://github.com/apache/systemml/pull/975#discussion_r441426528



##########
File path: src/main/python/systemds/matrix/data_gen.py
##########
@@ -102,3 +105,70 @@ def rand(sds_context: SystemDSContext, rows: int, cols: 
int,
         named_input_nodes['seed'] = seed
 
     return OperationNode(sds_context, 'rand', [], 
named_input_nodes=named_input_nodes)
+
+
+def rev(sds_context: 'SystemDSContext', X: Matrix) -> 'OperationNode':
+    """ Reverses the rows in a matrix
+
+    :param sds_context: SystemDS context
+    :param X: Input matrix
+    :return: reversed matrix
+    """
+    X._check_matrix_op()
+    return OperationNode(sds_context, 'rev', [X])
+
+
+def order(sds_context: 'SystemDSContext', X: Matrix, by: int = 1, decreasing: 
bool = False, index_return: bool = False) -> 'OperationNode':
+    """ Sort by a column of the matrix X in increasing/decreasing order and 
returns either the index or data
+
+    :param sds_context: SystemDS context
+    :param X: Input matrix
+    :param by: Column number
+    :param decreasing: If true the matrix will be sorted in decreasing order
+    :param index_return: If true, theindex numbers will be returned
+    :return: sorted matrix
+    """
+    X._check_matrix_op()
+
+    cols = X._np_array.shape[1]
+    if by > cols:
+        raise IndexError("Index {i} is out of bounds for axis 1 with size 
{c}".format(i=by, c=cols))
+
+    named_input_nodes = {'target': X, 'by': by, 'decreasing': 
str(decreasing).upper(), 'index.return': str(index_return).upper()}
+
+    return OperationNode(sds_context, 'order', [], 
named_input_nodes=named_input_nodes)
+
+
+def t(sds_context: 'SystemDSContext', X: Matrix) -> 'OperationNode':
+    """ Transposes the input matrix
+
+    :param sds_context: SystemDS context
+    :param X: Input matrix
+    :return: transposed matrix
+    """
+    X._check_matrix_op()
+    return OperationNode(sds_context, 't', [X])
+
+
+def cholesky(sds_context: 'SystemDSContext', X: Matrix) -> 'OperationNode':
+    """ Computes the Cholesky decomposition of a symmetric, positive definite 
matrix
+
+    :param sds_context: SystemDS context
+    :param X: Input matrix
+    :return: Cholesky decomposition
+    """
+    X._check_matrix_op()
+
+    # check square dimension
+    if X._np_array.shape[0] != X._np_array.shape[1]:
+        raise ValueError("Last 2 dimensions of the array must be square")
+
+    # check if mat is positive definite
+    if not np.all(np.linalg.eigvals(X._np_array)>0):
+        raise ValueError("Matrix is not positive definite")
+
+    # check if mat is symmetric
+    if not np.allclose(X._np_array, X._np_array.transpose()):
+        raise ValueError("Matrix is not symmetric")

Review comment:
       Ah ok I get your point, but I'm not sure how to catch these two 
scenarios (positive definite, symmetric) without these check since SystemDS 
will throw an exception which is not easily readable after calling `compute()`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to