-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Introduce make-matrix-determinant
for field-based matrices
#105
base: master
Are you sure you want to change the base?
Conversation
I'm sorta ambivalent about the code but why do we want this? I understand what a matrix is and how to find determinants in various fields or whatever. I also understand that this will allow you to handle arrays of |
Motivation for This PRThe original goal was to support zero-sized matrices to demonstrate mathematical concepts like category-theoretic null objects. However, this revealed deeper limitations in
By generalizing to accommodate algebraic structures, we not only expand the package's functionality but also establish a more robust foundation for handling edge cases like empty matrices. Benefits of Algebraic AbstractionIn addition to support for more general types, reimplementing Although I am not privy to the original implementation context of By supporting more generalized matrix operations based on algebraic structures, we can eliminate the interference caused by specific types and focus solely on the core logic from a mathematical perspective. This approach will help clarify and refine the code's logic. API Complexity ConcernsThe existing API constructs a As you pointed out, the current API does appear somewhat complex. However, I believe this complexity primarily stems from the requirements of implementing Gaussian elimination. When working with matrices based on more general algebraic structures, only a few operators are typically needed. For instance, commonly used generic matrix operations like |
Uhh, ok. This seems like a whole new abstraction that applies to one single method in the entire Your primary motivation seems to be allowing one to take the determinant of a zero-size matrix; that seems like a really rare edge case. While the library being "algebraic" or "categorical" is a nice to have, the goal of the library is actually doing linear algebra; zero-size matrices are in fact rare in actual workloads and adding APIs to support them seems odd. Do you, as contributor, actually have code that needs this? Or do you just think this will make a nicer API? |
My primary use case involves these operators:
While I don't personally need
The |
I'd still love to hear what the use case is. In any case it kinda sounds like what you want to do is rewrite the entire library, with a new API, new organization, and so on. In which case—perhaps you should just write a package? And then maybe there's no actual need to put it in the core |
My core motivation is to demonstrate abstract algebraic concepts using matrices as a pedagogical tool. For example:
The current While my personal focus is theoretical, generalized matrix operations are critical in many real-world domains:
These use cases require matrix operations over non-
This PR introduces a lightweight abstraction layer (e.g.,
The core logic for operations like matrix determinant and matrix multiplication is already well-implemented in If you think this direction aligns with |
I think a separate package is better. The idea of a math library parameterized over fields is a good one, it's how many new languages like Lean work, but it's not how Racket mostly works (we have a specific numeric tower) and I think both you and your possible users are more interested in an abstract algebra library than a linear algebra library. Nothing wrong with that, but for example pivoting is a good idea in linear algebra and a bad one in abstract algebra. Doing both from the same library doesn't sound like a good move to me. If this makes sense I'd appreciate you closing the PR/issue. |
Sorry to jump in. |
@pavpanchekha Thank you for the thoughtful perspective. I completely understand the value of keeping
This way we let real user needs guide the decision. Either way, I deeply respect your stewardship of the library. |
Yes, sure, no problem keeping it open. |
Checklist
Description of change
Adds
make-matrix-determinant
constructor that accepts field operations (+-*/=
), and refactors existingmatrix-determinant
to usemake-matrix-determinant
internally.Tested on
100×100
matrices with the following code:The new implementation shows no significant performance difference.