Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialization using array creates mismatch in grid size #57

Closed
loudinb opened this issue Jan 6, 2017 · 1 comment
Closed

initialization using array creates mismatch in grid size #57

loudinb opened this issue Jan 6, 2017 · 1 comment
Labels

Comments

@loudinb
Copy link

loudinb commented Jan 6, 2017

There seems to be an issue when initializing a matrix using an array. The backing grid does not contain the correct number of elements (e.g. rows*columns) in all cases.

examples:
Matrix([[1.0,2.0]]) results in a grid of [1.0, 2.0, 0.0] // contains 1 extra element
Matrix([[1.0,2.0,3.0]]) results in a grid of [1.0, 2.0, 3.0, 0.0, 0.0] // contains 2 extra elements
Matrix([[1.0,2.0],[1.0,2.0]]) results in a grid of [1.0, 2.0, 1.0, 2.0]
Matrix([[1.0,2.0, 3.0],[1.0,2.0, 3.0]]) results in a grid of [1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 0.0, 0.0] // contains 2 extra elements

The problems seems to be caused by replaceSubrange. There seems to be a problem in the calculation for the half open range:
grid.replaceSubrange(i*n..<i*n+Swift.min(m, row.count), with: row)

The problem seems to be fixed by moving to a closed range using the same range calculation.
grid.replaceSubrange(i*n...i*n+Swift.min(m, row.count), with: row)

@alejandro-isaza
Copy link
Collaborator

Fixed, thanks!

alejandro-isaza added a commit that referenced this issue Sep 19, 2017
alejandro-isaza added a commit that referenced this issue Sep 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants