ViennaGrid for Python
 All Classes Files Functions Variables
Public Member Functions | List of all members
PointCartesian2D Class Reference

Cartesian 2D point. More...

#include <cartesian.hpp>

Public Member Functions

 PointCartesian2D ()
 Initialize point in the 2D cartesian space with coordinates (0, 0).
 PointCartesian2D (double x, double y)
 Initialize point in the 2D cartesian space with coordinates (x, y) as specified by the parameters.
 PointCartesian2D (PointCartesian2D_t *initial_point, unsigned int initial_id=0)
 Initialize point in the 2D cartesian space from a ViennaGrid point by pointing at it.
 PointCartesian2D (PointCartesian2D_t &initial_point, unsigned int initial_id=-1)
 Initialize point in the 2D cartesian 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.
PointCartesian2Doperator= (const PointCartesian2D &other)
 Assignment operator that copies the coordinates of the right operand to the left operand.
PointCartesian2D operator+ (const PointCartesian2D &other)
 Addition operator which adds two points coordinate by coordinate.
PointCartesian2D operator- (const PointCartesian2D &other)
 Subtraction operator which subtracts two points coordinate by coordinate.
PointCartesian2D operator* (const double factor)
 Multiplication operator which multiplies a point and a scalar (real) number, coordinate by coordinate.
PointCartesian2D operator/ (const double factor)
 Division operator which divides a point and a scalar (real) number, coordinate by coordinate.
PointCartesian2D operator- ()
 Unary operator which inverts the coordinates of a point.
PointCartesian2D_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.
PointPolar2D to_polar ()
 Convert to polar point.
double inner_prod (PointCartesian2D &other)
 Calculate the dot product of two points.
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.

Detailed Description

Cartesian 2D point.

Since
0.1.0

Constructor & Destructor Documentation

PointCartesian2D::PointCartesian2D ( )

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.

Since
0.1.0
PointCartesian2D::PointCartesian2D ( 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.

Since
0.1.0
PointCartesian2D::PointCartesian2D ( PointCartesian2D_t *  initial_point,
unsigned int  initial_id = 0 
)

Initialize point in the 2D cartesian space from a ViennaGrid point by pointing at it.

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.

Since
0.1.0
PointCartesian2D::PointCartesian2D ( PointCartesian2D_t &  initial_point,
unsigned int  initial_id = -1 
)

Initialize point in the 2D cartesian 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.

Since
0.1.0

Member Function Documentation

double PointCartesian2D::get_coord ( unsigned int  index)

Get the coordinate at given index (0 for x, 1 for y).

Since
0.1.0
list PointCartesian2D::get_coord_list ( )

Get coordinates as a Python list.

Since
0.1.0
const char * PointCartesian2D::get_coord_system ( )

Get the name of the coordinate system.

For cartesian points, this always returns 'cartesian'.

Since
0.1.0
size_t PointCartesian2D::get_dimension ( )

Get the dimension of the point.

For 2D points, this always returns 2.

Since
0.1.0
unsigned int PointCartesian2D::get_id ( )

Get ID of the point within the domain it is assigned to (if applicable).

Since
0.1.0
PointCartesian2D_t & PointCartesian2D::get_point ( )

Get ViennaGrid point.

Since
0.1.0
double PointCartesian2D::inner_prod ( PointCartesian2D other)

Calculate the dot product of two points.

Since
0.1.0
double PointCartesian2D::norm_1 ( )

Calculate the 1-norm of the point.

Since
0.1.0
double PointCartesian2D::norm_2 ( )

Calculate the 2-norm of the point.

Since
0.1.0
double PointCartesian2D::norm_inf ( )

Calculate the ∞-norm of the point.

Since
0.1.0
PointCartesian2D PointCartesian2D::operator* ( const double  factor)

Multiplication operator which multiplies a point and a scalar (real) number, coordinate by coordinate.

Since
0.1.0
PointCartesian2D PointCartesian2D::operator+ ( const PointCartesian2D other)

Addition operator which adds two points coordinate by coordinate.

Since
0.1.0
PointCartesian2D PointCartesian2D::operator- ( const PointCartesian2D other)

Subtraction operator which subtracts two points coordinate by coordinate.

Since
0.1.0
PointCartesian2D PointCartesian2D::operator- ( )

Unary operator which inverts the coordinates of a point.

Since
0.1.0
PointCartesian2D PointCartesian2D::operator/ ( const double  factor)

Division operator which divides a point and a scalar (real) number, coordinate by coordinate.

Since
0.1.0
PointCartesian2D & PointCartesian2D::operator= ( const PointCartesian2D other)

Assignment operator that copies the coordinates of the right operand to the left operand.

This operator cannot be wrapped to Python explicitly.

Since
0.1.0
void PointCartesian2D::set_coord ( unsigned int  index,
double  new_value 
)

Set the coordinate at given index (0 for x, 1 for y).

Since
0.1.0
void PointCartesian2D::set_id ( unsigned int  new_id)

Set ID of the point within the domain it is assigned to.

Since
0.1.0
PointPolar2D PointCartesian2D::to_polar ( )

Convert to polar point.

Since
0.1.0

The documentation for this class was generated from the following files: