Matrix2D는 효율적인 2차원 배열 연산을 위한 Dart 패키지로, NumPy와 유사한 수학 함수를 제공합니다. 덧셈, 곱셈, 전치, 슬라이싱과 같은 행렬 조작을 쉽게 수행할 수 있습니다. 성능과 간편함을 중시하여 개발되었으며, Android, iOS, Web, macOS, Windows, Linux 등 주요 플랫폼을 모두 지원합니다. 과학 계산, 데이터 처리 및 강력한 2차원 수치 연산이 필요한 그래픽 애플리케이션에 적합합니다.
사용 사례
과학 계산
데이터 처리
그래픽 변환
머신러닝 전처리
이미지 조작
주요 기능
행렬 산술 연산
전치 및 슬라이싱
플랫폼에 관계없는 지원
NumPy와 유사한 API
고성능
적합한 대상
수학 응용 프로그램
데이터 과학 프로젝트
게임 개발
컴퓨터 비전 작업
교육 도구
고려 사항
2차원 배열에 대한 이해가 필요합니다
행렬 전용 연산에 한정
대규모 계산에 최적화되지 않음
내장된 시각화 없음
수치 작업 부하에서 Dart의 성능에 의존
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Matrix 2D 🧮
With Matrix 2D, you can perform matrix operations such as addition, subtraction, and multiplication in Dart. It is a simple and easy-to-use library inspired by Python's NumPy library.
Operations
addition(listA,listB) returns array of sums of corresponding elements of listA and listB of any dimensions.
subtraction(listA,listB) returns array of differences of corresponding elements of listA and listB of any dimensions.
division(listA,listB) divides listA by listB and returns new array
dot(listA,listB) Function returns the dot product of two arrays. For 2-D vectors, it is the equivalent to matrix multiplication. For 1-D arrays, it is the inner product of the vectors. For N-dimensional arrays, it is a sum product over the last axis of a and the second-last axis of b.
shape(list) returns dimensions of input array if the array is uniform or error otherwise.
flatten(list) returns 1-D representation of any shape and any levels of nesting of list array.
transpose(list) Reverse the axes of an array and returns the modified array
arange(start, stop, steps) returns evenly spaced values within the half-open interval [start, stop) with optional steps argument.
zeros(row,cols) Return a new array of given shape and type, with zeros
ones(row,cols) Return a new array of given shape and type, with ones
sum(list) Function returns the sum of array elements
reshape(list)Reshaping means changing the shape of an array.
diagonal(list) To find a diagonal element from a given matrix and gives output as one dimensional matrix.
fill(row,cols,object) Just like zeros() and ones this function will return a new array of given shape, with given object(anything btw strings too)
compareobject(list,operation,obj) compare values inside an array with given object and operations. function will return a new boolen array (this function is deprecated in favor of compare)
concatenate(listA,listB,{axis}) Concatenation refers to joining. This function is used to join two arrays of the same shape along a specified axis. The function takes the following parameters.Axis along which arrays have to be joined. Default is 0
min(list,{axis}) Functions, used to find the minimum value for any given array
max(list,{axis}) Functions, used to find the maximum value for any given array
slice(list (List<List>), row_index [start, stop*], column_index [start, stop*]*) Function used to slice two-dimensional arrays . (column_index and stop not required )
reverse(list,{axis}) Function used to reverse the array along the given axis. The function takes the following parameters.Axis along which the array is to be flipped. Default is 0
Examples
shape
List list = [[1, 2],[1, 2]];
print(list.shape);
ouput:
[2,2]
flatten
List list = [[1, 2],[1, 2]];
print(list.flatten);
ouput:
[1,2,1,2]
transpose
List list = [[1, 2],[1, 2]];
print(list.transpose);
ouput:
[[1,1],[2,2]]
addition
List list1 = [[1, 1],[1, 1]];
List list2 = [[2, 2],[2, 2]];
var addition = m2d.addition(list1,list2);
print(addition);
ouput:
[[3,3],[3,3]]
subtraction
List list1 = [[1, 1],[1, 1]];
List list2 = [[2, 2],[2, 2]];
var subtraction = m2d.subtraction(list1,list2);
print(subtraction);
ouput:
[[-1,-1],[-1,-1]]
division
List list1 = [[1, 1],[1, 1]];
List list2 = [[2, 2],[0, 2]];
var division = m2d.subtraction(division,list2);
print(division);
ouput:
[[0.5,Infinity],[0.5,0.5]]
dot operation
List list1 = [[1,2],[3,4]];
List list2 = [[11,12],[13,14]];
var dot = m2d.dot(division,list2);
print(dot);
ouput:
[[37, 40], [85, 92]]
arange
var arange = m2d.arange(8);
print(arange);
ouput:
[[0,1,2,3,4,5,6,7,8]]
sum
var list = [[2,2],[2,2]];
var sum = m2d.sum(list);
print(sum);
ouput:
8
reshape
List list = [[0, 1, 2, 3, 4, 5, 6, 7]];
list = list.reshape(2,4);
print(list);
ouput:
[[0, 1, 2, 3], [4, 5, 6, 7]]
linspace
var linspace = m2d.linspace(2, 3, 5);
print(linspace);
ouput:
[2.0, 2.25, 2.5, 2.75, 3.0]
diagonal
List list = [[1,1,1],[2,2,2],[3,3,3]];
print(list.diagonal);
ouput:
[1,2,3]
compare
var list = [[1,1,1],[2,2,2],[3,3,3]];
var compare = m2d.compare(list,'>',2);
print(compare);