consteig
Compile-time eigenvalue and eigenvector computation for C++17
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
consteig::Complex< T > Struct Template Reference

Constexpr complex number type. More...

#include <complex.hpp>

Public Member Functions

constexpr Complex (T r=0, T i=0)
 Construct from real and imaginary parts (default: 0 + 0i).
 
constexpr Complex operator+ (const Complex &other) const
 Complex addition.
 
constexpr Complexoperator+= (const Complex &other)
 Complex addition in-place.
 
constexpr Complex operator- (const Complex &other) const
 Complex subtraction.
 
constexpr Complex operator* (const Complex &other) const
 Complex multiplication: (a+bi)(c+di) = (ac-bd) + (ad+bc)i.
 
constexpr Complex operator/ (const Complex &other) const
 Complex division: divides by |other|^2.
 
constexpr bool operator== (const Complex &other) const
 Exact equality (no tolerance). Prefer equalWithin for floats.
 
constexpr bool operator!= (const Complex &other) const
 Inequality.
 

Public Attributes

T real
 Real part.
 
T imag
 Imaginary part.
 

Detailed Description

template<typename T>
struct consteig::Complex< T >

Constexpr complex number type.

A lightweight complex number with no dependency on <complex>. All arithmetic operators and utility functions are constexpr, making it suitable for compile-time computation. Returned by eigenvalues and eigenvectors for complex eigenvalue pairs.

Template Parameters
TFloating-point scalar type for the real and imaginary parts.
constexpr consteig::Complex<double> z{3.0, 4.0}; // 3 + 4i
constexpr double magnitude = consteig::abs(z); // 5.0
constexpr auto zc = consteig::conj(z); // 3 - 4i
constexpr T abs(const T x)
Absolute value of a real number.
Definition abs.hpp:17
constexpr T epsilon()
Machine epsilon for type T.
Definition utilities.hpp:82
Constexpr complex number type.
Definition complex.hpp:26

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