Home » U++ Library support » U++ Core » Complex numbers..How to use in upp??
|
|
|
Re: Complex numbers..How to use in upp?? [message #33836 is a reply to message #33821] |
Sat, 17 September 2011 12:12   |
|
There is a support for complex numbers in U++ Core: the Complex class. See uppsrc/Core/Complex.h for some details. It is based on the std::complex that Javier recommended in previous post, but adds some integration with U++, e.g. Value compatibility.
Simple usage:#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN{
Complex a(1,2);
Cout() << "a = " << a << "\n";
Cout() << "Im(a) = " << a.imag() << "\n";
Cout() << "Re(a) = " << a.real() << "\n";
Cout() << "|a| = " << abs(a) << "\n";
Cout() << "2a = " << Complex(a+a) << "\n";
Cout() << "a^2 = " << Complex(a*a) << "\n";
}
Best regards,
Honza
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 15:03:02 CEST 2025
Total time taken to generate the page: 0.03113 seconds
|