data-structure-typed 2.5.0 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +12984 -0
  2. package/.vitepress/cache/deps_temp_51f5f1b0/package.json +3 -0
  3. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +4505 -0
  4. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +9731 -0
  5. package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +347 -0
  6. package/CHANGELOG.md +5 -1
  7. package/README.md +124 -29
  8. package/dist/cjs/binary-tree.cjs +26282 -0
  9. package/dist/cjs/graph.cjs +5422 -0
  10. package/dist/cjs/hash.cjs +1310 -0
  11. package/dist/cjs/heap.cjs +1602 -0
  12. package/dist/cjs/index.cjs +31257 -14673
  13. package/dist/cjs/linked-list.cjs +4576 -0
  14. package/dist/cjs/matrix.cjs +1080 -0
  15. package/dist/cjs/priority-queue.cjs +1376 -0
  16. package/dist/cjs/queue.cjs +4264 -0
  17. package/dist/cjs/stack.cjs +907 -0
  18. package/dist/cjs/trie.cjs +1223 -0
  19. package/dist/cjs-legacy/binary-tree.cjs +26319 -0
  20. package/dist/cjs-legacy/graph.cjs +5420 -0
  21. package/dist/cjs-legacy/hash.cjs +1310 -0
  22. package/dist/cjs-legacy/heap.cjs +1599 -0
  23. package/dist/cjs-legacy/index.cjs +31268 -14679
  24. package/dist/cjs-legacy/linked-list.cjs +4582 -0
  25. package/dist/cjs-legacy/matrix.cjs +1083 -0
  26. package/dist/cjs-legacy/priority-queue.cjs +1374 -0
  27. package/dist/cjs-legacy/queue.cjs +4262 -0
  28. package/dist/cjs-legacy/stack.cjs +907 -0
  29. package/dist/cjs-legacy/trie.cjs +1222 -0
  30. package/dist/esm/binary-tree.mjs +26267 -0
  31. package/dist/esm/graph.mjs +5409 -0
  32. package/dist/esm/hash.mjs +1307 -0
  33. package/dist/esm/heap.mjs +1596 -0
  34. package/dist/esm/index.mjs +31254 -14674
  35. package/dist/esm/linked-list.mjs +4569 -0
  36. package/dist/esm/matrix.mjs +1076 -0
  37. package/dist/esm/priority-queue.mjs +1372 -0
  38. package/dist/esm/queue.mjs +4260 -0
  39. package/dist/esm/stack.mjs +905 -0
  40. package/dist/esm/trie.mjs +1220 -0
  41. package/dist/esm-legacy/binary-tree.mjs +26304 -0
  42. package/dist/esm-legacy/graph.mjs +5407 -0
  43. package/dist/esm-legacy/hash.mjs +1307 -0
  44. package/dist/esm-legacy/heap.mjs +1593 -0
  45. package/dist/esm-legacy/index.mjs +31265 -14680
  46. package/dist/esm-legacy/linked-list.mjs +4575 -0
  47. package/dist/esm-legacy/matrix.mjs +1079 -0
  48. package/dist/esm-legacy/priority-queue.mjs +1370 -0
  49. package/dist/esm-legacy/queue.mjs +4258 -0
  50. package/dist/esm-legacy/stack.mjs +905 -0
  51. package/dist/esm-legacy/trie.mjs +1219 -0
  52. package/dist/types/common/error.d.ts +9 -0
  53. package/dist/types/common/index.d.ts +1 -1
  54. package/dist/types/data-structures/base/index.d.ts +1 -0
  55. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  56. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  57. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
  58. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
  59. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
  60. package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
  61. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
  62. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
  63. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
  64. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
  65. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
  66. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
  67. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  68. package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
  69. package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
  70. package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
  71. package/dist/types/data-structures/heap/heap.d.ts +336 -0
  72. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
  73. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
  74. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
  75. package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
  76. package/dist/types/data-structures/queue/deque.d.ts +364 -4
  77. package/dist/types/data-structures/queue/queue.d.ts +288 -0
  78. package/dist/types/data-structures/stack/stack.d.ts +240 -0
  79. package/dist/types/data-structures/trie/trie.d.ts +292 -4
  80. package/dist/types/interfaces/graph.d.ts +1 -1
  81. package/dist/types/types/common.d.ts +2 -2
  82. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  83. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  84. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  85. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  86. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  87. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  88. package/dist/types/types/utils/validate-type.d.ts +4 -4
  89. package/dist/umd/data-structure-typed.js +31196 -14608
  90. package/dist/umd/data-structure-typed.min.js +11 -5
  91. package/docs-site-docusaurus/README.md +41 -0
  92. package/docs-site-docusaurus/docs/api/README.md +52 -0
  93. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +6644 -0
  94. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +282 -0
  95. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +2266 -0
  96. package/docs-site-docusaurus/docs/api/classes/BST.md +6293 -0
  97. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +333 -0
  98. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +455 -0
  99. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +4647 -0
  100. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +331 -0
  101. package/docs-site-docusaurus/docs/api/classes/Deque.md +2767 -0
  102. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +2999 -0
  103. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +2685 -0
  104. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +221 -0
  105. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +253 -0
  106. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +21 -0
  107. package/docs-site-docusaurus/docs/api/classes/HashMap.md +1333 -0
  108. package/docs-site-docusaurus/docs/api/classes/Heap.md +1881 -0
  109. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +800 -0
  110. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +644 -0
  111. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +1632 -0
  112. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +1853 -0
  113. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +1108 -0
  114. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +156 -0
  115. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +2824 -0
  116. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +2929 -0
  117. package/docs-site-docusaurus/docs/api/classes/Matrix.md +1026 -0
  118. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +1866 -0
  119. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +1883 -0
  120. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +1879 -0
  121. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +1882 -0
  122. package/docs-site-docusaurus/docs/api/classes/Navigator.md +109 -0
  123. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +1839 -0
  124. package/docs-site-docusaurus/docs/api/classes/Queue.md +2244 -0
  125. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +6888 -0
  126. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +372 -0
  127. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +2897 -0
  128. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +169 -0
  129. package/docs-site-docusaurus/docs/api/classes/SkipList.md +1229 -0
  130. package/docs-site-docusaurus/docs/api/classes/Stack.md +1573 -0
  131. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +1389 -0
  132. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +1591 -0
  133. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +1246 -0
  134. package/docs-site-docusaurus/docs/api/classes/Trie.md +1708 -0
  135. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +199 -0
  136. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +2979 -0
  137. package/docs-site-docusaurus/docs/guide/_category_.json +6 -0
  138. package/docs-site-docusaurus/docs/guide/architecture.md +615 -0
  139. package/docs-site-docusaurus/docs/guide/concepts.md +451 -0
  140. package/docs-site-docusaurus/docs/guide/faq.md +180 -0
  141. package/docs-site-docusaurus/docs/guide/guides.md +597 -0
  142. package/docs-site-docusaurus/docs/guide/installation.md +62 -0
  143. package/docs-site-docusaurus/docs/guide/integrations.md +825 -0
  144. package/docs-site-docusaurus/docs/guide/overview.md +645 -0
  145. package/docs-site-docusaurus/docs/guide/performance.md +835 -0
  146. package/docs-site-docusaurus/docs/guide/quick-start.md +104 -0
  147. package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
  148. package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
  149. package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
  150. package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
  151. package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
  152. package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
  153. package/docs-site-docusaurus/docusaurus.config.ts +159 -0
  154. package/docs-site-docusaurus/fix-mdx-generics.mjs +75 -0
  155. package/docs-site-docusaurus/package-lock.json +18667 -0
  156. package/docs-site-docusaurus/package.json +50 -0
  157. package/docs-site-docusaurus/prefix-class-to-methods.mjs +48 -0
  158. package/docs-site-docusaurus/sidebars.ts +23 -0
  159. package/docs-site-docusaurus/sort-protected.mjs +87 -0
  160. package/docs-site-docusaurus/src/css/custom.css +96 -0
  161. package/docs-site-docusaurus/src/pages/index.module.css +13 -0
  162. package/docs-site-docusaurus/src/pages/index.tsx +120 -0
  163. package/docs-site-docusaurus/src/pages/markdown-page.md +7 -0
  164. package/docs-site-docusaurus/src/theme/TOCItems/index.tsx +34 -0
  165. package/docs-site-docusaurus/static/.nojekyll +0 -0
  166. package/docs-site-docusaurus/static/img/docusaurus-social-card.jpg +0 -0
  167. package/docs-site-docusaurus/static/img/docusaurus.png +0 -0
  168. package/docs-site-docusaurus/static/img/favicon.ico +0 -0
  169. package/docs-site-docusaurus/static/img/favicon.png +0 -0
  170. package/docs-site-docusaurus/static/img/logo-180.png +0 -0
  171. package/docs-site-docusaurus/static/img/logo.jpg +0 -0
  172. package/docs-site-docusaurus/static/img/logo.png +0 -0
  173. package/docs-site-docusaurus/static/img/logo.svg +1 -0
  174. package/docs-site-docusaurus/static/img/og-image.png +0 -0
  175. package/docs-site-docusaurus/static/img/undraw_docusaurus_mountain.svg +171 -0
  176. package/docs-site-docusaurus/static/img/undraw_docusaurus_react.svg +170 -0
  177. package/docs-site-docusaurus/static/img/undraw_docusaurus_tree.svg +40 -0
  178. package/docs-site-docusaurus/static/llms.txt +37 -0
  179. package/docs-site-docusaurus/static/robots.txt +4 -0
  180. package/docs-site-docusaurus/typedoc.json +23 -0
  181. package/llms.txt +37 -0
  182. package/package.json +159 -55
  183. package/src/common/error.ts +19 -1
  184. package/src/common/index.ts +1 -1
  185. package/src/data-structures/base/index.ts +1 -0
  186. package/src/data-structures/base/iterable-element-base.ts +3 -2
  187. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  188. package/src/data-structures/base/linear-base.ts +3 -3
  189. package/src/data-structures/binary-tree/avl-tree.ts +287 -0
  190. package/src/data-structures/binary-tree/binary-indexed-tree.ts +327 -5
  191. package/src/data-structures/binary-tree/binary-tree.ts +581 -6
  192. package/src/data-structures/binary-tree/bst.ts +922 -7
  193. package/src/data-structures/binary-tree/red-black-tree.ts +453 -0
  194. package/src/data-structures/binary-tree/segment-tree.ts +139 -2
  195. package/src/data-structures/binary-tree/tree-map.ts +3300 -495
  196. package/src/data-structures/binary-tree/tree-multi-map.ts +3384 -563
  197. package/src/data-structures/binary-tree/tree-multi-set.ts +2757 -493
  198. package/src/data-structures/binary-tree/tree-set.ts +3122 -440
  199. package/src/data-structures/graph/abstract-graph.ts +6 -6
  200. package/src/data-structures/graph/directed-graph.ts +230 -0
  201. package/src/data-structures/graph/undirected-graph.ts +207 -0
  202. package/src/data-structures/hash/hash-map.ts +270 -19
  203. package/src/data-structures/heap/heap.ts +326 -4
  204. package/src/data-structures/heap/max-heap.ts +2 -2
  205. package/src/data-structures/linked-list/doubly-linked-list.ts +394 -3
  206. package/src/data-structures/linked-list/singly-linked-list.ts +348 -3
  207. package/src/data-structures/linked-list/skip-linked-list.ts +421 -7
  208. package/src/data-structures/matrix/matrix.ts +194 -10
  209. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  210. package/src/data-structures/queue/deque.ts +350 -5
  211. package/src/data-structures/queue/queue.ts +276 -0
  212. package/src/data-structures/stack/stack.ts +230 -0
  213. package/src/data-structures/trie/trie.ts +283 -7
  214. package/src/interfaces/graph.ts +1 -1
  215. package/src/types/common.ts +2 -2
  216. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  217. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  218. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  219. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  220. package/src/types/data-structures/heap/heap.ts +1 -0
  221. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  222. package/src/types/utils/validate-type.ts +4 -4
  223. package/vercel.json +6 -0
  224. package/dist/leetcode/avl-tree-counter.mjs +0 -2957
  225. package/dist/leetcode/avl-tree-multi-map.mjs +0 -2889
  226. package/dist/leetcode/avl-tree.mjs +0 -2720
  227. package/dist/leetcode/binary-tree.mjs +0 -1594
  228. package/dist/leetcode/bst.mjs +0 -2398
  229. package/dist/leetcode/deque.mjs +0 -683
  230. package/dist/leetcode/directed-graph.mjs +0 -1733
  231. package/dist/leetcode/doubly-linked-list.mjs +0 -709
  232. package/dist/leetcode/hash-map.mjs +0 -493
  233. package/dist/leetcode/heap.mjs +0 -542
  234. package/dist/leetcode/max-heap.mjs +0 -375
  235. package/dist/leetcode/max-priority-queue.mjs +0 -383
  236. package/dist/leetcode/min-heap.mjs +0 -363
  237. package/dist/leetcode/min-priority-queue.mjs +0 -371
  238. package/dist/leetcode/priority-queue.mjs +0 -363
  239. package/dist/leetcode/queue.mjs +0 -943
  240. package/dist/leetcode/red-black-tree.mjs +0 -2765
  241. package/dist/leetcode/singly-linked-list.mjs +0 -754
  242. package/dist/leetcode/stack.mjs +0 -217
  243. package/dist/leetcode/tree-counter.mjs +0 -3039
  244. package/dist/leetcode/tree-multi-map.mjs +0 -2913
  245. package/dist/leetcode/trie.mjs +0 -413
  246. package/dist/leetcode/undirected-graph.mjs +0 -1650
