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

    • java.io.Serializable

    • 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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.