8 template<
class T,
unsigned D>
18 Point(
const std::vector<U>& x) {
for (
unsigned i = 0; i < D; ++i) data_[i] = x[i]; }
20 T& operator[](
unsigned i) {
return data_[i]; }
21 const T& operator[](
unsigned i)
const {
return data_[i]; }
23 Point& operator+=(
const Point& other) {
for (
unsigned i = 0; i < D; ++i) data_[i] += other.data_[i];
return *
this; }
26 Point& operator-=(
const Point& other) {
for (
unsigned i = 0; i < D; ++i) data_[i] -= other.data_[i];
return *
this; }
29 T norm2()
const { T r = 0;
for (
unsigned i = 0; i < D; ++i) r += data_[i]*data_[i];
return r; }