Skip to content

Commit ec8e839

Browse files
committed
Testing skipping non positive values
1 parent ebf78d1 commit ec8e839

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/p_vector.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,24 @@ function dense_vector(I,V,n)
555555
T = eltype(V)
556556
a = zeros(T,n)
557557
for (i,v) in zip(I,V)
558+
if i < 1
559+
continue
560+
end
558561
a[i] += v
559562
end
560563
a
561564
end
562565

566+
function dense_vector!(A,K,V)
567+
fill!(A,0)
568+
for (k,v) in zip(K,V)
569+
if k < 1
570+
continue
571+
end
572+
A[k] += v
573+
end
574+
end
575+
563576
function pvector(I,V,rows;kwargs...)
564577
pvector(dense_vector,I,V,rows;kwargs...)
565578
end
@@ -665,16 +678,10 @@ end
665678
pvector!(B::PVector,V,cache)
666679
"""
667680
function pvector!(B,V,cache)
668-
function update!(A,K,V)
669-
fill!(A,0)
670-
for (k,v) in zip(K,V)
671-
A[k] += v
672-
end
673-
end
674681
(A,cacheB,assemble,assembled,K) = cache
675682
rows_sa = partition(axes(A,1))
676683
values_sa = partition(A)
677-
map(update!,values_sa,K,V)
684+
map(dense_vector!,values_sa,K,V)
678685
if !assembled && assemble
679686
t = PartitionedArrays.assemble!(B,A,cacheB)
680687
else

test/p_sparse_matrix_tests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ function p_sparse_matrix_tests(distribute)
206206
if part == 1
207207
[1,2,1,2,2], [2,6,1,2,1], [1.0,2.0,30.0,10.0,1.0]
208208
elseif part == 2
209-
[3,3,4,6], [3,9,4,2], [10.0,2.0,30.0,2.0]
209+
[3,3,4,6,0], [3,9,4,2,0], [10.0,2.0,30.0,2.0,2.0]
210210
elseif part == 3
211211
[5,5,6,7], [5,6,6,7], [10.0,2.0,30.0,1.0]
212212
else
213-
[9,9,8,10,6], [9,3,8,10,5], [10.0,2.0,30.0,50.0,2.0]
213+
[9,9,8,10,6,-1], [9,3,8,10,5,1], [10.0,2.0,30.0,50.0,2.0,1.0]
214214
end
215215
end |> tuple_of_arrays
216216

0 commit comments

Comments
 (0)