Skip to content

Commit

Permalink
Testing skipping non positive values
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Feb 9, 2024
1 parent ebf78d1 commit ec8e839
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions src/p_vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,24 @@ function dense_vector(I,V,n)
T = eltype(V)
a = zeros(T,n)
for (i,v) in zip(I,V)
if i < 1
continue
end
a[i] += v
end
a
end

function dense_vector!(A,K,V)
fill!(A,0)
for (k,v) in zip(K,V)
if k < 1
continue
end
A[k] += v
end
end

function pvector(I,V,rows;kwargs...)
pvector(dense_vector,I,V,rows;kwargs...)
end
Expand Down Expand Up @@ -665,16 +678,10 @@ end
pvector!(B::PVector,V,cache)
"""
function pvector!(B,V,cache)
function update!(A,K,V)
fill!(A,0)
for (k,v) in zip(K,V)
A[k] += v
end
end
(A,cacheB,assemble,assembled,K) = cache
rows_sa = partition(axes(A,1))
values_sa = partition(A)
map(update!,values_sa,K,V)
map(dense_vector!,values_sa,K,V)
if !assembled && assemble
t = PartitionedArrays.assemble!(B,A,cacheB)
else
Expand Down
4 changes: 2 additions & 2 deletions test/p_sparse_matrix_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ function p_sparse_matrix_tests(distribute)
if part == 1
[1,2,1,2,2], [2,6,1,2,1], [1.0,2.0,30.0,10.0,1.0]
elseif part == 2
[3,3,4,6], [3,9,4,2], [10.0,2.0,30.0,2.0]
[3,3,4,6,0], [3,9,4,2,0], [10.0,2.0,30.0,2.0,2.0]
elseif part == 3
[5,5,6,7], [5,6,6,7], [10.0,2.0,30.0,1.0]
else
[9,9,8,10,6], [9,3,8,10,5], [10.0,2.0,30.0,50.0,2.0]
[9,9,8,10,6,-1], [9,3,8,10,5,1], [10.0,2.0,30.0,50.0,2.0,1.0]
end
end |> tuple_of_arrays

Expand Down

0 comments on commit ec8e839

Please sign in to comment.