LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
complex_number.h File Reference

std::complex<double> as a number type for the generic linear algebra. More...

#include <cmath>
#include <complex>
#include <string>
#include "line/num/number.h"
#include "line/util/lu.h"
Include dependency graph for complex_number.h:

Go to the source code of this file.

Classes

struct  line::num_traits< Complex >
struct  line::pivot_mag< std::complex< R > >
 Partial pivoting compares moduli, since the complex field is unordered. More...

Namespaces

namespace  line

Typedefs

using line::Complex = std::complex<double>

Detailed Description

std::complex<double> as a number type for the generic linear algebra.

WHY THIS EXISTS. One algorithm in the port needs complex arithmetic: the Laplace-domain transient QBD (mam_transient2, mam_transient2_open), whose level blocks are shifted by -s I at a COMPLEX quadrature node s and whose fundamental matrices G and R are therefore complex. Everything it needs – products, identity, inverse, integer powers, LU with partial pivoting – already exists in util/linalg.h and util/lu.h templated on the element type, so declaring the traits here makes the whole stack available at complex argument instead of duplicating it.

WHAT IS DELIBERATELY NARROW. to_double returns the REAL PART, because the only consumer is a Laplace inversion whose quadrature sums Re(eta_k F(s_k)) and discards the imaginary part by construction. log_as_double is the log of the MODULUS. Neither is a faithful "convert to double"; both are the meaning the transient QBD needs, and no other algorithm instantiates this type. Do not reach for it as a general complex facility without revisiting those two.

is_exact is false and has_transcendental is true, so any algorithm gated on exact arithmetic refuses at complex argument, as it should.

Definition in file complex_number.h.