데이터 패키지는 시간과 공간 측면에서 최적화된 효율적이고 가벼운 데이터 구조 및 알고리즘을 Dart에 제공합니다. 배열, 세트, 맵과 같은 컬렉션은 향상된 성능 특성을 갖추고 있으며, 일반적인 계산 작업을 위한 유틸리티 함수도 제공합니다. 수학적 및 알고리즘 연산을 위해 설계되었으며, Android, iOS, 웹, macOS, Windows, Linux 등 모든 주요 플랫폼 간의 원활한 통합을 지원합니다. 큰 프레임워크의 오버헤드 없이 고성능 데이터 처리가 필요한 애플리케이션에 이상적입니다.
사용 사례
알고리즘 구현
고성능 데이터 처리
수학 계산
크로스 플랫폼 데이터 조작
앱에서의 효율적인 메모리 사용
주요 기능
시간 및 공간 효율성에 최적화됨
경량 컬렉션 구현
여러 플랫폼을 지원합니다
내장 알고리즘 유틸리티
최소 종속성
적합한 대상
빠른 데이터 작업이 필요한 개발자
중량 데이터 작업을 포함하는 애플리케이션
크로스 플랫폼 프로젝트
성능에 민감한 Dart 코드
수학 집약형 애플리케이션
고려 사항
내장된 Dart 컬렉션의 완전한 대체가 아님
특정 알고리즘적 요구 사항에 가장 적합
새로운 API 패턴을 배워야 할 수 있습니다
핵심 데이터 구조에 제한됨
사용자 인터페이스 또는 상태 관리용으로 설계되지 않음
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Dart Data
Dart Data is a fast and space efficient library to deal with data in Dart, Flutter and the web. As of today this mostly includes data structures and algorithms for vectors and matrices, but at some point might also include graphs and other mathematical structures.
This library is open source, stable and well tested. Development happens on GitHub. Feel free to report issues or create a pull-request there. General questions are best asked on StackOverflow.
Solve 'A * x = b', where 'A' is a matrix and 'b' a vector:
final a = Matrix<double>.fromRows(DataType.float64, [
[2, 1, 1],
[1, 3, 2],
[1, 0, 0],
]);
final b = Vector<double>.fromList(DataType.float64, [4, 5, 6]);
final x = a.solve(b.columnMatrix).column(0);
print(x.format(valuePrinter: FixedNumberPrinter())); // prints '6 15 -23'
How to find the eigenvalues of a matrix?
Find the eigenvalues of a matrix 'A':
final a = Matrix<double>.fromRows(DataType.float64, [
[1, 0, 0, -1],
[0, -1, 0, 0],
[0, 0, 1, -1],
[-1, 0, -1, 0],
]);
final decomposition = a.eigenvalue;
final eigenvalues = Vector<double>.fromList(
DataType.float64, decomposition.realEigenvalues);
print(eigenvalues.format(valuePrinter: FixedNumberPrinter(precision: 1))); // prints '-1.0 -1.0 1.0 2.0'
How to find all the roots of a polynomial?
To find the roots of x^5 + -8x^4 + -72x^3 + 242x^2 + 1847x + 2310:
To find the best fitting third degree polynomial through a list of points:
final height = [1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83].toVector();
final mass = [52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46].toVector();
final fitter = PolynomialRegression(degree: 2);
final result = fitter.fit(xs: height, ys: mass);
print(result.polynomial.format(valuePrinter: FixedNumberPrinter(precision: 3))); // 61.960x^2 + -143.162x + 128.813
How to numerically integrate a function?
In both examples we specify a custom depth, since these integrals are tricky at the upper bound (very steep for the first one, very flat for the second one).
// Compute the area of a circle by iterating over a quarter circle:final pi = 4 * integrate((x) => sqrt(1 - x * x), 0, 1, depth: 30);
print(pi); // 3.1415925673846368 ~ pi// Compute an improper integral:final one = integrate((x) => exp(-x), 0, double.infinity, depth: 30);
print(one); // 1.0000000904304227 ~ 1
Misc
Demos
This package includes a sandbox web dashboard in web/distributions to visualize, configure, and dynamically sample the supported continuous and discrete probability distributions in real-time.
To compile, serve, and explore the interactive distributions demo run:
dart pub global activate webdev
webdev serve --release