NetLogo / Tortoise

Compiler and runtime engine for NetLogo models that runs in JavaScript 🐢
https://netlogoweb.org
Other
56 stars 27 forks source link

Finish up Matrix extension #197

Closed TheBizzle closed 4 years ago

TheBizzle commented 7 years ago

Given the current state of the wip-matrix branch, I'd say that the NLW Matrix extension is now in acceptable shape for me to hand it over to someone else. There are a few loose ends that are worth pointing out, though, and I leave it to @LaCuneta to figure out how he wishes to proceed on these different fronts.

First, the extension is not very well-tested. It has a few tests (taken from desktop NetLogo's Matrix extension), but they aren't thorough. Lots of behavior is untested—significant portions of the API aren't test at all.

On a related note, one of the existing primitives (solve) is already known to have the flaw of yielding results that are only approximate. regress has a similar issue (documented in the tests) where its floating point arithmetic is not 100% accurate with that done in desktop NetLogo. Personally, I don't think that the floating point math issue is likely to become a real problem, but maybe others disagree.

Lastly, there are three primitives that are entirely unimplemented, all of which pertain to eigenvectors: real-eigenvalues, imaginary-eigenvalues, and eigenvectors. There is an issue here, since the otherwise-good matrix library that is being used (Vectorious) does not currently support eigenvector operations. The author has stated numerous times that he intends to implement those things at some point, but... it's been a while; who knows if it will ever happen.

Originally, we had an implementation of real-eigenvalues that used the Numeric library with the code (new Matrix(numeric.eig(toRowList(m)).lambda.x)) and an implementation of eigenvectors with the code (new Matrix(numeric.eig(toRowList(m)).E.x)), but that was when 3000 lines of Numeric were checked directly into version control, and I had issues with getting Numeric to play nice with our infrastructure, so I axed it. If someone wants to bring back the janky second matrix library, they are free to do so. Myself, I'm inclined to believe that the users can wait for a better solution.

My personal opinion on this is that the current extension should be tested more and then silently shipped. I don't think the current approximation issues and lack of eigenvectors should stop it from getting out there and being useful in other ways.