Working with matrices
As we discussed in the Working with vectors recipe, you could use the Eclipse or IntelliJ IDEA Scala worksheets for a faster turnaround time.
How to do it...
There are a variety of functions that we have in a matrix. In this recipe, we will look at some details around:
- Creating matrices:
- Creating a matrix from values
- Creating a zero matrix
- Creating a matrix out of a function
- Creating an identity matrix
- Creating a matrix from random numbers
- Creating from a Scala collection
- Matrix arithmetic:
- Addition
- Multiplication (also element-wise)
- Appending and conversion:
- Concatenating a matrix vertically
- Concatenating a matrix horizontally
- Converting a matrix of Int to a matrix of Double
- Data manipulation operations:
- Getting column vectors
- Getting row ...
Get Scala Data Analysis 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.