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

Cartesian 1D point. More...

#include <cartesian.hpp>

Public Member Functions

 PointCartesian1D ()
 Initialize point in the 1D cartesian space with coordinates (0, 0).
 PointCartesian1D (double x)
 Initialize point in the 1D cartesian space with coordinate x as specified by the parameters.
 PointCartesian1D (PointCartesian1D_t *initial_point, unsigned int initial_id=0)
 Initialize point in the 1D cartesian space from a ViennaGrid point by pointing at it.
 PointCartesian1D (PointCartesian1D_t &initial_point, unsigned int initial_id=-1)
 Initialize point in the 1D 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).
void set_coord (unsigned int index, double new_value)
 Set the coordinate at given index (0 for x).
list get_coord_list ()
 Get coordinates as a Python list.
PointCartesian1Doperator= (const PointCartesian1D &other)
 Assignment operator that copies the coordinates of the right operand to the left operand.
PointCartesian1D operator+ (const PointCartesian1D &other)
 Addition operator which adds two points coordinate by coordinate.
PointCartesian1D operator- (const PointCartesian1D &other)
 Subtraction operator which subtracts two points coordinate by coordinate.
PointCartesian1D operator* (const double factor)
 Multiplication operator which multiplies a point and a scalar (real) number, coordinate by coordinate.
PointCartesian1D operator/ (const double factor)
 Division operator which divides a point and a scalar (real) number, coordinate by coordinate.
PointCartesian1D operator- ()
 Unary operator which inverts the coordinates of a point.
PointCartesian1D_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.
double inner_prod (PointCartesian1D &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 1D point.

Since
0.1.0

Constructor & Destructor Documentation

PointCartesian1D::PointCartesian1D ( )

Initialize point in the 1D 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
PointCartesian1D::PointCartesian1D ( double  x)

Initialize point in the 1D cartesian space with coordinate x 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
PointCartesian1D::PointCartesian1D ( PointCartesian1D_t *  initial_point,
unsigned int  initial_id = 0 
)

Initialize point in the 1D 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
PointCartesian1D::PointCartesian1D ( PointCartesian1D_t &  initial_point,
unsigned int  initial_id = -1 
)

Initialize point in the 1D 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 PointCartesian1D::get_coord ( unsigned int  index)

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

Since
0.1.0
list PointCartesian1D::get_coord_list ( )

Get coordinates as a Python list.

Since
0.1.0
const char * PointCartesian1D::get_coord_system ( )

Get the name of the coordinate system.

For cartesian points, this always returns 'cartesian'.

Since
0.1.0
size_t PointCartesian1D::get_dimension ( )

Get the dimension of the point.

For 1D points, this always returns 1.

Since
0.1.0
unsigned int PointCartesian1D::get_id ( )

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

Since
0.1.0
PointCartesian1D_t & PointCartesian1D::get_point ( )

Get ViennaGrid point.

Since
0.1.0
double PointCartesian1D::inner_prod ( PointCartesian1D other)

Calculate the dot product of two points.

Since
0.1.0
double PointCartesian1D::norm_1 ( )

Calculate the 1-norm of the point.

Since
0.1.0
double PointCartesian1D::norm_2 ( )

Calculate the 2-norm of the point.

Since
0.1.0
double PointCartesian1D::norm_inf ( )

Calculate the ∞-norm of the point.

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

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

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

Addition operator which adds two points coordinate by coordinate.

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

Subtraction operator which subtracts two points coordinate by coordinate.

Since
0.1.0
PointCartesian1D PointCartesian1D::operator- ( )

Unary operator which inverts the coordinates of a point.

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

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

Since
0.1.0
PointCartesian1D & PointCartesian1D::operator= ( const PointCartesian1D 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 PointCartesian1D::set_coord ( unsigned int  index,
double  new_value 
)

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

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

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

Since
0.1.0

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