Getting started
Getting started
Install scidart, import it and run your first computation.
SciDart brings the core of NumPy and SciPy to Dart. It is written in pure Dart, so the same code runs on the Dart VM, in Flutter apps (Android, iOS, desktop) and on the web.
The package has two libraries:
package:scidart/numdart.dartis the NumPy side: arrays, linear algebra, polynomials, statistics, calculus, constants.package:scidart/scidart.dartis the SciPy side: FFT, signal processing, special functions, distributions and optimization. It also exports everything fromnumdart, so most programs only need this import.
Install
dart pub add scidartIn a Flutter project, use flutter pub add scidart. See Install for the SDK requirements.
First program
import 'dart:math' as math;
import 'package:scidart/numdart.dart';
import 'package:scidart/scidart.dart';
void main() {
var fs = 128.0;
var f0 = 3.7; // between two FFT bins
var n = linspace(0, 4, num: (4 * fs).toInt(), endpoint: false);
var signal = arraySin(arrayMultiplyToScalar(n, 2 * math.pi * f0));
var windowed = signal * blackmanharris(signal.length);
var spectrum = arrayComplexAbs(rfft(windowed));
var i = arrayArgMax(spectrum);
var refined = parabolic(arrayLog(spectrum), i)[0];
print('naive estimate: ${fs * i / windowed.length} Hz');
print(
'refined estimate: ${(fs * refined / windowed.length).toStringAsFixed(4)} Hz');
}
Output
naive estimate: 3.75 Hz refined estimate: 3.6993 Hz
How the docs are organized
- Each guide covers one module, with examples whose output comes from running them against the released version of scidart when this site was built.
- Some guides have interactive demos. They call the library compiled to JavaScript, the same code your app runs on the web.
- Names in
codelink to the API reference, generated withdart doc. - Function names follow NumPy and SciPy where possible, so their documentation is a good second reference.