mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.3.2 Complex
This commit is contained in:
parent
c8c9f1177a
commit
1ca93bdfa0
@ -1,3 +1,18 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
@ -8,4 +23,6 @@ compile:
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
||||
|
65
libraries/Complex/CHANGELOG.md
Normal file
65
libraries/Complex/CHANGELOG.md
Normal file
@ -0,0 +1,65 @@
|
||||
# Change Log Complex
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.3.2] - 2022-10-29
|
||||
- add changelog.md
|
||||
- add rp2040 to build-CI
|
||||
- minor edit unit test
|
||||
|
||||
|
||||
## [0.3.1] - 2021-12-14
|
||||
- update library.json
|
||||
- update license
|
||||
- minor edits
|
||||
|
||||
## [0.3.0] - 2021-11-15
|
||||
- fix #7 adding const to operators
|
||||
|
||||
----
|
||||
|
||||
## [0.2.4] - 2021-10-19
|
||||
- update build-CI.
|
||||
|
||||
## [0.2.3] - 2021-09-14
|
||||
- fix build-CI
|
||||
- update readme.md
|
||||
|
||||
## [0.2.2] - 2020-12-16
|
||||
- add arduino-ci + unit test (starter)
|
||||
- setReal(), setImag()
|
||||
|
||||
## [0.2.1] - 2020-06-05
|
||||
- fix library.json
|
||||
|
||||
## [0.2.0] - 2020-03-29
|
||||
- #pragma once,
|
||||
- create own repo
|
||||
|
||||
----
|
||||
|
||||
## [0.1.12] - 2018-04-02
|
||||
- fix issue #33 double -> float
|
||||
|
||||
## [0.1.11] - 2018-01-29
|
||||
- fix sin and cos formula - issue #91
|
||||
|
||||
## [0.1.10] - 2018-01-15
|
||||
- uppercase #define COMPLEX_H
|
||||
|
||||
## [0.1.09] - 2016-10-15
|
||||
- added (0,0) constructor
|
||||
|
||||
## [0.1.08] - 2015-06-03
|
||||
- refactor
|
||||
|
||||
## [0.1.07] - 2015-06-03
|
||||
- refactor interfaces
|
||||
|
||||
## [0.1.0] - 2013
|
||||
- initial version.
|
||||
|
@ -47,7 +47,6 @@ Apparently the name "Complex" is already in use (reserved) by some non-AVR compi
|
||||
so it won't include the Complex.h file. Problem seen on Due and Teensy3.5
|
||||
|
||||
|
||||
|
||||
#### Solution
|
||||
|
||||
- Make a copy of the Complex Library and rename the folder to CComplex
|
||||
|
@ -1,32 +1,18 @@
|
||||
//
|
||||
// FILE: Complex.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.1
|
||||
// VERSION: 0.3.2
|
||||
// PURPOSE: Arduino library for Complex math
|
||||
// URL: https://github.com/RobTillaart/Complex
|
||||
// http://arduino.cc/playground/Main/ComplexMath
|
||||
//
|
||||
// HISTORY
|
||||
// 0.3.1 2021-12-14 update library.json, license, minor edits
|
||||
// 0.3.0 2021-11-15 fix #7 adding const to operators
|
||||
// 0.2.4 2021-10-19 update build-CI.
|
||||
// 0.2.3 2021-09-14 fix build-CI + update readme
|
||||
// 0.2.2 2020-12-16 add arduino-ci + unit test (starter)
|
||||
// setReal, setImag
|
||||
// 0.2.1 2020-06-05 fix library.json
|
||||
// 0.2.0 2020-03-29 #pragma once, own repo
|
||||
// 0.1.12 2018-04-02 - fix issue #33 double -> float
|
||||
// 0.1.11 2018-01-29 - fix sin and cos formula - issue #91
|
||||
// 0.1.10 2018-01-15 - uppercase #define COMPLEX_H
|
||||
// 0.1.09 2016-10-15 - added (0,0) constructor
|
||||
// 0.1.08 2015-06-03 - refactor
|
||||
// 0.1.07 2015-06-03 - refactor interfaces
|
||||
// HISTORY: see changelog.md
|
||||
|
||||
|
||||
#include "Complex.h"
|
||||
|
||||
|
||||
// PRINTING
|
||||
// PRINTING
|
||||
size_t Complex::printTo(Print& p) const
|
||||
{
|
||||
size_t n = 0;
|
||||
@ -54,7 +40,7 @@ Complex Complex::reciprocal() const
|
||||
}
|
||||
|
||||
//
|
||||
// EQUALITIES
|
||||
// EQUALITIES
|
||||
//
|
||||
bool Complex::operator == (const Complex &c) const
|
||||
{
|
||||
@ -69,7 +55,7 @@ bool Complex::operator != (const Complex &c) const
|
||||
|
||||
|
||||
//
|
||||
// NEGATE
|
||||
// NEGATE
|
||||
//
|
||||
Complex Complex::operator - () const
|
||||
{
|
||||
@ -78,7 +64,7 @@ Complex Complex::operator - () const
|
||||
|
||||
|
||||
//
|
||||
// BASIC MATH
|
||||
// BASIC MATH
|
||||
//
|
||||
Complex Complex::operator + (const Complex &c) const
|
||||
{
|
||||
@ -147,7 +133,7 @@ Complex& Complex::operator /= (const Complex &c)
|
||||
|
||||
|
||||
//
|
||||
// POWER FUNCTIONS
|
||||
// POWER FUNCTIONS
|
||||
//
|
||||
Complex Complex::c_sqr() const
|
||||
{
|
||||
@ -205,7 +191,7 @@ Complex Complex::c_log10() const
|
||||
|
||||
|
||||
//
|
||||
// GONIO I - SIN COS TAN
|
||||
// GONIO I - SIN COS TAN
|
||||
//
|
||||
Complex Complex::c_sin() const
|
||||
{
|
||||
@ -275,7 +261,7 @@ Complex Complex::c_atan() const
|
||||
|
||||
|
||||
//
|
||||
// GONIO II - CSC SEC COT
|
||||
// GONIO II - CSC SEC COT
|
||||
//
|
||||
Complex Complex::c_csc() const
|
||||
{
|
||||
@ -314,7 +300,7 @@ Complex Complex::c_acot() const
|
||||
|
||||
|
||||
//
|
||||
// GONIO HYPERBOLICUS I
|
||||
// GONIO HYPERBOLICUS I
|
||||
//
|
||||
Complex Complex::c_sinh() const
|
||||
{
|
||||
@ -371,7 +357,7 @@ Complex Complex::c_atanh() const
|
||||
|
||||
|
||||
//
|
||||
// GONIO HYPERBOLICUS II
|
||||
// GONIO HYPERBOLICUS II
|
||||
//
|
||||
Complex Complex::c_csch() const
|
||||
{
|
||||
|
@ -2,18 +2,17 @@
|
||||
//
|
||||
// FILE: Complex.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.1
|
||||
// VERSION: 0.3.2
|
||||
// PURPOSE: Arduino library for Complex math
|
||||
// URL: https://github.com/RobTillaart/Complex
|
||||
// http://arduino.cc/playground/Main/ComplexMath
|
||||
//
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "Printable.h"
|
||||
|
||||
|
||||
#define COMPLEX_LIB_VERSION (F("0.3.1"))
|
||||
#define COMPLEX_LIB_VERSION (F("0.3.2"))
|
||||
|
||||
|
||||
class Complex: public Printable
|
||||
@ -36,7 +35,7 @@ public:
|
||||
void polar(const float modulus, const float phase);
|
||||
float phase() const { return atan2(im, re); };
|
||||
float modulus() const { return hypot(re, im); };
|
||||
// conjugate is the number mirrored in x-axis
|
||||
// conjugate is the number mirrored in x-axis
|
||||
Complex conjugate() const { return Complex(re, -im); };
|
||||
Complex reciprocal() const;
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/Complex.git"
|
||||
},
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=Complex
|
||||
version=0.3.1
|
||||
version=0.3.2
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for Complex math.
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "COMPLEX_LIB_VERSION: %s\n", (char *) COMPLEX_LIB_VERSION);
|
||||
}
|
||||
|
||||
|
||||
@ -40,8 +41,6 @@ unittest_teardown()
|
||||
|
||||
unittest(test_constructor)
|
||||
{
|
||||
fprintf(stderr, "COMPLEX_LIB_VERSION: %s\n", (char *) COMPLEX_LIB_VERSION);
|
||||
|
||||
Complex c1(10.0, -2.0);
|
||||
Complex c2(3, 0);
|
||||
Complex c3(-10, 4);
|
||||
@ -58,7 +57,7 @@ unittest(test_constructor)
|
||||
assertEqual(-5.0, c4.imag());
|
||||
assertEqual(0.0, c5.real());
|
||||
assertEqual(0.0, c5.imag());
|
||||
|
||||
|
||||
// one is a default available var.
|
||||
assertEqual(1.0, one.real());
|
||||
assertEqual(0.0, one.imag());
|
||||
@ -74,7 +73,7 @@ unittest(test_basic_math)
|
||||
{
|
||||
Complex a(10.0, -2.5);
|
||||
Complex b(3, 1);
|
||||
|
||||
|
||||
Complex c1 = a + b;
|
||||
assertEqual(13, c1.real());
|
||||
assertEqual(-1.5, c1.imag());
|
||||
@ -90,7 +89,7 @@ unittest(test_basic_math)
|
||||
Complex c4 = a / b;
|
||||
assertEqual(2.75, c4.real());
|
||||
assertEqual(-1.75, c4.imag());
|
||||
|
||||
|
||||
Complex c5 = -a;
|
||||
assertEqual(-10, c5.real());
|
||||
assertEqual(2.5, c5.imag());
|
||||
@ -133,7 +132,7 @@ unittest(test_basic_functions)
|
||||
|
||||
float ph = a.phase();
|
||||
assertEqualFloat(-0.244979, ph, 0.0001);
|
||||
|
||||
|
||||
float mod = a.modulus();
|
||||
assertEqualFloat(10.3078, mod, 0.0001);
|
||||
|
||||
@ -144,7 +143,7 @@ unittest(test_basic_functions)
|
||||
Complex reci = a.reciprocal();
|
||||
assertEqualFloat(0.0941176, reci.real(), 0.0001);
|
||||
assertEqualFloat(0.0235294, reci.imag(), 0.0001);
|
||||
|
||||
|
||||
reci *= a;
|
||||
assertEqualFloat(1.0, reci.real(), 0.0001);
|
||||
assertEqualFloat(0, reci.imag(), 0.0001);
|
||||
|
Loading…
Reference in New Issue
Block a user