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

Support for non-square matrices #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jadrian
Copy link

@jadrian jadrian commented Feb 18, 2016

Hi @esangel-

When using your MV.js for a course I'm teaching, I found a couple bugs in transpose() and mult() which seem to stem from an assumption that matrices must always be square. However, non-square matrices are useful, for example, for representing all the vertices of a shape.

The current implementation of transpose() creates a result whose number of rows is the same as the input's number of rows, and whose number of columns is also the same as the input's.

The current implementation of mult(), when called on two matrices, checks to see that their dimensions exactly match; that is, that if u is MxN, then v must also be MxN. Instead, the correct check is to verify that if u is MxN, then v must be NxP, and the result should be an MxP matrix.

My two patches fix these errors, but still assume that all rows are the same length in a matrix input, even though it's possible to create a list-of-lists with different lengths for the inner lists.

The changes should not disrupt the behavior of the existing code; all calls with square matrices work just the same as they did previously. Please check them over; I hope you find these to be useful contributions.

-Jadrian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant