next up previous contents
Next: I() Up: ``pvector'' class Previous: sum()

operator-(), operator*()

friend pvector operator-(const pvector& in1,const pvector& in2);
friend pvector operator*(Complex c,const pvector& in1);
friend pvector operator*(const pvector& in1,Complex c);

Return value:

Input:

Using the code provided for operator+() as a guide, write functions of the above prototype, again placing them within the definition of the pvector class. These are the functions that the compiler actually calls when it sees expressions like ``4.*rho+phi'' involving pvectors rho and phi. Note that you need to write two routines for multiplication, one for c*in1 and the other for in1*c because, from a compiler point of view, these really are distinct operations. Debug by uncommenting the tests for subtraction, scalar-pvector products and the algebra of the inner product.



Tomas Arias
Mon Apr 8 17:11:28 EDT 2002