June 2017
Intermediate to advanced
873 pages
18h 9m
English
Dart has no built-in type for complex numbers, but it is easy to build your own. The complex_numbers library (based on similar libraries by Tiago de Jesus and Adam Singer) provides constructors, utility methods, and four arithmetic operations both defined as operators and static methods.
We now define a ComplexNumber class, containing all utility methods for normal usage:
library complex_numbers; import 'dart:math' as math; class ComplexNumber { num _real; num _imag; // 1- Here we define different ways to build a complex number: // constructors: ComplexNumber([this._real = 0, this._imag = 0]); ComplexNumber.im(num imag) : this(0, imag); ComplexNumber.re(num real) : this(real, 0); // 2- The normal utility ...
Read now
Unlock full access