scidart 0.0.1-dev.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

SciDart #

SciDart is a experimental cross-platform scientific library for Dart.

Goals #

The main goal of SciDart is run where Dart can run, in other words, run on Flutter, Dart CLI, Dart web, etc.

Motivation #

Some time ago I tried make a guitar tuner (frequency estimator) with Flutter and I faced with the problem: Dart didn't have a unified scientific library. So, I tried implement something to help me and the community with this problem.

Link to the Pub repository: https://pub.dev/packages/scidart

Installation #

You can follow instruction in the Pub web site: https://pub.dev/packages/scidart#-installing-tab-

Examples #

The examples can be found in the project web site.

How to contribute #

I recommend see the Todo List and choose a task or choose and solve a problem with SciDart and implement the missing parts.

The references values for all function was obtained with SciPy. The contributions need use SciPy as reference too.

Every contribution needs have tests, documentation and examples, otherwise, the pull request will be blocked.

Todo list #

Benchmarks #

  • [ ] construct codes for benchmark tests
  • [ ] made benchmark for Android devices
  • [ ] made benchmark for iOS devices
  • [ ] made benchmark on Web
  • [ ] made benchmark on Linux
  • [ ] made benchmark on MacOS
  • [ ] made benchmark on MS Windows

Code implementations #

0.0.1-dev.6 #

0.0.1-dev.5 #

  • pubspec homepage updated.

0.0.1-dev.4 #

  • README examples updated.

0.0.1-dev.3 #

  • IO migrated to scidart_io.

0.0.1-dev.2 #

  • Readme file updated.

0.0.1-dev.1 #

  • NumDart, SciDart and IO fundamentals implemented and documented.

example/example.dart

import 'package:scidart/numdart.dart';
import 'package:scidart/scidart.dart';

void main() {
  // generate the signals for test
  // 1Hz sine wave
  var N = 50.0;
  var fs = 128.0;
  var n = linspace(0, N, num: (N * fs).toInt(), endpoint: false);
  var f1 = 1.0; // 1Hz
  var sg1 = arraySin(arrayMultiplyToScalar(n, 2 * pi * f1));

  var fEstimated = freqFromFft(sg1, fs);

  print('The original and estimated frequency need be very close each other');
  print('Original frequency: ${f1}');
  print('Estimated frequency: ${fEstimated}');
}

