-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add usolveAll and lsolveAll methods #1916
Conversation
Sounds good, thanks Michal! I'll review your work soon. Makes sense to not throw an error but return an empty array when there are no solutions. Thinking aloud here: we could also think about introducing two versions of the functions like |
The code looks very neat Michal, nice job 👍 . There are indeed still extra tests needed to test the new functionality. I'm curious to hear your ideas about either changing the behavior of |
Initially I thought there's no advantage in only finding one solution. But when I think about it again, for very large matrices with low rank, the difference in both computation time and memory usage would be noticable. So you're right, it would be probably best to expose methods for both "find one solution" and "find all solutions". About the API: I'm strongly for creating a new method instead of making one method with options. A robust API should only have few return types for a method :) Later today, I'll revert the changes to |
Makes sense that there will be a performance hit for finding all vs just one solution.
Sounds like a good plan to keep the methods separate 👍 . The names |
.
EDIT 2: Haha the tests were failing just locally because I didn't run EDIT 3: How do I fix the one error in Travis? |
😂 Good to hear you figured it out.
The new function should be added to the following index file so it will be bundled: https://github.com/josdejong/mathjs/blob/develop/src/factoriesAny.js |
I have done that already: https://github.com/josdejong/mathjs/pull/1916/files#diff-97a500a8c25160352eb28525e7d37613 |
Ahh, sorry. There is indeed also the embedded docs. Those are located in the folder: https://github.com/josdejong/mathjs/tree/develop/src/expression/embeddedDocs/function/algebra And the index file of the embedded docs is: https://github.com/josdejong/mathjs/blob/develop/src/expression/embeddedDocs/embeddedDocs.js I should make those error messages more explanatory, sorry. |
@m93a did you see my latest comment? Want me to fix the embedded docs? |
Sorry, I didn't have time to reply earlier. All set and ready to merge, sir! 😁️ |
No problem at all! I have the same issue regularly 😄 Thanks for the updates, will merge your work now. |
Published now in |
Fixes #1748, needed for #1743
In this pull request, I implement an algorithm that generalizes front- and back-substitution. Similar to
usolve
andlsolve
,usolveAll
andlsolveAll
return an array containing the vectors that make up an affine basis of the solution space. This means that all valid solutions can be expressed as an affine combination of these vectors.Example usage:
Previously,
u
-,l
- andlusolve
thrown an error when no solution existed. I kept it this way for now, but I'm tempted to return an empty array instead, as there is nothing bad or wrong about the case when a system doesn't have a solution, and throwing an unnecessary error might force users to write a lot of surplus try-catch blocks.