Spark distributed matrix multiply and pseudo-inverse calculating -


i new in apache spark scala. can me operations?

i have 2 distributed matrix h , y in spark scala.

i want compute pseudo-inverse of h , multiply h , y.

how can this?

here implementation inverse.

import org.apache.spark.mllib.linalg.{vectors,vector,matrix,singularvaluedecomposition,densematrix,densevector} import org.apache.spark.mllib.linalg.distributed.rowmatrix  def computeinverse(x: rowmatrix): densematrix = {   val ncoef = x.numcols.toint   val svd = x.computesvd(ncoef, computeu = true)   if (svd.s.size < ncoef) {     sys.error(s"rowmatrix.computeinverse called on singular matrix.")   }    // create inv diagonal matrix s    val invs = densematrix.diag(new densevector(svd.s.toarray.map(x => math.pow(x,-1))))    // u cannot rowmatrix   val u = new densematrix(svd.u.numrows().toint,svd.u.numcols().toint,svd.u.rows.collect.flatmap(x => x.toarray))    // if make v distributed, may better. alreadly local...so maybe fine.   val v = svd.v   // inv(x) = v*inv(s)*transpose(u)  --- u transposed.   (v.multiply(invs)).multiply(u)   } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -