The (code) size of a class does not has a (direct) performance consequence.
Also, as long as you don't have or expect performance problems, don't focus on optimization (mostly optimization results in more work, and sometimes more unreadable/maintainable code). Only optimize for performance if needed. Initially, always concentrate on small classes/readability/maintainability. Especially the last seems important since you add regularly functionality.
You already give some function areas, like projection, normalization. Maybe you can move them to other classes, or helper classes if they do not need any data.
Also maybe you can split your classes using inheritance, if there are some specific vector types, or maybe you can use the strategy pattern to perform different types of algorithms. But maybe you just have hundreds of functions you can use on a vector; in this case use helper methods, pass the vector with it and put each method in the best helper class.
like e.g. for normalization:
public abstract VectorNormalization
{
public void Normalize(Vector v)
{
.. do something with v
}
public void NormalizeDifferent(Vector v)
...
}
And you can call it by
Vector v = Vector(3,4);
VectorNormalization.Normalize(v);
About the performance. To call the Normalize function:
- Normally a helper class uses internally a so-called v-table. To call a helper method, the compiler needs to add the v-table start to the function and call it, this is a very negligible performance loss. I think C++ and Python work very similarly.
- In addition the stack needs to be filled with the vector.
- The function call is made.
Only the first will be changed, since in a big class the 2nd and 3th will be needed too.
You can win performance wise probably much more by optimizing the algorithms themselves wherever needed.
Btw,