I am using the method described in the article for explicit template instantiation in a separate .cpp file with my class declaration in a .h file. Here is the description of the class:
However, still, the compiler complains that there is no definition for the function 'operator*' that takes (double, vector<1>) or (double, vector<2>) or (double, vector<3>) as arguments. I need this feature to be present. Any help will be appreciated.
You need to move that function definition to the header file and make it inline.
Template functions are generated on the fly. If the definition of a methid isn't seen, the compiler doesn't generate code for it. Templates, at first glance, appear to be different in this regard.
In the above code, the line where I have g*(mass*tstep/GSL_CONST_MKSA_PLANCKS_CONSTANT_HBAR) works fine, but the line with 0.5*a*(tstep*tstep)) doesn't work. This is the functionality I am trying to achieve using the friend function. Of course, I could cut the crap and simply divide by 2, which is what I do to let it compile and let me work go on, but I wonder what happened to the function I wrote and would like to have all features enabled.