You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (JIRA)" <ji...@apache.org> on 2015/08/20 04:44:46 UTC

[jira] [Assigned] (SPARK-10127) Add numpy-like indexing interface for DenceMatrix

     [ https://issues.apache.org/jira/browse/SPARK-10127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Apache Spark reassigned SPARK-10127:
------------------------------------

    Assignee:     (was: Apache Spark)

> Add numpy-like indexing interface for DenceMatrix
> -------------------------------------------------
>
>                 Key: SPARK-10127
>                 URL: https://issues.apache.org/jira/browse/SPARK-10127
>             Project: Spark
>          Issue Type: New Feature
>          Components: MLlib
>            Reporter: Hiroshi Takahashi
>
> Currently, we don't have good interface to access sub-matrix.
> It's inconvenience to prototype manipulate matrix via spark-shell for the reason.
> My suggestion is to add operator "!" as operator of accessing sub-matrix instead of numpy's ().
> for example:
> {code}
> scala> import org.apache.spark.mllib.linalg.DenseMatrix
> import org.apache.spark.mllib.linalg.DenseMatrix
> scala> val dm = new DenseMatrix(3, 3, Array(1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0))
> dm: org.apache.spark.mllib.linalg.DenseMatrix = 
> 1.0  2.0  3.0  
> 4.0  5.0  6.0  
> 7.0  8.0  9.0  
> // get row
> scala> dm!(1)
> res0: org.apache.spark.mllib.linalg.DenseMatrix = 4.0  5.0  6.0  
> // get (i, j)
> scala> dm!(1, 2)
> res1: Double = 6.0
> // get colmun
> scala> dm!((), 1)
> res2: org.apache.spark.mllib.linalg.DenseMatrix = 
> 2.0  
> 5.0  
> 8.0  
> // get columns between i and j-1
> scala> dm!((), (1, 3))
> res3: org.apache.spark.mllib.linalg.DenseMatrix = 
> 2.0  3.0  
> 5.0  6.0  
> 8.0  9.0  
> // get rows between i and j-1
> scala> dm!((1, 3))
> res4: org.apache.spark.mllib.linalg.DenseMatrix = 
> 4.0  5.0  6.0  
> 7.0  8.0  9.0  
> // get sub-matrix between (i1, j1-1) and (i2, j2-1)
> scala> dm!((1, 3), (1, 3))
> res5: org.apache.spark.mllib.linalg.DenseMatrix = 
> 5.0  6.0  
> 8.0  9.0  
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org