Archived

This topic is now archived and is closed to further replies.

Drath

Building a maths library (c++)

Recommended Posts

Drath    138
What approach is best? I have seen many different libraries now. Here are various options I need to consider: Should I make my functions all inline? Else inline most but not larger functions such as inverse. How much of a speed advantage does inlining give? Should I take a class or a function approach? In other words: Mat.Inverse(); or InverseMatrix(&Mat); Mat.BuildView(a,b,c) or BuildViewMatrix(&Mat,a,b,c);

Share this post


Link to post
Share on other sites
Garrland    122
I prefer the class approach ie. Matrix.Inverse(). But this is personal preference. I don''t thin there is much of a speed difference between a function and a member function. Using inline can speed up your code since no function call is required. I use inline on most of my Matrix, Vector, etc classes but not for all member functions. If you use inline too much you can increase the size of your .exe quite a bit. Also some compilers use the inline keyword as a suggestion not a rule. If you are using MSVC you can use __forceinline to make it a rule.

Journal

Share this post


Link to post
Share on other sites