Thank you for your help with this!
This is part of the project JuliaPetra (as I mentioned “using JuliaPetra”) so I’m not sure the best way to show you all the code, but here is the DenseMultiVector constructors:
function DenseMultiVector{Data}(map::BlockMap{GID, PID, LID}, numVecs::Integer, zeroOut=true) where {Data <: Number, GID <: Integer, PID <: Integer, LID <: Integer}
localLength = numMyElements(map)
if zeroOut
data = zeros(Data, (localLength, numVecs))
else
data = Array{Data, 2}(undef, localLength, numVecs)
end
DenseMultiVector{Data, GID, PID, LID}(data, numVecs, map)
end
function DenseMultiVector(map::BlockMap{GID, PID, LID}, data::AbstractArray{Data, 2}) where {Data <: Number, GID <: Integer, PID <: Integer, LID <: Integer}
localLength = numMyElements(map)
if size(data, 1) != localLength
throw(InvalidArgumentError("Length of vectors does not match local length indicated by map"))
end
DenseMultiVector{Data, GID, PID, LID}(data, size(data, 2), map)
end
and then how I construct it to run the update function:
function update(a, A::MultiVector, b, B::MultiVector)
if numVectors(A) == numVectors(B) && localLength(A) == localLength(B)
myComm = SerialComm{Int, Int, Int}()
myMap = BlockMap(numVectors(A), localLength(A), myComm)
data = Array{Float32}(undef, localLength(A), numVectors(A))
result = DenseMultiVector{}(myMap, data)
A = scale!(A, a)
B = scale!(B, b)
for i = 1:numVectors(A)
for j = 1:localLength(A)
result[i,j] = A[i,j] + B[i,j]
end
end
else
println("Error: MultiVectors must be the same size")
end
return result
end
v1 = DenseMultiVector(curMap, ones(Float64, 2, 2))
v2 = DenseMultiVector(curMap, ones(Float64, 2, 2))
println("Update: ", update(2, v1, 3, v2))
What I expect is for the result to print [5.0 5.0; 5.0 5.0] but what is printed is [5.0 0.0; 5.0 0.0]. And when I do @show result[i,j] after it’s assignment, it prints: 5.0 0.0 5.0 0.0, just as is shown in the result.