Skip to content

Commit 082cc7d

Browse files
committed
Initial commit
1 parent 2e72e6e commit 082cc7d

File tree

2 files changed

+102
-102
lines changed

2 files changed

+102
-102
lines changed

src/ndsparsearray.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ Modifies `A` and returns it. More efficient than `A = A + B`.
498498
"""
499499
function add!(A::NDSparseArray{T, N}, B::NDSparseArray{S, N}) where {T, S, N}
500500
size(A) == size(B) || throw(DimensionMismatch("Array dimensions must match"))
501-
501+
502502
# Add elements from B, converting to A's type
503503
for (idx, val_b) in B.data
504504
if haskey(A.data, idx)
@@ -509,7 +509,7 @@ function add!(A::NDSparseArray{T, N}, B::NDSparseArray{S, N}) where {T, S, N}
509509
A.data[idx] = convert(T, val_b)
510510
end
511511
end
512-
512+
513513
return A
514514
end
515515

@@ -530,13 +530,13 @@ function add!(A::NDSparseArray{T}, scalar) where {T}
530530
catch MethodError
531531
# zero() not defined for this type, continue with the operation
532532
end
533-
533+
534534
# Add scalar to all stored values, converting to A's type
535535
scalar_converted = convert(T, scalar)
536536
for (idx, val) in A.data
537537
A.data[idx] = val + scalar_converted
538538
end
539-
539+
540540
return A
541541
end
542542

@@ -548,7 +548,7 @@ Modifies `A` and returns it. More efficient than `A = A - B`.
548548
"""
549549
function sub!(A::NDSparseArray{T, N}, B::NDSparseArray{S, N}) where {T, S, N}
550550
size(A) == size(B) || throw(DimensionMismatch("Array dimensions must match"))
551-
551+
552552
# Subtract elements from B, converting to A's type
553553
for (idx, val_b) in B.data
554554
val_b_converted = convert(T, val_b)
@@ -569,7 +569,7 @@ function sub!(A::NDSparseArray{T, N}, B::NDSparseArray{S, N}) where {T, S, N}
569569
end
570570
end
571571
end
572-
572+
573573
return A
574574
end
575575

@@ -590,13 +590,13 @@ function sub!(A::NDSparseArray{T}, scalar) where {T}
590590
catch MethodError
591591
# zero() not defined for this type, continue with the operation
592592
end
593-
593+
594594
# Subtract scalar from all stored values, converting to A's type
595595
scalar_converted = convert(T, scalar)
596596
for (idx, val) in A.data
597597
A.data[idx] = val - scalar_converted
598598
end
599-
599+
600600
return A
601601
end
602602

@@ -618,20 +618,20 @@ function mul!(A::NDSparseArray{T}, scalar) where {T}
618618
catch MethodError
619619
# zero() not defined for this type, continue
620620
end
621-
621+
622622
try
623623
if scalar == one(typeof(scalar))
624624
return A
625625
end
626626
catch MethodError
627627
# one() not defined for this type, continue
628628
end
629-
629+
630630
# Multiply all stored values, converting scalar to A's type
631631
scalar_converted = convert(T, scalar)
632632
for (idx, val) in A.data
633633
A.data[idx] = val * scalar_converted
634634
end
635-
635+
636636
return A
637637
end

0 commit comments

Comments
 (0)