GY-63_MS5611/libraries/Complex/complex.h

120 lines
2.1 KiB
C
Raw Normal View History

2013-09-29 08:16:03 -04:00
//
2013-09-29 08:13:36 -04:00
// FILE: Complex.h
// AUTHOR: Rob Tillaart
// VERSION: see COMPLEX_LIB_VERSION
// PURPOSE: library for Complex math for Arduino
// URL: http://arduino.cc/playground/Main/ComplexMath
2013-09-29 08:16:03 -04:00
//
2013-09-29 08:13:36 -04:00
// Released to the public domain
//
#ifndef Complex_h
#define Complex_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#define COMPLEX_LIB_VERSION "0.1.04"
// five categories of functions can be switched per category
// by (un)commenting next lines.
// #define COMPLEX_EXTENDED
// #define COMPLEX_GONIO_1
// #define COMPLEX_GONIO_2
// #define COMPLEX_GONIO_3
// #define COMPLEX_GONIO_4
2013-09-29 08:13:36 -04:00
2013-09-29 08:16:03 -04:00
class Complex
2013-09-29 08:13:36 -04:00
{
public:
Complex(double, double);
Complex(const Complex &);
Complex(double);
2013-09-29 08:16:03 -04:00
void set(double, double);
2013-09-29 08:13:36 -04:00
double real();
double imag();
2013-09-29 08:16:03 -04:00
void polar(double, double);
2013-09-29 08:13:36 -04:00
double phase();
2013-09-29 08:16:03 -04:00
double modulus();
2013-09-29 08:13:36 -04:00
Complex conjugate();
Complex reciprocal();
2013-09-29 08:16:03 -04:00
bool operator == (Complex);
bool operator != (Complex);
Complex operator - (); // negation
2013-09-29 08:13:36 -04:00
Complex operator + (Complex);
Complex operator - (Complex);
Complex operator * (Complex);
Complex operator / (Complex);
// #ifdef COMPLEX_BASIC_II
2013-09-29 08:16:03 -04:00
void operator += (Complex);
void operator -= (Complex);
void operator *= (Complex);
void operator /= (Complex);
// #endif
2013-09-29 08:16:03 -04:00
#ifdef COMPLEX_EXTENDED
2013-09-29 08:16:03 -04:00
Complex c_sqrt();
Complex c_sqr();
2013-09-29 08:13:36 -04:00
Complex c_exp();
2013-09-29 08:16:03 -04:00
Complex c_log();
Complex c_log10();
Complex c_pow(Complex);
Complex c_logn(Complex);
#endif
2013-09-29 08:16:03 -04:00
#ifdef COMPLEX_GONIO_1
2013-09-29 08:13:36 -04:00
Complex c_sin();
Complex c_cos();
Complex c_tan();
2013-09-29 08:16:03 -04:00
Complex c_asin();
Complex c_acos();
Complex c_atan();
#endif
2013-09-29 08:16:03 -04:00
#ifdef COMPLEX_GONIO_2
2013-09-29 08:16:03 -04:00
Complex c_csc();
Complex c_sec();
Complex c_cot();
Complex c_acsc();
Complex c_asec();
Complex c_acot();
#endif
2013-09-29 08:16:03 -04:00
#ifdef COMPLEX_GONIO_3
2013-09-29 08:16:03 -04:00
Complex c_sinh();
Complex c_cosh();
Complex c_tanh();
Complex c_asinh();
Complex c_acosh();
Complex c_atanh();
#endif
2013-09-29 08:16:03 -04:00
#ifdef COMPLEX_GONIO_4
2013-09-29 08:16:03 -04:00
Complex c_csch();
Complex c_sech();
Complex c_coth();
Complex c_acsch();
Complex c_asech();
Complex c_acoth();
#endif
2013-09-29 08:16:03 -04:00
2013-09-29 08:13:36 -04:00
private:
double re;
double im;
2013-09-29 08:16:03 -04:00
Complex gonioHelper1(int);
Complex gonioHelper2(int);
2013-09-29 08:13:36 -04:00
};
2013-09-29 08:13:36 -04:00
#endif
// --- END OF FILE ---