TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0. More...
#include <array>
#include <cassert>
#include <cmath>
#include <complex>
#include <exception>
#include <iomanip>
#include <iostream>
Go to the source code of this file.
Namespaces | |
namespace | math |
for assert | |
Functions | |
std::array< std::complex< long double >, 2 > | math::quadraticEquation (long double a, long double b, long double c) |
Quadratic equation calculator. | |
void | assertArray (std::array< std::complex< long double >, 2 > input, std::array< std::complex< long double >, 2 > expected, size_t precision=10) |
Asserts an array of complex numbers. | |
static void | test () |
Self-test implementations to test quadraticEquation function. | |
int | main () |
Main function. | |
Calculate quadratic equation with complex roots, i.e. b^2 - 4ac < 0.
@description Calculates any quadratic equation in form ax^2 + bx + c.
Quadratic equation: x = (-b +/- sqrt(b^2 - 4ac)) / 2a
Definition in file quadratic_equations_complex_numbers.cpp.
void assertArray | ( | std::array< std::complex< long double >, 2 > | input, |
std::array< std::complex< long double >, 2 > | expected, | ||
size_t | precision = 10 ) |
Asserts an array of complex numbers.
input | Input array of complex numbers. . |
expected | Expected array of complex numbers. |
precision | Precision to be asserted. Default=10 |
Definition at line 100 of file quadratic_equations_complex_numbers.cpp.
int main | ( | void | ) |
Main function.
Definition at line 186 of file quadratic_equations_complex_numbers.cpp.
|
static |
Self-test implementations to test quadraticEquation function.
Definition at line 122 of file quadratic_equations_complex_numbers.cpp.