normally we use only p=1 or 2. I wrote in this way because compilers may optimize std::pow()  if p=1,2. But I'm not sure. Is std::sqrt faster than std::pow?