Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
Scalar.Scalar Class Reference

Public Member Functions

 __init__ (self, float re=0.0, float im=0.0)
 
"Scalar" from_complex (cls, complex z)
 
float real (self)
 
float imag (self)
 
float to_double (self)
 
float __float__ (self)
 
complex __complex__ (self)
 
"Scalar" __add__ (self, "Scalar" other)
 
"Scalar" __sub__ (self, "Scalar" other)
 
"Scalar" __mul__ (self, "Scalar" other)
 
"Scalar" __truediv__ (self, "Scalar" other)
 
"Scalar" __neg__ (self)
 
bool __eq__ (self, object other)
 
"Scalar" from_cpp (cls, cpp_obj)
 
str __repr__ (self)
 

Protected Attributes

 _cpp_obj
 

Detailed Description

Python wrapper for the C++ scalar_t class.

scalar_t is an enhanced complex number type that supports real projection,
full arithmetic, and compatibility with Python's numeric types.

Definition at line 7 of file Scalar.py.

Constructor & Destructor Documentation

◆ __init__()

Scalar.Scalar.__init__ (   self,
float   re = 0.0,
float   im = 0.0 
)
Initializes a Scalar from real and imaginary parts.

Args:
    re (float): Real part. Defaults to 0.0.
    im (float): Imaginary part. Defaults to 0.0.

Definition at line 14 of file Scalar.py.

Member Function Documentation

◆ __add__()

"Scalar" Scalar.Scalar.__add__ (   self,
"Scalar"  other 
)

Definition at line 92 of file Scalar.py.

◆ __complex__()

complex Scalar.Scalar.__complex__ (   self)
Casts to Python complex.

Returns:
    complex: Native Python complex value.

Definition at line 84 of file Scalar.py.

◆ __eq__()

bool Scalar.Scalar.__eq__ (   self,
object  other 
)

Definition at line 117 of file Scalar.py.

◆ __float__()

float Scalar.Scalar.__float__ (   self)
Casts to float, calling to_double.

Returns:
    float: Real part.

Definition at line 76 of file Scalar.py.

◆ __mul__()

"Scalar" Scalar.Scalar.__mul__ (   self,
"Scalar"  other 
)

Definition at line 102 of file Scalar.py.

◆ __neg__()

"Scalar" Scalar.Scalar.__neg__ (   self)

Definition at line 112 of file Scalar.py.

◆ __repr__()

str Scalar.Scalar.__repr__ (   self)

Definition at line 129 of file Scalar.py.

◆ __sub__()

"Scalar" Scalar.Scalar.__sub__ (   self,
"Scalar"  other 
)

Definition at line 97 of file Scalar.py.

◆ __truediv__()

"Scalar" Scalar.Scalar.__truediv__ (   self,
"Scalar"  other 
)

Definition at line 107 of file Scalar.py.

◆ from_complex()

"Scalar" Scalar.Scalar.from_complex (   cls,
complex  z 
)
Creates a Scalar from a complex number.

Args:
    z (complex): A Python complex.

Returns:
    Scalar: A wrapped scalar_t.

Definition at line 24 of file Scalar.py.

◆ from_cpp()

"Scalar" Scalar.Scalar.from_cpp (   cls,
  cpp_obj 
)
Wraps an existing C++ scalar_t object.

Definition at line 123 of file Scalar.py.

◆ imag()

float Scalar.Scalar.imag (   self)
Returns the imaginary part.

Supports both bound ``scalar_t.imag()`` and Python ``complex.imag``.

Returns:
    float: Imaginary component.

Definition at line 51 of file Scalar.py.

◆ real()

float Scalar.Scalar.real (   self)
Returns the real part.

``Scalar.from_cpp`` can receive either a bound ``scalar_t`` object or a
native Python ``complex`` depending on the pybind overload that produced
the value.  The C++ object exposes ``real()`` as a method, while Python
complex exposes ``real`` as a float attribute; both forms are supported.

Returns:
    float: Real component.

Definition at line 37 of file Scalar.py.

◆ to_double()

float Scalar.Scalar.to_double (   self)
Casts to float using the real part.

Bound ``scalar_t`` still uses its native ``to_double()`` implementation.
Native Python numbers/complex values use ``real()``.

Returns:
    float: Real part.

Definition at line 62 of file Scalar.py.

Member Data Documentation

◆ _cpp_obj

Scalar.Scalar._cpp_obj
protected

Definition at line 21 of file Scalar.py.


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