Building a maths library (c++)

Started by
0 comments, last by Drath 21 years, 1 month ago
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);
Advertisement
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

This topic is closed to new replies.

Advertisement