Patch a bug in the Dim function

Former-commit-id: 004545e81df4dcf33294fb062de8204692035cdf
This commit is contained in:
2023-08-27 16:18:10 +02:00
parent 18d3eec24a
commit 5b7d88ccc6

View File

@ -93,5 +93,13 @@ func (matrix *Matrix[T]) Rows(i ...int) Matrix[T] {
// It takes no parameters.
// It returns two integers: the number of rows and the number of columns.
func (matrix *Matrix[T]) Dim() (int, int) {
switch {
case *matrix == nil:
return 0, 0
case len(*matrix) == 0:
return 0, 0
case len((*matrix)[0]) == 0:
return len(*matrix), 0
}
return len(*matrix), len((*matrix)[0])
}