Added functions: schur, sylvester, and lyap#2646
Conversation
|
Thanks Lucas, that looks good at first sight. I will review your PR more in-depth soon. Some first notes:
|
|
You're welcome and thanks for the review! :)
Yes, I'll try to do it in the next few days (I am a bit overwhelmed this week)...
Sure thing!
Yes, I was hesitating between both but I agree that makes sense. By the way, CI is failing but I cannot check if the error was due to my changes... |
|
Thanks, take it easy 👍 Don't worry about the failing build-and-test, I can look into it if needed. It could indeed be unrelated to your changes. As for the types: so there are two definitions: a static function like |
|
Hey @josdejong, I also added the docs for the chained versions (only As you suggested I moved the functions to algebra and Finally, CI was failing because of the doc tests. I added Let me know if there's something else to be done :) |
|
Thanks for the updates Lucas 👍 , I'll review your updates somewhere this week |
|
Hello, I just solved the conflict in the author's file. |
|
Thanks for the ping @egidioln , for some reason I totally forgot about this PR, I'm sorry 😳 . You're right about the BigNumbers, that is not supported by All in all this PR looks very good. Thanks for writing the documentation and unit tests. Two more questions:
|
|
No Worries @josdejong, thanks for doing this check :)
Unfortunately the schur decomposition is not unique. One can verify the correctness of the decomposition by comparing For For the Lyapunov equation in octave/matlab it is However, thinking better now, maybe it is a good idea to have a notation for these that matches octave/matlab, do you agree?
Actually, maybe I wasn't clear but I had mentioned above that I didn't implement it because |
|
ah, that makes sense. Your explanation of the different definitions in differing math applications helps me a lot understanding what is going on. That complicates things. So first thing is to clearly document this, which you did. It may be good to mention the existence of an alternative definition in the documentation so the user is aware that he may be assuming one or the other definition. In general I try to use the "most commonly" used definition: what do Matlab, Mathematica, and Pythons NumPi for example use? Do you have an idea what is the most common definition for these three functions? As for the missing chained definition for |
|
Hey @josdejong, So I changed I changed the docs and tests accordingly. Let me know if there's something else to be done here 😉 |
|
Thanks @egidioln , this looks very good and well documented, thanks for all your work 👍 Looking at the code, I think the implementations also support bignumbers out of the box, which is great. Can you write some (small) unit tests to validate that? |
Thanks @josdejong 😄! So is https://github.com/josdejong/mathjs/pulls#issuecomment-1274438181 |
|
o wow, of course. Sorry I forgot about the dependency on OK all is ready then, thanks a ton for all your effort Lucas! |
Cool!! Thank you for your guidance Jos! I'll try to code the discrete-time version of |
|
ow, that sounds promising! Thanks. |
|
Published now in |
Hi there,
I added these 3 functions:
schur,sylvester, andlyap.Respectively, they perform a real Schur decomposition, solve a Sylvester equation and a continuous-time Lyapunov equation.
I notice that there are no javascript implementations of these online and they are pretty useful linear-algebra operations for signal processing and control systems.
In the future, these could be extended to deal with complex matrices and the discrete-time version of
lyap(lyapd) could be implemented.I followed the syntax from Matlab and the values from the tests were compared to the outputs from there.
Tests are passing locally. I hope all is good :)