diff --git a/libraries/Complex/complex/complex.xxx b/libraries/Complex/complex/complex.xxx deleted file mode 100644 index eb1c9f46..00000000 --- a/libraries/Complex/complex/complex.xxx +++ /dev/null @@ -1,158 +0,0 @@ -// -// FILE: complex.pde -// AUTHOR: Rob Tillaart -// DATE: 2012-03-10 -// -// PUPROSE: test complex math -// - -#include "complex.h" - -void PrintComplex(Complex c) -{ - Serial.print(c.real(),3); - Serial.print("\t "); - Serial.print(c.imag(),3); - Serial.println("i"); -} - -void setup() -{ - Serial.begin(115200); - Serial.print("\n COMPLEX_LIB_VERSION: "); - Serial.println(COMPLEX_LIB_VERSION); - Serial.println("\n Complex numbers test for Arduino"); - Serial.println("\n1. PrintComplex"); - - Complex c1(10.0,-2.0); - Complex c2(3,0); - Complex c3(-10,4); - Complex c4(-5,-5); - Complex c5(0,0); - - // c5 = csqr(c3); PrintComplex(c5); - - PrintComplex(c1); PrintComplex(c2); - PrintComplex(c3); PrintComplex(c4); - c3.set(0,0); PrintComplex(c3); - - Serial.println("\n2. == != "); - c5 = c1; - if (c5 == c1) Serial.println("ok :)"); - else Serial.println(" fail :("); - c5 = c1 + 1; - if (c5 != c1) Serial.println("ok :)"); - else Serial.println(" fail :("); - c5 = 3; - if (c5 == 3) Serial.println("ok :)"); - else Serial.println(" fail :("); - - - Serial.println("\n3. negation - "); - c5 = -c1; PrintComplex(c5); - c5 = -c5; PrintComplex(c5); - if (c5 == c1) Serial.println("ok :)"); - else Serial.println(" fail :("); - - - Serial.println("\n4. + - "); - c5 = c1 + c2; PrintComplex(c5); - c5 = c1 + 3; PrintComplex(c5); - c5 = c1 - c2; PrintComplex(c5); - c5 = c1 - 3; PrintComplex(c5); - - - Serial.println("\n5. * / "); - c5 = c1 * c2; PrintComplex(c5); - c5 = c5 * 3; PrintComplex(c5); - c5 = c5 / c2; PrintComplex(c5); - c5 = c5 / 3; PrintComplex(c5); - - c5 = c1 / c2 * c2; PrintComplex(c5); - c5 = c1 * c4 / c4; PrintComplex(c5); - - - Serial.println("\n6. assign += -= etc"); - c5 = c1; - c5 += c1; PrintComplex(c5); - c5 += 3; PrintComplex(c5); - c5 -= c1; PrintComplex(c5); - c5 -= 3; PrintComplex(c5); - c5 *= c1; PrintComplex(c5); - c5 *= 3; PrintComplex(c5); - c5 /= c1; PrintComplex(c5); - c5 /= 3; PrintComplex(c5); - - - Serial.println("\n7. phase modulus polar"); - double m = c1.modulus(); Serial.println(m); - double p = c1.phase(); Serial.println(p); - c5.polar(m, p); PrintComplex(c5); - - - Serial.println("\n8. conjugate & reciprocal"); - c5 = c1.conjugate(); PrintComplex(c5); - c5 = c5.conjugate(); PrintComplex(c5); - c5 = c1.reciprocal(); PrintComplex(c5); - c5 = c5.reciprocal(); PrintComplex(c5); - - - Serial.println("\n9. power: exp log pow sqrt logn log10"); - c5 = c1.c_exp(); PrintComplex(c5); - c5 = c5.c_log(); PrintComplex(c5); - c5 = c1.c_pow(2); PrintComplex(c5); - c5 = c5.c_sqrt(); PrintComplex(c5); - c5 = c1.c_pow(c2); PrintComplex(c5); - c5 = c5.c_pow(c2.reciprocal()); PrintComplex(c5); - c5 = c5.c_logn(c4); PrintComplex(c5); - c5 = c4.c_pow(c5); PrintComplex(c5); - c5 = c5.c_log10(); PrintComplex(c5); - c5 = c4.c_sqr().c_sqrt(); PrintComplex(c5); - - - Serial.println("\n10. gonio: sin cos tan asin acos atan"); - c1.set(0.5, 0.5); - c5 = c1.c_sin(); PrintComplex(c5); - c5 = c5.c_asin(); PrintComplex(c5); - c5 = c1.c_cos(); PrintComplex(c5); - c5 = c5.c_acos(); PrintComplex(c5); - c5 = c1.c_tan(); PrintComplex(c5); - c5 = c5.c_atan(); PrintComplex(c5); - - - Serial.println("\n11. gonio csc sec cot acsc asec acot"); - c1.set(0.5, 0.5); - c5 = c1.c_csc(); PrintComplex(c5); - c5 = c5.c_acsc(); PrintComplex(c5); - c5 = c1.c_sec(); PrintComplex(c5); - c5 = c5.c_asec(); PrintComplex(c5); - c5 = c1.c_cot(); PrintComplex(c5); - c5 = c5.c_acot(); PrintComplex(c5); - - - Serial.println("\n12. gonio hyperbolicus I "); - c1.set(0.5, 0.5); - c5 = c1.c_sinh(); PrintComplex(c5); - c5 = c5.c_asinh(); PrintComplex(c5); - c5 = c1.c_cosh(); PrintComplex(c5); - c5 = c5.c_acosh(); PrintComplex(c5); - c5 = c1.c_tanh(); PrintComplex(c5); - c5 = c5.c_atanh(); PrintComplex(c5); - - Serial.println("\n13. gonio hyperbolicus II "); - c1.set(0.5, 0.5); - c5 = c1.c_csch(); PrintComplex(c5); - c5 = c5.c_acsch(); PrintComplex(c5); - c5 = c1.c_sech(); PrintComplex(c5); - c5 = c5.c_asech(); PrintComplex(c5); - c5 = c1.c_coth(); PrintComplex(c5); - c5 = c5.c_acoth(); PrintComplex(c5); - - Serial.println("\n.. Complex done"); -} - -void loop() -{ -} - - diff --git a/libraries/Complex/complex/performance/performance.pde b/libraries/Complex/complex/performance/performance.pde deleted file mode 100644 index 20ad1dac..00000000 --- a/libraries/Complex/complex/performance/performance.pde +++ /dev/null @@ -1,47 +0,0 @@ -// -// FILE: complex.pde -// AUTHOR: Rob Tillaart -// DATE: 2012-03-11 -// -// PUPROSE: test complex math -// - -#include "complex.h" - -void PrintComplex(Complex c) -{ - Serial.print(c.real(),3); - Serial.print("\t "); - Serial.print(c.imag(),3); - Serial.println("i"); -} - -void setup() -{ - Serial.begin(115200); - Serial.print("\n COMPLEX_LIB_VERSION: "); - Serial.println(COMPLEX_LIB_VERSION); - Serial.println("\n Complex numbers test for Arduino"); - Serial.println("\n1. Performance"); - - Complex c1(10.0,-2.0); - Complex c2(3, 0); - Complex c3(-10,4); - Complex c4(-5,-5); - Complex c5(0,0); - - unsigned long start = micros(); - for (int i = 0; i< 1000; i++) - { - c5 = c3.c_log(); - } - unsigned long stop = micros(); - Serial.println(stop - start); - Serial.println("\n.. Complex done"); -} - -void loop() -{ -} - - diff --git a/libraries/Complex/performance/performance.ino b/libraries/Complex/performance/performance.ino new file mode 100644 index 00000000..dbed08c2 --- /dev/null +++ b/libraries/Complex/performance/performance.ino @@ -0,0 +1,429 @@ +// +// FILE: performance.ino +// AUTHOR: Rob Tillaart +// DATE: 2013-09-23 +// +// PUPROSE: test complex math +// +// Serial.print(Complex) supported since 0.1.05 + +#include "complex.h" + +unsigned long start, stop, total; +double re, im, m, p; + +void setup() +{ + Serial.begin(115200); + Serial.print("\n Complex numbers performance test for Arduino: "); + Serial.println(COMPLEX_LIB_VERSION); + Serial.println(); + + start = micros(); + Complex c1(10.0, -2.0); + Complex c2(3, 0); + Complex c3(-10, 4); + Complex c4(-5,-5); + Complex c5(0, 0); + stop = micros(); + Serial.print("5 constructors\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c3.set(0,0); + stop = micros(); + Serial.print("set(0,0)\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1 + 1; + stop = micros(); + Serial.print("c1 + 1 \t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1 + c2; + stop = micros(); + Serial.print("c1 + c2\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 += c2; + stop = micros(); + Serial.print("+= c2\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = -c1; + stop = micros(); + Serial.print("c5 = -c1\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1 - 3; + stop = micros(); + Serial.print("c1 - 3\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1 - c2; + stop = micros(); + Serial.print("c1 - c2\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 -= c2; + stop = micros(); + Serial.print("c5 -= c2\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1 * 3; + stop = micros(); + Serial.print("c1 * 3\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1 * c2; + stop = micros(); + Serial.print("c1 * c2\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 *= c2; + stop = micros(); + Serial.print("c5 *= c2\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1 / 3; + stop = micros(); + Serial.print("c1 / 3\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1 / c2; + stop = micros(); + Serial.print("c1 / c2\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 /= c2; + stop = micros(); + Serial.print("c5 /= c2\t"); + Serial.println(stop - start); + total += (stop - start); + + Serial.println(); + + start = micros(); + for(uint8_t i=0; i< 100; i++) re = c1.real(); + stop = micros(); + Serial.print("real()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) im = c1.imag(); + stop = micros(); + Serial.print("imag()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) m = c1.modulus(); + stop = micros(); + Serial.print("modulus()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) p = c1.phase(); + stop = micros(); + Serial.print("phase\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5.polar(m, p); + stop = micros(); + Serial.print("polar()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.conjugate(); + stop = micros(); + Serial.print("conjugate()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.reciprocal(); + stop = micros(); + Serial.print("reciprocal();\t"); + Serial.println(stop - start); + total += (stop - start); + + Serial.println(); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_sqr(); + stop = micros(); + Serial.print("c_sqr()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_exp(); + stop = micros(); + Serial.print("c_exp()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_log(); + stop = micros(); + Serial.print("c_log()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_pow(2); + stop = micros(); + Serial.print("c_pow(2)\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_sqrt(); + stop = micros(); + Serial.print("c_sqrt()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_logn(c4); + stop = micros(); + Serial.print("c_logn(c4)\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c4.c_pow(c5); + stop = micros(); + Serial.print("c_pow(c5)\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_log10(); + stop = micros(); + Serial.print("c_log10()\t"); + Serial.println(stop - start); + total += (stop - start); + + Serial.println(); + c1.set(0.5, 0.5); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_sin(); + stop = micros(); + Serial.print("c_sin()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_asin(); + stop = micros(); + Serial.print("c_asin()\t"); + Serial.println(stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_cos(); + stop = micros(); + Serial.print("c_cos()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_acos(); + stop = micros(); + Serial.print("c_acos()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_tan(); + stop = micros(); + Serial.print("c_tan()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_atan(); + stop = micros(); + Serial.print("c_atan()\t"); + Serial.println(stop - start); + total += (stop - start); + + Serial.println(); + c1.set(0.5, 0.5); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_csc(); + stop = micros(); + Serial.print("c_csc()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_acsc(); + stop = micros(); + Serial.print("c_acsc()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_sec(); + stop = micros(); + Serial.print("c_sec()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_asec(); + stop = micros(); + Serial.print("c_asec()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_cot(); + stop = micros(); + Serial.print("c_cot()\t\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_acot(); + stop = micros(); + Serial.print("c_acot()\t"); + Serial.println(stop - start); + total += (stop - start); + + Serial.println(); + c1.set(0.5, 0.5); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_sinh(); + stop = micros(); + Serial.print("c_sinh()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_asinh(); + stop = micros(); + Serial.print("c_asinh()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_cosh(); + stop = micros(); + Serial.print("c_cosh()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_acosh(); + stop = micros(); + Serial.print("c_acosh()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_tanh(); + stop = micros(); + Serial.print("c_tanh()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_atanh(); + stop = micros(); + Serial.print("c_atanh()\t"); + Serial.println(stop - start); + total += (stop - start); + + Serial.println(); + c1.set(0.5, 0.5); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_csch(); + stop = micros(); + Serial.print("c_csch()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_acsch(); + stop = micros(); + Serial.print("c_acsch()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_sech(); + stop = micros(); + Serial.print("c_sech()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_asech(); + stop = micros(); + Serial.print("c_asech()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c1.c_coth(); + stop = micros(); + Serial.print("c_coth()\t"); + Serial.println(stop - start); + total += (stop - start); + + start = micros(); + for(uint8_t i=0; i< 100; i++) c5 = c5.c_acoth(); + stop = micros(); + Serial.print("c_acoth()\t"); + Serial.println(stop - start); + total += (stop - start); + + Serial.println(); + Serial.println(total); + Serial.println("\n.. Complex done"); +} + +void loop() +{ +} +// +// END OF FILE +// \ No newline at end of file