@@ -0,0 +1,1026 @@
1
+ [**data-structure-typed**](../README.md)
2
+
3
+ ***
4
+
5
+ [data-structure-typed](../README.md) / Matrix
6
+
7
+ # Class: Matrix
8
+
9
+ Defined in: [data-structures/matrix/matrix.ts:97](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L97)
10
+
11
+ Matrix — a numeric matrix with standard linear algebra operations.
12
+
13
+ ## Examples
14
+
15
+ ```ts
16
+ // Basic matrix arithmetic
17
+ const a = new Matrix([
18
+ [1, 2],
19
+ [3, 4]
20
+ ]);
21
+ const b = new Matrix([
22
+ [5, 6],
23
+ [7, 8]
24
+ ]);
25
+
26
+ const sum = a.add(b);
27
+ console.log(sum?.data); // [
28
+ // [6, 8],
29
+ // [10, 12]
30
+ // ];
31
+
32
+ const diff = b.subtract(a);
33
+ console.log(diff?.data); // [
34
+ // [4, 4],
35
+ // [4, 4]
36
+ // ];
37
+ ```
38
+
39
+ ```ts
40
+ // Matrix multiplication for transformations
41
+ // 2x3 matrix * 3x2 matrix = 2x2 matrix
42
+ const a = new Matrix([
43
+ [1, 2, 3],
44
+ [4, 5, 6]
45
+ ]);
46
+ const b = new Matrix([
47
+ [7, 8],
48
+ [9, 10],
49
+ [11, 12]
50
+ ]);
51
+
52
+ const product = a.multiply(b);
53
+ console.log(product?.rows); // 2;
54
+ console.log(product?.cols); // 2;
55
+ // Row 0: 1*7+2*9+3*11=58, 1*8+2*10+3*12=64
56
+ // Row 1: 4*7+5*9+6*11=139, 4*8+5*10+6*12=154
57
+ console.log(product?.data); // [
58
+ // [58, 64],
59
+ // [139, 154]
60
+ // ];
61
+ ```
62
+
63
+ ```ts
64
+ // Matrix transpose (square matrix)
65
+ const m = new Matrix([
66
+ [1, 2, 3],
67
+ [4, 5, 6],
68
+ [7, 8, 9]
69
+ ]);
70
+
71
+ const transposed = m.transpose();
72
+ console.log(transposed.rows); // 3;
73
+ console.log(transposed.cols); // 3;
74
+ console.log(transposed.data); // [
75
+ // [1, 4, 7],
76
+ // [2, 5, 8],
77
+ // [3, 6, 9]
78
+ // ];
79
+
80
+ // Transpose of transpose = original
81
+ console.log(transposed.transpose().data); // m.data;
82
+ ```
83
+
84
+ ```ts
85
+ // Get and set individual cells
86
+ const m = new Matrix([
87
+ [0, 0, 0],
88
+ [0, 0, 0]
89
+ ]);
90
+
91
+ m.set(0, 1, 42);
92
+ m.set(1, 2, 99);
93
+
94
+ console.log(m.get(0, 1)); // 42;
95
+ console.log(m.get(1, 2)); // 99;
96
+ console.log(m.get(0, 0)); // 0;
97
+
98
+ // Out of bounds returns undefined
99
+ console.log(m.get(5, 5)); // undefined;
100
+ ```
101
+
102
+ ## Constructors
103
+
104
+ ### Constructor
105
+
106
+ ```ts
107
+ new Matrix(data, options?): Matrix;
108
+ ```
109
+
110
+ Defined in: [data-structures/matrix/matrix.ts:105](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L105)
111
+
112
+ The constructor function initializes a matrix object with the provided data and options, or with
113
+ default values if no options are provided.
114
+
115
+ #### Parameters
116
+
117
+ ##### data
118
+
119
+ `number`[][]
120
+
121
+ A 2D array of numbers representing the data for the matrix.
122
+
123
+ ##### options?
124
+
125
+ `MatrixOptions`
126
+
127
+ The `options` parameter is an optional object that can contain the following
128
+ properties:
129
+
130
+ #### Returns
131
+
132
+ `Matrix`
133
+
134
+ ## Accessors
135
+
136
+ ### addFn
137
+
138
+ #### Get Signature
139
+
140
+ ```ts
141
+ get addFn(): (a, b) => number | undefined;
142
+ ```
143
+
144
+ Defined in: [data-structures/matrix/matrix.ts:164](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L164)
145
+
146
+ The above function returns the value of the _addFn property.
147
+
148
+ ##### Returns
149
+
150
+ The value of the property `_addFn` is being returned.
151
+
152
+ (`a`, `b`) => `number` \| `undefined`
153
+
154
+ ***
155
+
156
+ ### cols
157
+
158
+ #### Get Signature
159
+
160
+ ```ts
161
+ get cols(): number;
162
+ ```
163
+
164
+ Defined in: [data-structures/matrix/matrix.ts:146](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L146)
165
+
166
+ The function returns the value of the protected variable _cols.
167
+
168
+ ##### Returns
169
+
170
+ `number`
171
+
172
+ The number of columns.
173
+
174
+ ***
175
+
176
+ ### data
177
+
178
+ #### Get Signature
179
+
180
+ ```ts
181
+ get data(): number[][];
182
+ ```
183
+
184
+ Defined in: [data-structures/matrix/matrix.ts:156](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L156)
185
+
186
+ The function returns a two-dimensional array of numbers.
187
+
188
+ ##### Returns
189
+
190
+ `number`[][]
191
+
192
+ The data property, which is a two-dimensional array of numbers.
193
+
194
+ ***
195
+
196
+ ### multiplyFn
197
+
198
+ #### Get Signature
199
+
200
+ ```ts
201
+ get multiplyFn(): (a, b) => number;
202
+ ```
203
+
204
+ Defined in: [data-structures/matrix/matrix.ts:180](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L180)
205
+
206
+ The function returns the value of the _multiplyFn property.
207
+
208
+ ##### Returns
209
+
210
+ The `_multiplyFn` property is being returned.
211
+
212
+ (`a`, `b`) => `number`
213
+
214
+ ***
215
+
216
+ ### rows
217
+
218
+ #### Get Signature
219
+
220
+ ```ts
221
+ get rows(): number;
222
+ ```
223
+
224
+ Defined in: [data-structures/matrix/matrix.ts:136](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L136)
225
+
226
+ The function returns the number of rows.
227
+
228
+ ##### Returns
229
+
230
+ `number`
231
+
232
+ The number of rows.
233
+
234
+ ***
235
+
236
+ ### size
237
+
238
+ #### Get Signature
239
+
240
+ ```ts
241
+ get size(): [number, number];
242
+ ```
243
+
244
+ Defined in: [data-structures/matrix/matrix.ts:904](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L904)
245
+
246
+ Returns [rows, cols] dimensions tuple.
247
+
248
+ ##### Returns
249
+
250
+ \[`number`, `number`\]
251
+
252
+ ***
253
+
254
+ ### subtractFn
255
+
256
+ #### Get Signature
257
+
258
+ ```ts
259
+ get subtractFn(): (a, b) => number;
260
+ ```
261
+
262
+ Defined in: [data-structures/matrix/matrix.ts:172](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L172)
263
+
264
+ The function returns the value of the _subtractFn property.
265
+
266
+ ##### Returns
267
+
268
+ The `_subtractFn` property is being returned.
269
+
270
+ (`a`, `b`) => `number`
271
+
272
+ ## Methods
273
+
274
+ ### \[iterator\]()
275
+
276
+ ```ts
277
+ iterator: IterableIterator<number[]>;
278
+ ```
279
+
280
+ Defined in: [data-structures/matrix/matrix.ts:933](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L933)
281
+
282
+ Iterates over rows.
283
+
284
+ #### Returns
285
+
286
+ `IterableIterator`\<`number`[]\>
287
+
288
+ ***
289
+
290
+ ### add()
291
+
292
+ ```ts
293
+ add(matrix): Matrix | undefined;
294
+ ```
295
+
296
+ Defined in: [data-structures/matrix/matrix.ts:385](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L385)
297
+
298
+ The `add` function adds two matrices together, returning a new matrix with the result.
299
+
300
+ #### Parameters
301
+
302
+ ##### matrix
303
+
304
+ `Matrix`
305
+
306
+ The `matrix` parameter is an instance of the `Matrix` class.
307
+
308
+ #### Returns
309
+
310
+ `Matrix` \| `undefined`
311
+
312
+ The `add` method returns a new `Matrix` object that represents the result of adding the
313
+ current matrix with the provided `matrix` parameter.
314
+
315
+ *
316
+
317
+ #### Example
318
+
319
+ ```ts
320
+ // Basic matrix arithmetic
321
+ const a = new Matrix([
322
+ [1, 2],
323
+ [3, 4]
324
+ ]);
325
+ const b = new Matrix([
326
+ [5, 6],
327
+ [7, 8]
328
+ ]);
329
+
330
+ const sum = a.add(b);
331
+ console.log(sum?.data); // [
332
+ // [6, 8],
333
+ // [10, 12]
334
+ // ];
335
+
336
+ const diff = b.subtract(a);
337
+ console.log(diff?.data); // [
338
+ // [4, 4],
339
+ // [4, 4]
340
+ // ];
341
+ ```
342
+
343
+ ***
344
+
345
+ ### clone()
346
+
347
+ ```ts
348
+ clone(): Matrix;
349
+ ```
350
+
351
+ Defined in: [data-structures/matrix/matrix.ts:886](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L886)
352
+
353
+ The `clone` function returns a new instance of the Matrix class with the same data and properties
354
+ as the original instance.
355
+
356
+ #### Returns
357
+
358
+ `Matrix`
359
+
360
+ The `clone()` method is returning a new instance of the `Matrix` class with the same data
361
+ and properties as the current instance.
362
+
363
+ ***
364
+
365
+ ### dot()
366
+
367
+ ```ts
368
+ dot(matrix): Matrix | undefined;
369
+ ```
370
+
371
+ Defined in: [data-structures/matrix/matrix.ts:835](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L835)
372
+
373
+ The dot function calculates the dot product of two matrices and returns a new matrix.
374
+
375
+ #### Parameters
376
+
377
+ ##### matrix
378
+
379
+ `Matrix`
380
+
381
+ The `matrix` parameter is an instance of the `Matrix` class.
382
+
383
+ #### Returns
384
+
385
+ `Matrix` \| `undefined`
386
+
387
+ a new Matrix object.
388
+
389
+ *
390
+
391
+ #### Example
392
+
393
+ ```ts
394
+ // Dot product of two matrices
395
+ const a = Matrix.from([[1, 2], [3, 4]]);
396
+ const b = Matrix.from([[5, 6], [7, 8]]);
397
+ const result = a.dot(b);
398
+ console.log(result?.toArray()); // [[19, 22], [43, 50]];
399
+ ```
400
+
401
+ ***
402
+
403
+ ### flatten()
404
+
405
+ ```ts
406
+ flatten(): number[];
407
+ ```
408
+
409
+ Defined in: [data-structures/matrix/matrix.ts:922](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L922)
410
+
411
+ Returns a flat row-major array.
412
+
413
+ #### Returns
414
+
415
+ `number`[]
416
+
417
+ ***
418
+
419
+ ### forEach()
420
+
421
+ ```ts
422
+ forEach(callback): void;
423
+ ```
424
+
425
+ Defined in: [data-structures/matrix/matrix.ts:952](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L952)
426
+
427
+ Visits each element with its row and column index.
428
+
429
+ #### Parameters
430
+
431
+ ##### callback
432
+
433
+ (`value`, `row`, `col`) => `void`
434
+
435
+ #### Returns
436
+
437
+ `void`
438
+
439
+ ***
440
+
441
+ ### get()
442
+
443
+ ```ts
444
+ get(row, col): number | undefined;
445
+ ```
446
+
447
+ Defined in: [data-structures/matrix/matrix.ts:244](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L244)
448
+
449
+ The `get` function returns the value at the specified row and column index if it is a valid index.
450
+
451
+ #### Parameters
452
+
453
+ ##### row
454
+
455
+ `number`
456
+
457
+ The `row` parameter represents the row index of the element you want to
458
+ retrieve from the data array.
459
+
460
+ ##### col
461
+
462
+ `number`
463
+
464
+ The parameter "col" represents the column number of the element you want to
465
+ retrieve from the data array.
466
+
467
+ #### Returns
468
+
469
+ `number` \| `undefined`
470
+
471
+ The `get` function returns a number if the provided row and column indices are valid.
472
+ Otherwise, it returns `undefined`.
473
+
474
+ *
475
+
476
+ #### Example
477
+
478
+ ```ts
479
+ // Get and set individual cells
480
+ const m = new Matrix([
481
+ [0, 0, 0],
482
+ [0, 0, 0]
483
+ ]);
484
+
485
+ m.set(0, 1, 42);
486
+ m.set(1, 2, 99);
487
+
488
+ console.log(m.get(0, 1)); // 42;
489
+ console.log(m.get(1, 2)); // 99;
490
+ console.log(m.get(0, 0)); // 0;
491
+
492
+ // Out of bounds returns undefined
493
+ console.log(m.get(5, 5)); // undefined;
494
+ ```
495
+
496
+ ***
497
+
498
+ ### inverse()
499
+
500
+ ```ts
501
+ inverse(): Matrix | undefined;
502
+ ```
503
+
504
+ Defined in: [data-structures/matrix/matrix.ts:714](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L714)
505
+
506
+ The `inverse` function calculates the inverse of a square matrix using Gaussian elimination.
507
+
508
+ #### Returns
509
+
510
+ `Matrix` \| `undefined`
511
+
512
+ a Matrix object, which represents the inverse of the original matrix.
513
+
514
+ *
515
+
516
+ #### Example
517
+
518
+ ```ts
519
+ // Compute the inverse of a 2x2 matrix
520
+ const m = Matrix.from([[4, 7], [2, 6]]);
521
+ const inv = m.inverse();
522
+ console.log(inv); // defined;
523
+ // A * A^-1 should ≈ Identity
524
+ const product = m.multiply(inv!);
525
+ console.log(product?.get(0, 0)); // toBeCloseTo;
526
+ console.log(product?.get(0, 1)); // toBeCloseTo;
527
+ console.log(product?.get(1, 0)); // toBeCloseTo;
528
+ console.log(product?.get(1, 1)); // toBeCloseTo;
529
+ ```
530
+
531
+ ***
532
+
533
+ ### isMatchForCalculate()
534
+
535
+ ```ts
536
+ isMatchForCalculate(matrix): boolean;
537
+ ```
538
+
539
+ Defined in: [data-structures/matrix/matrix.ts:318](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L318)
540
+
541
+ The function checks if the dimensions of the given matrix match the dimensions of the current
542
+ matrix.
543
+
544
+ #### Parameters
545
+
546
+ ##### matrix
547
+
548
+ `Matrix`
549
+
550
+ The parameter `matrix` is of type `Matrix`.
551
+
552
+ #### Returns
553
+
554
+ `boolean`
555
+
556
+ a boolean value.
557
+
558
+ ***
559
+
560
+ ### isValidIndex()
561
+
562
+ ```ts
563
+ isValidIndex(row, col): boolean;
564
+ ```
565
+
566
+ Defined in: [data-structures/matrix/matrix.ts:876](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L876)
567
+
568
+ The function checks if a given row and column index is valid within a specified range.
569
+
570
+ #### Parameters
571
+
572
+ ##### row
573
+
574
+ `number`
575
+
576
+ The `row` parameter represents the row index of a two-dimensional array or
577
+ matrix. It is a number that indicates the specific row in the matrix.
578
+
579
+ ##### col
580
+
581
+ `number`
582
+
583
+ The "col" parameter represents the column index in a two-dimensional array
584
+ or grid. It is used to check if the given column index is valid within the bounds of the grid.
585
+
586
+ #### Returns
587
+
588
+ `boolean`
589
+
590
+ A boolean value is being returned.
591
+
592
+ ***
593
+
594
+ ### map()
595
+
596
+ ```ts
597
+ map(callback): Matrix;
598
+ ```
599
+
600
+ Defined in: [data-structures/matrix/matrix.ts:963](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L963)
601
+
602
+ Maps each element (number → number) and returns a new Matrix.
603
+
604
+ #### Parameters
605
+
606
+ ##### callback
607
+
608
+ (`value`, `row`, `col`) => `number`
609
+
610
+ #### Returns
611
+
612
+ `Matrix`
613
+
614
+ ***
615
+
616
+ ### multiply()
617
+
618
+ ```ts
619
+ multiply(matrix): Matrix | undefined;
620
+ ```
621
+
622
+ Defined in: [data-structures/matrix/matrix.ts:548](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L548)
623
+
624
+ The `multiply` function performs matrix multiplication between two matrices and returns the result
625
+ as a new matrix.
626
+
627
+ #### Parameters
628
+
629
+ ##### matrix
630
+
631
+ `Matrix`
632
+
633
+ The `matrix` parameter is an instance of the `Matrix` class.
634
+
635
+ #### Returns
636
+
637
+ `Matrix` \| `undefined`
638
+
639
+ a new Matrix object.
640
+
641
+ *
642
+
643
+ #### Example
644
+
645
+ ```ts
646
+ // Matrix multiplication for transformations
647
+ // 2x3 matrix * 3x2 matrix = 2x2 matrix
648
+ const a = new Matrix([
649
+ [1, 2, 3],
650
+ [4, 5, 6]
651
+ ]);
652
+ const b = new Matrix([
653
+ [7, 8],
654
+ [9, 10],
655
+ [11, 12]
656
+ ]);
657
+
658
+ const product = a.multiply(b);
659
+ console.log(product?.rows); // 2;
660
+ console.log(product?.cols); // 2;
661
+ // Row 0: 1*7+2*9+3*11=58, 1*8+2*10+3*12=64
662
+ // Row 1: 4*7+5*9+6*11=139, 4*8+5*10+6*12=154
663
+ console.log(product?.data); // [
664
+ // [58, 64],
665
+ // [139, 154]
666
+ // ];
667
+ ```
668
+
669
+ ***
670
+
671
+ ### set()
672
+
673
+ ```ts
674
+ set(
675
+ row,
676
+ col,
677
+ value): boolean;
678
+ ```
679
+
680
+ Defined in: [data-structures/matrix/matrix.ts:304](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L304)
681
+
682
+ The set function updates the value at a specified row and column in a two-dimensional array.
683
+
684
+ #### Parameters
685
+
686
+ ##### row
687
+
688
+ `number`
689
+
690
+ The "row" parameter represents the row index of the element in a
691
+ two-dimensional array or matrix. It specifies the row where the value will be set.
692
+
693
+ ##### col
694
+
695
+ `number`
696
+
697
+ The "col" parameter represents the column index of the element in a
698
+ two-dimensional array.
699
+
700
+ ##### value
701
+
702
+ `number`
703
+
704
+ The value parameter represents the number that you want to set at the
705
+ specified row and column in the data array.
706
+
707
+ #### Returns
708
+
709
+ `boolean`
710
+
711
+ a boolean value. It returns true if the index (row, col) is valid and the value is
712
+ successfully set in the data array. It returns false if the index is invalid and the value is not
713
+ set.
714
+
715
+ *
716
+
717
+ #### Example
718
+
719
+ ```ts
720
+ // Modify individual cells
721
+ const m = Matrix.zeros(2, 2);
722
+ console.log(m.set(0, 0, 5)); // true;
723
+ console.log(m.set(1, 1, 10)); // true;
724
+ console.log(m.get(0, 0)); // 5;
725
+ console.log(m.get(1, 1)); // 10;
726
+ ```
727
+
728
+ ***
729
+
730
+ ### subtract()
731
+
732
+ ```ts
733
+ subtract(matrix): Matrix | undefined;
734
+ ```
735
+
736
+ Defined in: [data-structures/matrix/matrix.ts:459](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L459)
737
+
738
+ The `subtract` function performs element-wise subtraction between two matrices and returns a new
739
+ matrix with the result.
740
+
741
+ #### Parameters
742
+
743
+ ##### matrix
744
+
745
+ `Matrix`
746
+
747
+ The `matrix` parameter is an instance of the `Matrix` class. It
748
+ represents the matrix that you want to subtract from the current matrix.
749
+
750
+ #### Returns
751
+
752
+ `Matrix` \| `undefined`
753
+
754
+ a new Matrix object with the result of the subtraction operation.
755
+
756
+ *
757
+
758
+ #### Example
759
+
760
+ ```ts
761
+ // Element-wise subtraction
762
+ const a = Matrix.from([[5, 6], [7, 8]]);
763
+ const b = Matrix.from([[1, 2], [3, 4]]);
764
+ const result = a.subtract(b);
765
+ console.log(result?.toArray()); // [[4, 4], [4, 4]];
766
+ ```
767
+
768
+ ***
769
+
770
+ ### toArray()
771
+
772
+ ```ts
773
+ toArray(): number[][];
774
+ ```
775
+
776
+ Defined in: [data-structures/matrix/matrix.ts:915](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L915)
777
+
778
+ Returns a deep copy of the data as a plain 2D array.
779
+
780
+ #### Returns
781
+
782
+ `number`[][]
783
+
784
+ ***
785
+
786
+ ### transpose()
787
+
788
+ ```ts
789
+ transpose(): Matrix;
790
+ ```
791
+
792
+ Defined in: [data-structures/matrix/matrix.ts:640](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L640)
793
+
794
+ The transpose function takes a matrix and returns a new matrix that is the transpose of the
795
+ original matrix.
796
+
797
+ #### Returns
798
+
799
+ `Matrix`
800
+
801
+ The transpose() function returns a new Matrix object with the transposed data.
802
+
803
+ *
804
+
805
+ #### Example
806
+
807
+ ```ts
808
+ // Matrix transpose (square matrix)
809
+ const m = new Matrix([
810
+ [1, 2, 3],
811
+ [4, 5, 6],
812
+ [7, 8, 9]
813
+ ]);
814
+
815
+ const transposed = m.transpose();
816
+ console.log(transposed.rows); // 3;
817
+ console.log(transposed.cols); // 3;
818
+ console.log(transposed.data); // [
819
+ // [1, 4, 7],
820
+ // [2, 5, 8],
821
+ // [3, 6, 9]
822
+ // ];
823
+
824
+ // Transpose of transpose = original
825
+ console.log(transposed.transpose().data); // m.data;
826
+ ```
827
+
828
+ ***
829
+
830
+ ### from()
831
+
832
+ ```ts
833
+ static from(data): Matrix;
834
+ ```
835
+
836
+ Defined in: [data-structures/matrix/matrix.ts:1022](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L1022)
837
+
838
+ Creates a Matrix from a plain 2D array (deep copy).
839
+
840
+ #### Parameters
841
+
842
+ ##### data
843
+
844
+ `number`[][]
845
+
846
+ #### Returns
847
+
848
+ `Matrix`
849
+
850
+ #### Example
851
+
852
+ ```ts
853
+ const m = Matrix.from([[1, 2], [3, 4]]);
854
+ m.get(0, 1); // 2
855
+ ```
856
+
857
+ ***
858
+
859
+ ### identity()
860
+
861
+ ```ts
862
+ static identity(n): Matrix;
863
+ ```
864
+
865
+ Defined in: [data-structures/matrix/matrix.ts:1007](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L1007)
866
+
867
+ Creates an n×n identity matrix.
868
+
869
+ #### Parameters
870
+
871
+ ##### n
872
+
873
+ `number`
874
+
875
+ #### Returns
876
+
877
+ `Matrix`
878
+
879
+ #### Example
880
+
881
+ ```ts
882
+ const I = Matrix.identity(3); // [[1,0,0],[0,1,0],[0,0,1]]
883
+ ```
884
+
885
+ ***
886
+
887
+ ### zeros()
888
+
889
+ ```ts
890
+ static zeros(rows, cols): Matrix;
891
+ ```
892
+
893
+ Defined in: [data-structures/matrix/matrix.ts:995](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L995)
894
+
895
+ Creates a rows×cols zero matrix.
896
+
897
+ #### Parameters
898
+
899
+ ##### rows
900
+
901
+ `number`
902
+
903
+ ##### cols
904
+
905
+ `number`
906
+
907
+ #### Returns
908
+
909
+ `Matrix`
910
+
911
+ #### Example
912
+
913
+ ```ts
914
+ const z = Matrix.zeros(2, 3); // [[0,0,0],[0,0,0]]
915
+ ```
916
+
917
+
918
+ ---
919
+
920
+ ## Protected Members
921
+
922
+ ### \_addScaledRow()
923
+
924
+ ```ts
925
+ protected _addScaledRow(
926
+ targetRow,
927
+ sourceRow,
928
+ scalar): void;
929
+ ```
930
+
931
+ Defined in: [data-structures/matrix/matrix.ts:1076](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L1076)
932
+
933
+ The function `_addScaledRow` multiplies a row in a matrix by a scalar value and adds it to another
934
+ row.
935
+
936
+ #### Parameters
937
+
938
+ ##### targetRow
939
+
940
+ `number`
941
+
942
+ The targetRow parameter represents the index of the row in which the
943
+ scaled values will be added.
944
+
945
+ ##### sourceRow
946
+
947
+ `number`
948
+
949
+ The sourceRow parameter represents the index of the row from which the
950
+ values will be scaled and added to the targetRow.
951
+
952
+ ##### scalar
953
+
954
+ `number`
955
+
956
+ The scalar parameter is a number that is used to scale the values in the
957
+ source row before adding them to the target row.
958
+
959
+ #### Returns
960
+
961
+ `void`
962
+
963
+ ***
964
+
965
+ ### \_scaleRow()
966
+
967
+ ```ts
968
+ protected _scaleRow(row, scalar): void;
969
+ ```
970
+
971
+ Defined in: [data-structures/matrix/matrix.ts:1058](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L1058)
972
+
973
+ The function scales a specific row in a matrix by a given scalar value.
974
+
975
+ #### Parameters
976
+
977
+ ##### row
978
+
979
+ `number`
980
+
981
+ The `row` parameter represents the index of the row in the matrix that you
982
+ want to scale. It is a number that indicates the position of the row within the matrix.
983
+
984
+ ##### scalar
985
+
986
+ `number`
987
+
988
+ The scalar parameter is a number that is used to multiply each element in
989
+ a specific row of a matrix.
990
+
991
+ #### Returns
992
+
993
+ `void`
994
+
995
+ ***
996
+
997
+ ### \_swapRows()
998
+
999
+ ```ts
1000
+ protected _swapRows(row1, row2): void;
1001
+ ```
1002
+
1003
+ Defined in: [data-structures/matrix/matrix.ts:1045](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/matrix/matrix.ts#L1045)
1004
+
1005
+ The function `_swapRows` swaps the positions of two rows in an array.
1006
+
1007
+ #### Parameters
1008
+
1009
+ ##### row1
1010
+
1011
+ `number`
1012
+
1013
+ The `row1` parameter is the index of the first row that you want to swap.
1014
+
1015
+ ##### row2
1016
+
1017
+ `number`
1018
+
1019
+ The `row2` parameter is the index of the second row that you want to swap
1020
+ with the first row.
1021
+
1022
+ #### Returns
1023
+
1024
+ `void`
1025
+
1026
+ ***