Polar point. More...
#include <polar.hpp>
Public Member Functions | |
PointPolar2D () | |
Initialize point in the 2D cartesian space with coordinates (0, 0). | |
PointPolar2D (double x, double y) | |
Initialize point in the 2D cartesian space with coordinates (x, y) as specified by the parameters. | |
PointPolar2D (PointPolar_t *initial_point, unsigned int initial_id=0) | |
Initialize point in the polar space from a ViennaGrid point. | |
PointPolar2D (PointPolar_t &initial_point, unsigned int initial_id=-1) | |
Initialize point in the polar space from a ViennaGrid point by copying it. | |
size_t | get_dimension () |
Get the dimension of the point. | |
const char * | get_coord_system () |
Get the name of the coordinate system. | |
double | get_coord (unsigned int index) |
Get the coordinate at given index (0 for x, 1 for y). | |
void | set_coord (unsigned int index, double new_value) |
Set the coordinate at given index (0 for x, 1 for y). | |
list | get_coord_list () |
Get coordinates as a Python list. | |
PointPolar2D & | operator= (const PointPolar2D &other) |
Assignment operator that copies the coordinates of the right operand to the left operand. | |
PointPolar2D | operator+ (const PointPolar2D &other) |
Addition operator which adds two points coordinate by coordinate. | |
PointPolar2D | operator- (const PointPolar2D &other) |
Subtraction operator which subtracts two points coordinate by coordinate. | |
PointPolar2D | operator* (const double factor) |
Multiplication operator which multiplies a point and a scalar (real) number, coordinate by coordinate. | |
PointPolar2D | operator/ (const double factor) |
Division operator which divides a point and a scalar (real) number, coordinate by coordinate. | |
PointPolar2D | operator- () |
Unary operator which inverts the coordinates of a point. | |
PointPolar_t & | get_point () |
Get ViennaGrid point. | |
unsigned int | get_id () |
Get ID of the point within the domain it is assigned to (if applicable). | |
void | set_id (unsigned int new_id) |
Set ID of the point within the domain it is assigned to. | |
PointCartesian2D | to_cartesian () |
Convert to cartesian 2D point. | |
double | norm_1 () |
Calculate the 1-norm of the point. | |
double | norm_2 () |
Calculate the 2-norm of the point. | |
double | norm_inf () |
Calculate the ∞-norm of the point. |
Polar point.
PointPolar2D::PointPolar2D | ( | ) |
Initialize point in the 2D cartesian space with coordinates (0, 0).
This constructor is meant to be used when the programmer creates an instance of the high-level Python point, and allocates memory in the heap for storing the point. As one would normally think, this should be paired with a destructor that frees the allocated memory. However, when we free the memory in the destructor, the program aborts and states that the program tried to perform a double-free.
PointPolar2D::PointPolar2D | ( | double | x, |
double | y | ||
) |
Initialize point in the 2D cartesian space with coordinates (x, y) as specified by the parameters.
This constructor is meant to be used when the programmer creates an instance of the high-level Python point, and allocates memory in the heap for storing the point. As one would normally think, this should be paired with a destructor that frees the allocated memory. However, when we free the memory in the destructor, the program aborts and states that the program tried to perform a double-free.
PointPolar2D::PointPolar2D | ( | PointPolar_t * | initial_point, |
unsigned int | initial_id = 0 |
||
) |
Initialize point in the polar space from a ViennaGrid point.
What this makes is to set the pointer to point to the ViennaGrid point and thus solves the issue caused by the fact that the ViennaGrid point was being copied, thus not being able to get references to the points stored in the domain and thus not being able to modify them.
This constructor is meant to be used by the wrapper code when the programmer tries to get a reference to a point stored in a domain (not when they want to define a point on their own!), and does not allocate memory in the heap, thus elliminating the need for the constructor to free that memory when this constructor has been used. At first, one would think that it should be distinguished in some way when the object has been instantiated using this constructor or any other constructor in order for the destructor to only free when another constructor has been called, not this one. However, we have shown that no freeing action is need at all.
PointPolar2D::PointPolar2D | ( | PointPolar_t & | initial_point, |
unsigned int | initial_id = -1 |
||
) |
Initialize point in the polar space from a ViennaGrid point by copying it.
This constructor is meant to be used by the wrapper code when the programmer runs an algorithm on points. Hence, it needs to allocate memory in the heap for the new ViennaGrid point.
As one would normally think, this should be paired with a destructor that frees the allocated memory. However, when we free the memory in the destructor, the program aborts and states that the program tried to perform a double-free.
double PointPolar2D::get_coord | ( | unsigned int | index | ) |
Get the coordinate at given index (0 for x, 1 for y).
list PointPolar2D::get_coord_list | ( | ) |
Get coordinates as a Python list.
const char * PointPolar2D::get_coord_system | ( | ) |
Get the name of the coordinate system.
For cartesian points, this always returns 'cartesian'.
size_t PointPolar2D::get_dimension | ( | ) |
Get the dimension of the point.
For 2D points, this always returns 2.
unsigned int PointPolar2D::get_id | ( | ) |
Get ID of the point within the domain it is assigned to (if applicable).
PointPolar_t & PointPolar2D::get_point | ( | ) |
Get ViennaGrid point.
double PointPolar2D::norm_1 | ( | ) |
Calculate the 1-norm of the point.
double PointPolar2D::norm_2 | ( | ) |
Calculate the 2-norm of the point.
double PointPolar2D::norm_inf | ( | ) |
Calculate the ∞-norm of the point.
PointPolar2D PointPolar2D::operator* | ( | const double | factor | ) |
Multiplication operator which multiplies a point and a scalar (real) number, coordinate by coordinate.
PointPolar2D PointPolar2D::operator+ | ( | const PointPolar2D & | other | ) |
Addition operator which adds two points coordinate by coordinate.
PointPolar2D PointPolar2D::operator- | ( | const PointPolar2D & | other | ) |
Subtraction operator which subtracts two points coordinate by coordinate.
PointPolar2D PointPolar2D::operator- | ( | ) |
Unary operator which inverts the coordinates of a point.
PointPolar2D PointPolar2D::operator/ | ( | const double | factor | ) |
Division operator which divides a point and a scalar (real) number, coordinate by coordinate.
PointPolar2D & PointPolar2D::operator= | ( | const PointPolar2D & | other | ) |
Assignment operator that copies the coordinates of the right operand to the left operand.
This operator cannot be wrapped to Python explicitly.
void PointPolar2D::set_coord | ( | unsigned int | index, |
double | new_value | ||
) |
Set the coordinate at given index (0 for x, 1 for y).
void PointPolar2D::set_id | ( | unsigned int | new_id | ) |
Set ID of the point within the domain it is assigned to.
PointCartesian2D PointPolar2D::to_cartesian | ( | ) |
Convert to cartesian 2D point.