double freqFromFft(Array sig, double fs) {
  // Estimate frequency from peak of FFT

  // Compute Fourier transform of windowed signal
  // Avoid spectral leakage: https://en.wikipedia.org/wiki/Spectral_leakage
  var windowed = sig * blackmanharris(sig.length);
  var f = rfft(windowed);

  var fAbs = arrayComplexAbs(f);

  // Find the peak and interpolate to get a more accurate peak
  var i = arrayArgMax(fAbs); // Just use this for less-accurate, naive version

  // Parabolic approximation is necessary to get the exactly frequency of a discrete signal
  // since the frequency can be in some point between the samples.
  var true_i = parabolic(arrayLog(fAbs), i)[0];

  // Convert to equivalent frequency
  return fs * true_i / windowed.length;
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  scidart: ^0.0.1-dev.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:scidart/scidart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:scidart/scidart.dart.

Health suggestions

Format lib/src/numdart/arrays_base/array.dart.

Run dartfmt to format lib/src/numdart/arrays_base/array.dart.

Format lib/src/numdart/arrays_base/array2d.dart.

Run dartfmt to format lib/src/numdart/arrays_base/array2d.dart.

Format lib/src/numdart/arrays_base/array3d.dart.

Run dartfmt to format lib/src/numdart/arrays_base/array3d.dart.

Fix additional 31 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/numdart/calculus/calculus.dart (Run dartfmt to format lib/src/numdart/calculus/calculus.dart.)
  • lib/src/numdart/calculus/numerical_integration/arrays/simps_array.dart (Run dartfmt to format lib/src/numdart/calculus/numerical_integration/arrays/simps_array.dart.)
  • lib/src/numdart/constants/math.dart (Run dartfmt to format lib/src/numdart/constants/math.dart.)
  • lib/src/numdart/constants/physical.dart (Run dartfmt to format lib/src/numdart/constants/physical.dart.)
  • lib/src/numdart/fastmath/fastmath.dart (Run dartfmt to format lib/src/numdart/fastmath/fastmath.dart.)
  • lib/src/numdart/geometric/hypotenuse.dart (Run dartfmt to format lib/src/numdart/geometric/hypotenuse.dart.)
  • lib/src/numdart/linalg/matrix_operations/matrix_vander.dart (Run dartfmt to format lib/src/numdart/linalg/matrix_operations/matrix_vander.dart.)
  • lib/src/numdart/numbers/double.dart (Run dartfmt to format lib/src/numdart/numbers/double.dart.)
  • lib/src/numdart/numbers/int.dart (Run dartfmt to format lib/src/numdart/numbers/int.dart.)
  • lib/src/numdart/numdart.dart (Run dartfmt to format lib/src/numdart/numdart.dart.)
  • lib/src/numdart/spaces/arange.dart (Run dartfmt to format lib/src/numdart/spaces/arange.dart.)
  • lib/src/numdart/spaces/linspace.dart (Run dartfmt to format lib/src/numdart/spaces/linspace.dart.)
  • lib/src/numdart/spaces/ones.dart (Run dartfmt to format lib/src/numdart/spaces/ones.dart.)
  • lib/src/numdart/spaces/zeros.dart (Run dartfmt to format lib/src/numdart/spaces/zeros.dart.)
  • lib/src/scidart/fftpack/fft/fft.dart (Run dartfmt to format lib/src/scidart/fftpack/fft/fft.dart.)
  • lib/src/scidart/fftpack/fft/ifft.dart (Run dartfmt to format lib/src/scidart/fftpack/fft/ifft.dart.)
  • lib/src/scidart/fftpack/fftpack.dart (Run dartfmt to format lib/src/scidart/fftpack/fftpack.dart.)
  • lib/src/scidart/fftpack/rfft/rfft.dart (Run dartfmt to format lib/src/scidart/fftpack/rfft/rfft.dart.)
  • lib/src/scidart/fftpack/rfft/rifft.dart (Run dartfmt to format lib/src/scidart/fftpack/rfft/rifft.dart.)
  • lib/src/scidart/signal/fir/firwin.dart (Run dartfmt to format lib/src/scidart/signal/fir/firwin.dart.)
  • lib/src/scidart/signal/signal.dart (Run dartfmt to format lib/src/scidart/signal/signal.dart.)
  • lib/src/scidart/signal/windows/blackman.dart (Run dartfmt to format lib/src/scidart/signal/windows/blackman.dart.)
  • lib/src/scidart/signal/windows/blackmanharris.dart (Run dartfmt to format lib/src/scidart/signal/windows/blackmanharris.dart.)
  • lib/src/scidart/signal/windows/flattop.dart (Run dartfmt to format lib/src/scidart/signal/windows/flattop.dart.)
  • lib/src/scidart/signal/windows/general_cosine.dart (Run dartfmt to format lib/src/scidart/signal/windows/general_cosine.dart.)
  • lib/src/scidart/signal/windows/general_hamming.dart (Run dartfmt to format lib/src/scidart/signal/windows/general_hamming.dart.)
  • lib/src/scidart/signal/windows/get_window.dart (Run dartfmt to format lib/src/scidart/signal/windows/get_window.dart.)
  • lib/src/scidart/signal/windows/hamming.dart (Run dartfmt to format lib/src/scidart/signal/windows/hamming.dart.)
  • lib/src/scidart/signal/windows/hann.dart (Run dartfmt to format lib/src/scidart/signal/windows/hann.dart.)
  • lib/src/scidart/signal/windows/kaiser.dart (Run dartfmt to format lib/src/scidart/signal/windows/kaiser.dart.)
  • lib/src/scidart/signal/windows/nuttall.dart (Run dartfmt to format lib/src/scidart/signal/windows/nuttall.dart.)

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.4.0 <3.0.0
path ^1.6.4 1.6.4
Dev dependencies
pedantic ^1.7.0
test ^1.6.0