ddg.geometry.geometries module
- class ddg.geometry.geometries.Geometry(name=None, dimension=None, dimension_offset=None)[source]
Bases:
objectBasic geometry class.
Predefined geometries and geometries that are named upon initialization can be retrieved with get_geometry.
- Parameters:
- namestr (default=None)
Name of the geometry. Note that geometries can only be retrieved with get_geometry, if its name is not None.
- dimensionint (default=None)
Dimension of the geometry. This is the ambient dimension of the space the model for the geometry lives in.
- dimension_offsetint (default=None)
Offset to subtract from
dimensionto get the ‘interpreted’ dimension. For example, Möbius geometry has an offset of 1: The model space of n-dimensional Möbius geometry is an n-dimensional quadric surface in (n+1)-dimensional space.
See also
- Attributes:
- namestr
Name of the geometry.
- dimensionint
Dimension of the geometry.
- dimension_offsetint
- name_dimensionint
Equal to dimension - dimension_offset.
Methods
set_alias(name[, overwrite])Set alias for geometry.
- dimension_offset = 0
Dimension offset, see above.
This will be overwritten if a
dimension_offsetis passed to a geometry upon creation.
- class ddg.geometry.geometries.ProjectiveGeometry(name='projective', dimension=None, dimension_offset=None, is_dual=False)[source]
Bases:
GeometryProjective geometry class.
Describes an n-dimensional projective space (or its dual space).
- Parameters:
- namestr (default=None)
Name of the geometry. Note that geometries can only be retrieved with get_geometry, if its name is not None.
- dimensionint (default=None)
Dimension of the projective space.
- is_dualbool (default=False)
Indicates whether the geometry describes the primal or dual projective space.
See also
- Attributes:
- namestr
Name of the geometry.
- dimensionint
Dimension of the projective space.
- is_dualbool
True if geometry is dual, else False.
- dualProjectiveGeometry
The dual geometry.
Methods
set_alias(name[, overwrite])Set alias for geometry.
- set_alias(name, overwrite=False)[source]
Set alias for geometry.
A geometry can also be retrieved by its alias using get_geometry.
- Parameters:
- namestr
New alias for the geometry.
- overwritebool (default=False)
If set to True, the internal name of the geometry will be overwritten.
- dimension_offset = 0
Dimension offset, see above.
This will be overwritten if a
dimension_offsetis passed to a geometry upon creation.
- class ddg.geometry.geometries.CayleyKleinGeometry(quadric, name=None, dimension=None, is_dual=False)[source]
Bases:
ProjectiveGeometryCayley-Klein geometry class.
Describes an n-dimensional Cayley-Klein space using an absolute quadric, or a (pseudo-)conformal geometry on that quadric.
- Parameters:
- namestr (default=None)
Name of the geometry. Note that geometries can only be retrieved with get_geometry, if its name is not None.
- dimensionint (default=None)
Dimension of the projective space. This is the ambient dimension of the absolute quadric.
- is_dualbool (default=False)
Indicates whether the geometry describes the primal or dual projective space.
- quadricddg.Quadric, numpy.array, callable
Absolute quadric of the geometry. When given as an array it is taken as the symmetric matrix of the absolute quadric. When given as a callable inner product, the parameter dimension becomes mandatory.
See also
- Attributes:
- namestr
Name of the geometry.
- dimensionint
Dimension of the projective space. This is the ambient dimension of the absolute quadric.
- is_dualbool
True if geometry is dual, else False
- dualCayleyKleinGeometry
The dual geometry.
Methods
set_alias(name[, overwrite])Set alias for geometry.
inner_product(v, w)Inner product induced by the absolute quadric.
d(v, w)Distance function.
- metric_to_cayley_klein_distance(d)[source]
Return Metric distance converted to Cayley-Klein “distance”.
- Parameters:
- dfloat
- Returns:
- Kfloat
- cayley_klein_distance_to_metric(K)[source]
Return Cayley-Klein distance converted to actual metric distance.
- Parameters:
- Kfloat
- Returns:
- dfloat
- d(v, w)[source]
Distance function.
The default implementation attempts to use
cayley_klein_distance_to_metric(an abstract method) to convert the Cayley-Klein distance, wich is always defined in the same way, to a metric distance.- Parameters:
- v, wnumpy.ndarray or Point
Homogeneous coordinate vectors or Point instances. Both points must be either inside or outside the absolute quadric.
- Returns:
- float
- dimension_offset = 0
Dimension offset, see above.
This will be overwritten if a
dimension_offsetis passed to a geometry upon creation.
- set_alias(name, overwrite=False)
Set alias for geometry.
A geometry can also be retrieved by its alias using get_geometry.
- Parameters:
- namestr
New alias for the geometry.
- overwritebool (default=False)
If set to True, the internal name of the geometry will be overwritten.
- class ddg.geometry.geometries.EllipticGeometry(dimension, is_dual=False)[source]
Bases:
CayleyKleinGeometryElliptic geometry class.
- Parameters:
- dimensionint
Dimension of the geometry.
- is_dualbool (default=False)
Whether geometry is dual or not.
See also
- Attributes:
- dimensionint
Dimension of the geometry. This is the dimension of the model itself.
- is_dualbool
True if geometry is dual, else False
- dualEllipticGeometry
The dual geometry.
Methods
set_alias(name[, overwrite])Set alias for geometry.
inner_product(v, w)Inner product induced by the absolute quadric.
- metric_to_cayley_klein_distance(d)[source]
Return Metric distance converted to Cayley-Klein “distance”.
K = cos(d) ** 2
- Parameters:
- dfloat
- Returns:
- Kfloat
- cayley_klein_distance_to_metric(K)[source]
Return Cayley-Klein distance converted to metric distance.
d is given by the equation
K = cos(d) ** 2
- Parameters:
- dfloat
- Returns:
- Kfloat
- cayley_klein_distance(v, w)
Cayley-Klein “distance” induced by the absolute quadric.
- d(v, w)
Distance function.
The default implementation attempts to use
cayley_klein_distance_to_metric(an abstract method) to convert the Cayley-Klein distance, wich is always defined in the same way, to a metric distance.- Parameters:
- v, wnumpy.ndarray or Point
Homogeneous coordinate vectors or Point instances. Both points must be either inside or outside the absolute quadric.
- Returns:
- float
- dimension_offset = 0
Dimension offset, see above.
This will be overwritten if a
dimension_offsetis passed to a geometry upon creation.
- inner_product(v, w)
Inner product induced by the absolute quadric.
- set_alias(name, overwrite=False)
Set alias for geometry.
A geometry can also be retrieved by its alias using get_geometry.
- Parameters:
- namestr
New alias for the geometry.
- overwritebool (default=False)
If set to True, the internal name of the geometry will be overwritten.
- class ddg.geometry.geometries.EuclideanGeometry(dimension, is_dual=False, affine_component=-1)[source]
Bases:
CayleyKleinGeometryEuclidean geometry class.
- Parameters:
- dimensionint
Dimension of the geometry.
- is_dualbool (default=False)
Whether geometry is dual or not.
See also
- Attributes:
- namestr
Name of the geometry.
- dimensionint
Dimension of the geometry. This is the dimension of the model itself.
- is_dualbool
True if geometry is dual, else False
- dualEuclideanGeometry
The dual geometry.
Methods
set_alias(name[, overwrite])Set alias for geometry.
inner_product(v, w)Inner product induced by the absolute quadric.
- d(x, y)[source]
Euclidean distance.
Dehomogenizes by
self.affine_componentand computes the norm of the difference ofxandy.Note that the
affine_componentattribute ofPointobjects is ignored.- Parameters:
- x, yPoint or array_like of shape (dimension+1,)
- Returns:
- float
- cayley_klein_distance(v, w)
Cayley-Klein “distance” induced by the absolute quadric.
- cayley_klein_distance_to_metric(K)
Return Cayley-Klein distance converted to actual metric distance.
- Parameters:
- Kfloat
- Returns:
- dfloat
- dimension_offset = 0
Dimension offset, see above.
This will be overwritten if a
dimension_offsetis passed to a geometry upon creation.
- inner_product(v, w)
Inner product induced by the absolute quadric.
- metric_to_cayley_klein_distance(d)
Return Metric distance converted to Cayley-Klein “distance”.
- Parameters:
- dfloat
- Returns:
- Kfloat
- set_alias(name, overwrite=False)
Set alias for geometry.
A geometry can also be retrieved by its alias using get_geometry.
- Parameters:
- namestr
New alias for the geometry.
- overwritebool (default=False)
If set to True, the internal name of the geometry will be overwritten.
- class ddg.geometry.geometries.HyperbolicGeometry(dimension, is_dual=False)[source]
Bases:
CayleyKleinGeometryHyperbolic geometry class.
- Parameters:
- dimensionint
Dimension of the geometry.
- is_dualbool (default=False)
Whether geometry is dual or not.
See also
- Attributes:
- namestr
Name of the geometry.
- dimensionint
Dimension of the geometry. This is the dimension of the model itself.
- is_dualbool
True if geometry is dual, else False
- dualHyperbolicGeometry
The dual geometry.
Methods
set_alias(name[, overwrite])Set alias for geometry.
inner_product(v, w)Inner product induced by the absolute quadric.
- metric_to_cayley_klein_distance(d)[source]
Return Metric distance converted to Cayley-Klein “distance”.
K = cosh(d) ** 2
- Parameters:
- dfloat
- Returns:
- Kfloat
- cayley_klein_distance_to_metric(K)[source]
Return Cayley-Klein distance converted to metric distance.
d is given by the equation.
K = cosh(d) ** 2
- Parameters:
- dfloat
- Returns:
- Kfloat
- cayley_klein_distance(v, w)
Cayley-Klein “distance” induced by the absolute quadric.
- d(v, w)
Distance function.
The default implementation attempts to use
cayley_klein_distance_to_metric(an abstract method) to convert the Cayley-Klein distance, wich is always defined in the same way, to a metric distance.- Parameters:
- v, wnumpy.ndarray or Point
Homogeneous coordinate vectors or Point instances. Both points must be either inside or outside the absolute quadric.
- Returns:
- float
- dimension_offset = 0
Dimension offset, see above.
This will be overwritten if a
dimension_offsetis passed to a geometry upon creation.
- inner_product(v, w)
Inner product induced by the absolute quadric.
- set_alias(name, overwrite=False)
Set alias for geometry.
A geometry can also be retrieved by its alias using get_geometry.
- Parameters:
- namestr
New alias for the geometry.
- overwritebool (default=False)
If set to True, the internal name of the geometry will be overwritten.
- class ddg.geometry.geometries.LaguerreGeometry(dimension, is_dual=False)[source]
Bases:
CayleyKleinGeometryLaguerre geometry class.
- Parameters:
- dimensionint
Dimension of the geometry.
- is_dualbool (default=False)
Whether geometry is dual or not.
See also
- Attributes:
- namestr
Name of the geometry.
- dimensionint
Dimension of the geometry. This is the dimension of the model itself.
- is_dualbool
True if geometry is dual, else False
- dualLaguerreGeometry
The dual geometry.
Methods
set_alias(name[, overwrite])Set alias for geometry.
inner_product(v, w)Inner product induced by the absolute quadric.
- dimension_offset = 1
Dimension offset, see above.
This will be overwritten if a
dimension_offsetis passed to a geometry upon creation.
- cayley_klein_distance(v, w)
Cayley-Klein “distance” induced by the absolute quadric.
- cayley_klein_distance_to_metric(K)
Return Cayley-Klein distance converted to actual metric distance.
- Parameters:
- Kfloat
- Returns:
- dfloat
- d(v, w)
Distance function.
The default implementation attempts to use
cayley_klein_distance_to_metric(an abstract method) to convert the Cayley-Klein distance, wich is always defined in the same way, to a metric distance.- Parameters:
- v, wnumpy.ndarray or Point
Homogeneous coordinate vectors or Point instances. Both points must be either inside or outside the absolute quadric.
- Returns:
- float
- inner_product(v, w)
Inner product induced by the absolute quadric.
- metric_to_cayley_klein_distance(d)
Return Metric distance converted to Cayley-Klein “distance”.
- Parameters:
- dfloat
- Returns:
- Kfloat
- set_alias(name, overwrite=False)
Set alias for geometry.
A geometry can also be retrieved by its alias using get_geometry.
- Parameters:
- namestr
New alias for the geometry.
- overwritebool (default=False)
If set to True, the internal name of the geometry will be overwritten.
- class ddg.geometry.geometries.LieGeometry(dimension, is_dual=False)[source]
Bases:
CayleyKleinGeometryElliptic geometry class.
- Parameters:
- dimensionint
Dimension of the geometry.
- is_dualbool (default=False)
Whether geometry is dual or not.
See also
- Attributes:
- namestr
Name of the geometry.
- dimensionint
Dimension of the geometry. This is the dimension of the model itself.
- is_dualbool
True if geometry is dual, else False
- dualLieGeometry
The dual geometry.
Methods
set_alias(name[, overwrite])Set alias for geometry.
inner_product(v, w)Inner product induced by the absolute quadric.
- dimension_offset = 2
Dimension offset, see above.
This will be overwritten if a
dimension_offsetis passed to a geometry upon creation.
- cayley_klein_distance(v, w)
Cayley-Klein “distance” induced by the absolute quadric.
- cayley_klein_distance_to_metric(K)
Return Cayley-Klein distance converted to actual metric distance.
- Parameters:
- Kfloat
- Returns:
- dfloat
- d(v, w)
Distance function.
The default implementation attempts to use
cayley_klein_distance_to_metric(an abstract method) to convert the Cayley-Klein distance, wich is always defined in the same way, to a metric distance.- Parameters:
- v, wnumpy.ndarray or Point
Homogeneous coordinate vectors or Point instances. Both points must be either inside or outside the absolute quadric.
- Returns:
- float
- inner_product(v, w)
Inner product induced by the absolute quadric.
- metric_to_cayley_klein_distance(d)
Return Metric distance converted to Cayley-Klein “distance”.
- Parameters:
- dfloat
- Returns:
- Kfloat
- set_alias(name, overwrite=False)
Set alias for geometry.
A geometry can also be retrieved by its alias using get_geometry.
- Parameters:
- namestr
New alias for the geometry.
- overwritebool (default=False)
If set to True, the internal name of the geometry will be overwritten.
- class ddg.geometry.geometries.MoebiusGeometry(dimension, is_dual=False)[source]
Bases:
CayleyKleinGeometryMoebius geometry class.
- Parameters:
- dimensionint
Dimension of the geometry.
- is_dualbool (default=False)
Whether geometry is dual or not.
See also
- Attributes:
- namestr
Name of the geometry.
- dimensionint
Dimension of the geometry. This is the dimension of the model itself.
- is_dualbool
True if geometry is dual, else False
- dualMoebiusGeometry
The dual geometry.
Methods
set_alias(name[, overwrite])Set alias for geometry.
inner_product(v, w)Inner product induced by the absolute quadric.
- dimension_offset = 1
Dimension offset, see above.
This will be overwritten if a
dimension_offsetis passed to a geometry upon creation.
- cayley_klein_distance(v, w)
Cayley-Klein “distance” induced by the absolute quadric.
- cayley_klein_distance_to_metric(K)
Return Cayley-Klein distance converted to actual metric distance.
- Parameters:
- Kfloat
- Returns:
- dfloat
- d(v, w)
Distance function.
The default implementation attempts to use
cayley_klein_distance_to_metric(an abstract method) to convert the Cayley-Klein distance, wich is always defined in the same way, to a metric distance.- Parameters:
- v, wnumpy.ndarray or Point
Homogeneous coordinate vectors or Point instances. Both points must be either inside or outside the absolute quadric.
- Returns:
- float
- inner_product(v, w)
Inner product induced by the absolute quadric.
- metric_to_cayley_klein_distance(d)
Return Metric distance converted to Cayley-Klein “distance”.
- Parameters:
- dfloat
- Returns:
- Kfloat
- set_alias(name, overwrite=False)
Set alias for geometry.
A geometry can also be retrieved by its alias using get_geometry.
- Parameters:
- namestr
New alias for the geometry.
- overwritebool (default=False)
If set to True, the internal name of the geometry will be overwritten.
- ddg.geometry.geometries.get_geometry(name, dimension=None)[source]
Retrieve a geometry.
Geometries can only be retrieved, if they are named upon initialization, or are one of the predefined geometries (elliptic, hyperbolic, laguerre, moebius, euclicean and lie).
- Parameters:
- namestr
Name of the geometry
- dimensionint (default=None)
Dimension of the geometry. This should be the model dimension.
- Returns:
- ddg.Geometry
- Raises:
- KeyError
when the geometry could not be found nor created.