Created
September 13, 2018 13:00
-
-
Save Caellian/dcd22f3ade50d7e4432cca3008c66b9f to your computer and use it in GitHub Desktop.
Example of dense and uncommented code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Creates a new matrix without specified rows & columns. | |
| * | |
| * @param deletedRows rows to exclude from submatrix. | |
| * @param deletedColumns columns to exclude from submatrix. | |
| * @return defined submatrix. | |
| */ | |
| def submatrix(deletedRows: Array[Int], deletedColumns: Array[Int]): MatrixF = { | |
| val result = Array.ofDim[Float](rowCount - deletedRows.count(rowCount >= _), columnCount - deletedColumns.count(columnCount >= _)) | |
| data.indices.filterNot(deletedRows contains _ + 1).zipWithIndex.foreach { case (row, i) => | |
| data(0).indices.filterNot(deletedColumns contains _ + 1).zipWithIndex.foreach { case (col, j) => | |
| result(i)(j) = data(row)(col) | |
| } | |
| } | |
| new MatrixF(result) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment