KiCad PCB EDA Suite
Loading...
Searching...
No Matches
resistor_substitution_utils.cpp File Reference
#include "resistor_substitution_utils.h"
#include <algorithm>
#include <cmath>
#include <functional>
#include <stdexcept>

Go to the source code of this file.

Classes

class  SolutionCollector
 Helper class that collects solutions and keeps one with the best deviation. More...
 

Functions

bool operator< (const RESISTANCE &aLhs, double aRhs)
 
bool operator< (const RESISTANCE &aLhs, const RESISTANCE &aRhs)
 
static std::string maybeEmbrace (const std::string &aText, char aRequiredSymbol)
 If aText contains aRequiredSymbol as top-level (i.e.
 
static double serialValue (double aR1, double aR2)
 Functions calculating values and text representations of serial and parallel combinations.
 
static double parallelValue (double aR1, double aR2)
 
static RESISTANCE serialResistance (const RESISTANCE &aR1, const RESISTANCE &aR2)
 
static RESISTANCE parallelResistance (const RESISTANCE &aR1, const RESISTANCE &aR2)
 
static RESISTANCE serialResistanceSimple (const RESISTANCE &aR1, const RESISTANCE &aR2)
 
static RESISTANCE parallelResistanceSimple (const RESISTANCE &aR1, const RESISTANCE &aR2)
 
static std::string strValue (double aValue)
 

Function Documentation

◆ maybeEmbrace()

static std::string maybeEmbrace ( const std::string &  aText,
char  aRequiredSymbol 
)
static

If aText contains aRequiredSymbol as top-level (i.e.

not in parentheses) operator, return aText enclosed in parentheses. Otherwise, return aText unmodified.

Definition at line 113 of file resistor_substitution_utils.cpp.

Referenced by parallelResistance(), and serialResistance().

◆ operator<() [1/2]

bool operator< ( const RESISTANCE aLhs,
const RESISTANCE aRhs 
)

Definition at line 40 of file resistor_substitution_utils.cpp.

References RESISTANCE::value.

◆ operator<() [2/2]

bool operator< ( const RESISTANCE aLhs,
double  aRhs 
)

Definition at line 35 of file resistor_substitution_utils.cpp.

References RESISTANCE::value.

◆ parallelResistance()

static RESISTANCE parallelResistance ( const RESISTANCE aR1,
const RESISTANCE aR2 
)
inlinestatic

◆ parallelResistanceSimple()

static RESISTANCE parallelResistanceSimple ( const RESISTANCE aR1,
const RESISTANCE aR2 
)
inlinestatic

◆ parallelValue()

static double parallelValue ( double  aR1,
double  aR2 
)
inlinestatic

◆ serialResistance()

static RESISTANCE serialResistance ( const RESISTANCE aR1,
const RESISTANCE aR2 
)
inlinestatic

◆ serialResistanceSimple()

static RESISTANCE serialResistanceSimple ( const RESISTANCE aR1,
const RESISTANCE aR2 
)
inlinestatic

◆ serialValue()

static double serialValue ( double  aR1,
double  aR2 
)
inlinestatic

Functions calculating values and text representations of serial and parallel combinations.

Functions marked as 'Simple' do not care about parentheses, which makes them faster.

Definition at line 142 of file resistor_substitution_utils.cpp.

Referenced by RES_EQUIV_CALC::calculate3RSolution(), RES_EQUIV_CALC::calculate4RSolution(), serialResistance(), and serialResistanceSimple().

◆ strValue()