Closed drmoose closed 6 years ago
This PR adds shortcut functions to the Matrix interface inspired by the filterKeys/filterValues functions supplied by Kotlin's Maps.
Matrix
filterKeys
filterValues
filterRows
filterRowsIndexed
filterCols
filterColsIndexed
All four take a predicate, and return a matrix that includes all of the (rows/cols) from the source matrix for which the predicate returns true.
>>> println(eye(6).filterRows { it[1] == it[3] }.repr()) mat[ 1.00, 0.00, 0.00, 0.00, 0.00, 0.00 end 0.00, 0.00, 1.00, 0.00, 0.00, 0.00 end 0.00, 0.00, 0.00, 0.00, 1.00, 0.00 end 0.00, 0.00, 0.00, 0.00, 0.00, 1.00 ]
Looks good, thanks.
This PR adds shortcut functions to the
Matrix
interface inspired by thefilterKeys
/filterValues
functions supplied by Kotlin's Maps.filterRows
filterRowsIndexed
filterCols
filterColsIndexed
All four take a predicate, and return a matrix that includes all of the (rows/cols) from the source matrix for which the predicate returns true.