Skip to content

Commit 77eff3a

Browse files
committed
refactor: remove add method from SparseMatrix class
1 parent 72db1dd commit 77eff3a

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

src/index.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,28 +156,13 @@ export class SparseMatrix {
156156
return this;
157157
}
158158

159-
add(other) {
160-
if (typeof other === 'number') return this.addS(other);
161-
if (this.rows !== other.rows || this.columns !== other.columns) {
162-
throw new RangeError('Matrices dimensions must be equal');
163-
}
164-
165-
other.withEachNonZero((i, j, v) => {
166-
this.set(i, j, v + this.get(i, j));
167-
});
168-
169-
return this;
170-
}
171-
172159
mul(other) {
173160
if (typeof other !== 'number') {
174161
throw new RangeError('the argument should be a number');
175162
}
176163

177164
if (other === 0) {
178-
return new SparseMatrix(this.rows, this.columns, {
179-
initialCapacity: this.cardinality,
180-
});
165+
return new SparseMatrix(this.rows, this.columns);
181166
}
182167

183168
this.withEachNonZero((i, j, v) => {

0 commit comments

Comments
 (0)