[
https://issues.apache.org/jira/browse/SYSTEMML-475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15240289#comment-15240289
]
Mike Dusenberry commented on SYSTEMML-475:
------------------------------------------
Note: I'm going to close this for now, but we should consider revisiting these
ideas in the future with regards to quick fixes for print statements and string
appends, as well as broader design decisions for native scalar outputs for full
right-indexing (i.e. {{X[1,3]}}).
> Add Implicit Conversion Between Scalar Values and 1x1 Matrices
> --------------------------------------------------------------
>
> Key: SYSTEMML-475
> URL: https://issues.apache.org/jira/browse/SYSTEMML-475
> Project: SystemML
> Issue Type: Improvement
> Components: Compiler, Parser
> Reporter: Mike Dusenberry
> Assignee: Mike Dusenberry
>
> Currently, any DML functions that require scalars will not accept 1x1
> matrices. Matrix indexing always returns a matrix, so a statement such as
> {{A[1,1]}} from the following simple example will return a single-valued
> matrix, even though it logically represents a scalar. Thus, in order to use
> this value as a scalar, the {{as.scalar(...)}} function is required.
> {code}
> A = matrix(7, rows=10, cols=10)
>
> print( "A[1,1]: " + as.scalar(A[1,1])) // 7
> {code}
> In this scenario, the required usage of {{as.scalar(...)}} can cause
> confusion, and can be viewed as a violation of SystemML's goal of hiding the
> underlying data representation from the user.
> Additionally, many of the built-in functions, such as {{rowVars(...)}},
> accept matrices without other requirements of dimensionality, and thus will
> accept a 1x1 matrix, yet will not accept a scalar value. We should allow any
> such functions that accept 1x1 matrices to also accept scalar values.
> {code}
> a = 4
> print("Row variances of scalar are: " + rowVars(a)) // 0
> {code}
> In order to achieve this, we can add implicit casting between scalar values
> and 1x1 matrices within the parser during the validation stage as needed.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)