21template <
int spacedim,
typename T = real_t>
class GeomPoint
150 std::array<T, spacedim> data_;
155 std::for_each(data_.begin(), data_.end(), [=](
T &
item) { item = val; });
158template <
int spacedim,
typename T>
159template <
typename Container>
162 for (
uint_t i = 0;
i < data_.size(); ++
i)
168template <
int spacedim,
typename T>
174 msg +=
"Invalid initialization ";
175 msg +=
" list size for point construction. " + std::to_string(
list.size());
176 msg +=
" not equal to " + std::to_string(
spacedim);
177 throw std::logic_error(
msg);
181 auto end =
list.end();
190template <
int spacedim,
typename T>
195template <
int spacedim,
typename T>
217template <
int spacedim,
typename T>
223 data_[
i] +=
t.data_[
i];
228template <
int spacedim,
typename T>
234 data_[
i] -=
t.data_[
i];
239template <
int spacedim,
typename T>
251template <
int spacedim,
typename T>
255 (*this) *= (
static_cast<T>(1) / factor);
259template <
int spacedim,
typename T>
267 msg +=
"Invalid initialization ";
268 msg +=
" list size for point construction. " + std::to_string(
list.size());
269 msg +=
" not equal to " + std::to_string(
spacedim);
270 throw std::logic_error(
msg);
274 auto end =
list.end();
285template <
int spacedim,
typename T>
291 data_[
i] += p.data_[
i] * factor;
320template <
int spacedim,
typename T>
329 sum += (data_[
i] - data[
i]) * (data_[
i] - data[
i]);
331 return std::sqrt(sum);
334template <
int spacedim,
typename T>
347 std::for_each(data_.begin(), data_.end(), [&](
const T &
value) { result += value * value; });
352template <
int spacedim,
typename T>
372template <
int spacedim,
typename T>
395 std::string
rslt(
"");
396 auto end = data_.begin();
398 std::for_each(data_.begin(), end,
401 rslt += std::to_string(value);
412template <
int spacedim,
typename T>
420template <
int spacedim,
typename T>
427template <
int spacedim,
typename T>
431 auto data =
t.data();
441template <
int spacedim,
typename T>
447 data[
i] = std::abs(data[
i]);
453template <
int spacedim,
typename T>
460template <
int spacedim,
typename T>
467template <
int spacedim,
typename T>
474template <
int spacedim,
typename T>
482template <
int spacedim,
typename T>
489template <
int spacedim,
typename T>
506template <
int spacedim,
typename T>
A class that describes a point with spacedim spatial dimension space.
Definition geom_point.h:22
T min() const
Get the min element in the point.
Definition geom_point.h:307
static const int dimension
dimension. Spatial dimension of the point
Definition geom_point.h:33
T distance(const GeomPoint &) const
Get the distance from the given point.
Definition geom_point.h:321
T entry(uint_t i) const
access the i-th coordinate of the point read-only
Definition geom_point.h:104
GeomPoint & operator-=(const GeomPoint &)
\detailed Subtract another tensor.
Definition geom_point.h:229
void scale(T factor)
scale with a given factor
T value_type
value_type. The type of the coordinates
Definition geom_point.h:28
T & operator[](uint_t i)
Access the i-th coordinate of the point.
Definition geom_point.h:207
virtual ~GeomPoint()
dtor
Definition geom_point.h:57
GeomPoint & operator+=(const GeomPoint &)
Add another vector, i.e. move this point by the given offset.
Definition geom_point.h:218
auto coordinates() const
Get a copy of the data of this object.
Definition geom_point.h:107
GeomPoint & operator/=(T factor)
Scale the vector by factor.
Definition geom_point.h:252
T dot(const GeomPoint &other) const
Returns the dot product of this point and the given point.
Definition geom_point.h:353
GeomPoint & operator=(const GeomPoint &t)
copy assignement operator
Definition geom_point.h:196
GeomPoint(T val=T())
ctor all dim data are assigned the given value
Definition geom_point.h:153
T L2_norm() const
Return the distance from the origin.
Definition geom_point.h:125
T operator[](uint_t i) const
Access the i-th coordinate of the point read-only.
Definition geom_point.h:212
T max() const
Get the max element in the point.
Definition geom_point.h:295
GeomPoint(const GeomPoint &t)
copy ctor
Definition geom_point.h:191
const std::string to_string() const
Returns string representation of the point.
Definition geom_point.h:392
void add_scaled(const GeomPoint &p, T factor)
Add the coordinates of the given point to this scaled by factor.
Definition geom_point.h:286
GeomPoint & operator*=(T factor)
Scale the point by factor.
Definition geom_point.h:240
GeomPoint(const std::initializer_list< T > &list)
Construct given an initializer_list.
Definition geom_point.h:169
GeomPoint & operator=(const std::initializer_list< T > &list)
operator = Assign from the initializer list
Definition geom_point.h:261
T square_sum() const
Returns the square sum of the compontents.
Definition geom_point.h:343
void scale(const std::vector< T > &factors)
scale this object by the given factors p factors should have size at least spacedim
Definition geom_point.h:335
std::ostream & print_point_info(std::ostream &out) const
print the point
Definition geom_point.h:373
GeomPoint(const Container &data)
Create by passing a vector of data.
Definition geom_point.h:160
void zero()
Zero the entries of the tensor.
Definition geom_point.h:366
std::ostream & operator<<(std::ostream &out, const GeomPoint< spacedim, T > &p)
free functions that work on the GeomPoint<spacedim,T> class
Definition geom_point.h:413
bool operator==(const GeomPoint< spacedim, T > &t1, const GeomPoint< spacedim, T > &t2)
Definition geom_point.h:490
const GeomPoint< spacedim, T > operator*(T factor, const GeomPoint< spacedim, T > &t)
Allow multiplication from left with a factor.
Definition geom_point.h:454
const GeomPoint< spacedim, T > abs(const GeomPoint< spacedim, T > &t)
Return a point having the absolute values of the given point object.
Definition geom_point.h:442
const GeomPoint< spacedim, T > operator/(const GeomPoint< spacedim, T > &t, T factor)
Definition geom_point.h:468
bool operator!=(const GeomPoint< spacedim, T > &t1, const GeomPoint< spacedim, T > &t2)
Definition geom_point.h:507
const GeomPoint< spacedim, T > operator+(const GeomPoint< spacedim, T > &t1, const GeomPoint< spacedim, T > &t2)
Definition geom_point.h:475
const GeomPoint< spacedim, T > operator-(const GeomPoint< spacedim, T > &t1, const GeomPoint< spacedim, T > &t2)
Definition geom_point.h:483
const GeomPoint< spacedim, T > scale(const GeomPoint< spacedim, T > &t, T factor)
scale the given point by facto and returns a copyr. This function does not change the entries of t.
Definition geom_point.h:421
OutT resolve(const std::string &name, const std::map< std::string, std::any > &input)
Definition std_map_utils.h:25
Definition bitrl_consts.h:14
std::size_t uint_t
uint_t
Definition bitrl_types.h:43