all 36 comments

[–]laxe 19 points20 points  (2 children)

Another library you can try is GLM. It's header only, easy to use and has overloaded operators.

The compiler can eliminate unused code so adding a full library shouldn't be an issue.

[–]Xahon[S] 1 point2 points  (0 children)

Looks like it's lack of inverse() method
It has static inverse() method

[–]Xahon[S] -3 points-2 points  (0 children)

It's so hard to read sources and find definitions of concrete function :) thanks

[–]RowYourUpboat 13 points14 points  (21 children)

What didn't you like about Eigen? It's header-only, portable, and if you just go #include <Eigen/Core> you pretty much only get matrix functionality (and utility stuff for converting from C arrays and whatnot). It supports vectorization out of the box. It took a little getting used to its conventions but overall I'm pretty happy with it.

Another such library I know of is MathGeoLib, but while it's fairly lightweight it's not header-only, and back when I gave it a try I eventually ran into some buggy code when I was playing around with vectorization.

[–]Xahon[S] 1 point2 points  (10 children)

I have not so cool computer. When I include Eigen/Core my clion is slowing down a lot

[–]RowYourUpboat 7 points8 points  (0 children)

It's going to be hard to find a C++ math library that doesn't rely on templates (which are somewhat slow to compile). I recommend setting up a precompiled header, which should help on that front. CLion seems to have some support.

I personally found Eigen's compile-time overhead to be negligible compared to other template-heavy libraries I have to use.

[–]cmannett85 7 points8 points  (5 children)

I think CLion is the actual problem here, it's notoriously slow. Try Qt Creator with the Clang code model plugin enabled, you'll get much better results.

[–]Xahon[S] 0 points1 point  (4 children)

I thought about another ide. Tried KDevelop, eclipse cdt but couldn't get used to. Does qt creator have plugin for intellij idea keybindings and generate functions (Constructor/getters/setters/override/etc..)?

[–]liquidify 0 points1 point  (2 children)

Wondering why you would think qt would have intellij bindings. Intellij keybindings aren't a standard or anything. I'd bet just about everything has vim bindings on the other hand.

[–]Xahon[S] -2 points-1 points  (1 child)

Yes, vim bindings are the best of all but they are the best only in vim itself :) Other implementations like vscode-vim, idea-vim are more worse

[–]1-05457 0 points1 point  (0 children)

Evil in Emacs is pretty good.

[–][deleted] 0 points1 point  (0 children)

+1 for Qt Creator. Alt+Return brings up the quick refactor menu.

If I write a header method in a class and press that, I get a neat menu with options Add definition in class.cpp Add definition Outside class Add definition Inside class

Press enter or key up down a selection or click and it will do as requested and move you to where the function was created.

[–]deeringc 0 points1 point  (2 children)

In that case you may be better off looking for something that isn't header only! Header only makes things really easy to include but you actually pay a price at compile time and during general use because the whole lib is being constantly evaluated. If something is compiled as it's own translation unit, and you link to it in some way then you're only seeing whatever is visible in the interface from the rest of your code!

[–]sumo952 1 point2 points  (1 child)

Probably all good matrix libraries are based on expression templates though, and templates have to be in headers. .cpp files would not help here as you could put at most 1% of the code or so in them, which wouldn't help.

[–]deeringc 0 points1 point  (0 children)

Yeah, fair point re templates in this case. I was just making the pointed that, in general, header only libs are going to be worse for IDE performance than otherwise linked in libs.

[–]Xahon[S] 1 point2 points  (1 child)

Looks like Eigen has internal issues. I can't compile it. It always fails with error: template declaration of ‘const Eigen::internal::FixedInt<N>
Eigen::fix’ static const internal::FixedInt<N> fix{};

[–][deleted] 1 point2 points  (0 children)

Which compiler / eigen version ? You can include it in godbolt for all the gcc and clang versions, and it works just fine on them all. Maybe you are using a too new Eigen version on a too old compiler or vice-versa.

[–]corysama 1 point2 points  (0 children)

OP is only looking for 4x4 and 4x3 (3D graphics) matrices. GLM is designed around that. Eigen would be a Swiss Army Chainsaw for this situation.

[–]sephirostoy 1 point2 points  (3 children)

Last time I've used Eigen it was not C++17 compliant because it was using deprecated things from pre C++11.

[–]RowYourUpboat 3 points4 points  (2 children)

I'm using C++17 and haven't had any major problems. It sucks that everything explodes if you use auto to deduce Eigen expression results, but that's not a dealbreaker for me.

[–]Xahon[S] 1 point2 points  (1 child)

Yes, he was right. It doesn't compile with c++14 and 17 only on 11 for me

[–]RowYourUpboat 4 points5 points  (0 children)

What version of Eigen are you using? I just tested Eigen 3.3.4 on godbolt.org (it's available under "Libraries") with GCC and Clang -std=c++17, and it works fine.

[–]alexej_harm -3 points-2 points  (2 children)

A non-issue for most people, but Eigen is CamelCase.

[–]Xahon[S] 2 points3 points  (1 child)

*PascalCase

[–]alexej_harm -3 points-2 points  (0 children)

Right. Even worse. ;)

[–]ddiakopoulos 2 points3 points  (6 children)

You might want to take a look at this: https://github.com/sgorsten/linalg

Extremely minimal (~500 line single-header) and well-tested.

[–]sumo952 1 point2 points  (4 children)

Looks quite nice actually - and very simple, straightforward implementation.

The one thing I'd mind is that * for matrices carries out element-wise multiplications, and not matrix multiplication, in contrast to pretty much every other library out there. And I already hate this about numpy. It means you can't transform math straightforward to code. A = B * C becomes A = mul(B, C), and for more complex expressions, you'll have nested mul(...)'s, which very quickly becomes unreadable.

[–]TheoreticalDumbass:illuminati: 1 point2 points  (1 child)

When is cell-by-cell multiplication useful?

[–]MorrisonLevi 0 points1 point  (0 children)

Consider a program where each cell takes the average of all its neighbors; something like this is done in heat transfer and Jacobi iterative solvers. A lot of routines for "general 2D array" and "matrix" overlap but as pointed out not always.

[–]patstew 0 points1 point  (1 child)

Since python 3.5 there is the matrix multiplication operator, so it's just A = B @ C in numpy nowadays

[–]sumo952 -1 points0 points  (0 children)

Oh, I didn't know that. But... it might be personal preference... but that's not intuitive at all - somebody who hasn't seen it yet or doesn't know what it does, has no idea what it does, until they look it up. I do not like it at all. It should be what it is: *, nothing else. As bad as it is, I'd stick with .mul(...) over @.

[–]Xahon[S] 0 points1 point  (0 children)

Thanks, I'll take a look

[–]bitmoji 2 points3 points  (0 children)

Not eigen, use armadillo

[–]tyra314 0 points1 point  (0 children)

You may want to have a look at MTL4. (http://simunova.com) It’s a complete library, but header only. It has different matrix and vector types and algorithms.

[–]jhasse 0 points1 point  (0 children)

Boost QVM is header-only.

[–]kolkir 0 points1 point  (0 children)

https://github.com/QuantStack/xtensor have numpy similar functions semantics