What p norms are really required? A general implementation have to cover every case and can not be optimized very good. For example in case of p=1 the std::pow in line 34 and line 35 can be ommited. If p=2 the std::pow in line 35 can be substituted by sqrt.