Singular value decomposition of a matrix *M*: *m x n* (real or complex) is a factorization with the form *UΣV**, where *U* is an *m x R* matrix. *Σ* is an *R x R* rectangular diagonal matrix with non-negative real numbers on the diagonal, and *V* is an *n x r* unitary matrix. *r* is equal to the rank of the matrix *M*.

The diagonal entries *Σii* of Sigma are known as the singular values of *M*. The columns of *U* and the columns of *V* are called the left-singular vectors and right-singular vectors of *M* respectively.

The following is an example of an SVD in Apache Spark:

package linalg.svd import org.apache.spark.{SparkConf, SparkContext} import org.apache.spark.mllib.linalg.distributed.RowMatrix import org.apache.spark.mllib.linalg.{Matrix, ...