Giter Club home page Giter Club logo

Comments (2)

httpdigest avatar httpdigest commented on August 24, 2024

You are right in that both Matrix4f.determinant() and Matrix4f.invert() would need to effectively do the same computations. And they indeed do. It's just that the calculations done in Matrix4f.invert() have been massively reshuffled and reorganized to make full use of variables to hold common sub-expressions that are computed at least twice. This gave a huge performance boost compared to a naive implementation of Matrix4f.invert() where you'd simply once call determinant() and then do all computations for the individual matrix elements.
However, both the determinant and the inverse matrix elements share many common sub-expressions that need not be computed multiple times, so I spend literally hours refactoring it to have as few arithmetic operations and as many reuses of variables for common sub-expressions as possible.

The fact that you do not see the common alternating + - patterns in the determinant is that this has also been restructured/reshuffled to "look nicer". Note that + (a * b - c * d) is equal to - (c * d - a * b). This is all there is to it, really.

And both methods should do what they are supposed to do.

from joml.

TheIceCreamBear avatar TheIceCreamBear commented on August 24, 2024

Note that + (a * b - c * d) is equal to - (c * d - a * b). This is all there is to it, really.

This makes so much more sense now and I didn't even think about that. Nor did I think about the performance implications. Thank you for clarifying!

from joml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.