How it works...

  1. The signatures for this method constructor are (Column-major dense matrix):
DenseMatrix(int numRows, int numCols, double[] values)DenseMatrix(int numRows, int numCols, double[] values, boolean isTransposed)
  1. The method inherits from the following which makes their concrete methods available to all routines:
    • interface class java.lang.Object


    • Matrix

  2. There are several method calls that are of interest:
    1. Generate the diagonal matrix from the supplied values in the vector:

static DenseMatrix(Vector vector) 
    1. Create an identity matrix. An identity matrix is a matrix that has diagonals as 1 and any other element as 0:
static eye(int n) 
    1. Keep track of whether the matrix is transposed:

Get Apache Spark 2.x Machine Learning Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.