Hi Srini, If you want to get value like the following example using scala, some other language also like this " mat.rows.collect().apply(i) val cov = mat.computeCovariance() cov.apply(i, j) " mat is RowMatrix type and the cov is Matrix type.
------------------ ???????? ------------------ ??????: "Srivathsan Srinivas";<srivathsan.srini...@gmail.com>; ????????: 2016??1??22??(??????) ????1:12 ??????: "zhangjp"<592426...@qq.com>; ????: "user"<user@spark.apache.org>; ????: Re: retrieve cell value from a rowMatrix. Hi Zhang, I am new to Scala and Spark. I am not a Java guy (more of Python and R guy). Just began playing with matrices in MlLib and looks painful to do simple things. If you can show me a small example, it would help. Apply function is not available in RowMatrix. For eg., import org.apache.spark.mllib.linalg.distributed.RowMatrix /* retrive a cell value */ def getValue(m: RowMatrix): Double = { <what should go in here>??? } Likewise, I have trouble adding two RowMatrices /* add two RowMatrices */ def addRowMatrices(a: RowMatrix, b: RowMatrix): RowMatrix = { } From what I have read on Stackoverflow and other places is that such simple things are not exposed in MlLib. But, they are heavily used in the underlying Breeze libraries. Hence, one should convert the rowMatrics to its Breeze equivalent, do the required operations and convert it back to rowMatrix. I am still learning how to do this kind of conversion back and forth. If you have small examples, it would be very helpful. Thanks! Srini. On Wed, Jan 20, 2016 at 10:08 PM, zhangjp <592426...@qq.com> wrote: use apply(i,j) function. can u know how to save matrix to a file using java language? ------------------ ???????? ------------------ ??????: "Srivathsan Srinivas";<srivathsan.srini...@gmail.com>; ????????: 2016??1??21??(??????) ????9:04 ??????: "user"<user@spark.apache.org>; ????: retrieve cell value from a rowMatrix. Hi, Is there a way to retrieve the cell value of a rowMatrix? Like m(i,j)? The docs say that the indices are long. Maybe I am doing something wrong...but, there doesn't seem to be any such direct method. Any suggestions? -- Thanks, Srini. -- Thanks, Srini.