Matrix Transpose on RowMatrix in Spark

前端 未结 6 1225
梦谈多话
梦谈多话 2020-12-16 15:20

Suppose I have a RowMatrix.

  1. How can I transpose it. The API documentation does not seem to have a transpose method.
  2. The Matrix has the transpose() me
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 16:11

    You can use BlockMatrix, which can be created from an IndexedRowMatrix:

    BlockMatrix matA = (new IndexedRowMatrix(...).toBlockMatrix().cache();
    matA.validate();
    
    BlockMatrix matB = matA.transpose();
    

    Then, can be easily put back as IndexedRowMatrix. This is described in the spark documentation.

提交回复
热议问题