apache spark - Creating BlockMatrix of m rows n columns where m is not equal to n without using 'transpose' -


i working on algorithm has following things

  = np.array([[10,  5, 1, 0, 0],           [6, 6, 0, 1, 0],           [4.5, 18,0, 0, 1]])   nonbasis = np.array([0, 1])  basis = np.array([2, 3, 4]) 

i doing following create blockmatrix above given info.

dm2 = matrices.dense(3, 2, a[:, nonbasis].flatten().tolist())  blocks2 = sc.parallelize([((0, 0), dm2)])  mat3 = blockmatrix(blocks2, 3, 2) 

i expecting mat3 follows,

mat3 = densematrix([[ 10. ,   5. ],          [  6. ,   6.],          [  4.5 ,  18. ]]) 

the result is,

mat3 = densematrix([[ 10. ,   6. ],          [  5. ,   4.5],          [  6. ,  18. ]]) 

ideally if 3x3 matrix or nxm n=m have used mat3 =mat3.transpose().

here if 2x3 matrix becomes 3x2 creating problems further in algorithm. can suggest simple solution.

i'd go intermediate indexedrowmatrix:

from pyspark.mllib.linalg.distributed import indexedrowmatrix  indexedrowmatrix(sc.parallelize(enumerate(a))).toblockmatrix() 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -