Skip to content

Commit 09668f5

Browse files
committed
Corrected memory access for vectors
1 parent dd9166a commit 09668f5

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

src/GraphBLAS-sharp/Implementations.fs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,15 +486,22 @@ and SparseVector<'a when 'a : struct and 'a : equality>(size: int, indices: int[
486486
if firstIndicesBuffer.[middleIdx] < secondIndicesBuffer.[i - middleIdx] then leftEdge <- middleIdx + 1 else rightEdge <- middleIdx - 1
487487

488488
let boundaryX, boundaryY = rightEdge, i - leftEdge
489-
let firstIndex = firstIndicesBuffer.[boundaryX]
490-
let secondIndex = secondIndicesBuffer.[boundaryY]
491489

492-
if boundaryX < 0 || boundaryY >= 0 && firstIndex < secondIndex then
493-
allIndicesBuffer.[i] <- secondIndex
490+
if boundaryX < 0 then
491+
allIndicesBuffer.[i] <- secondIndicesBuffer.[boundaryY]
494492
allValuesBuffer.[i] <- secondValuesBuffer.[boundaryY]
495-
else
496-
allIndicesBuffer.[i] <- firstIndex
493+
elif boundaryY < 0 then
494+
allIndicesBuffer.[i] <- firstIndicesBuffer.[boundaryX]
497495
allValuesBuffer.[i] <- firstValuesBuffer.[boundaryX]
496+
else
497+
let firstIndex = firstIndicesBuffer.[boundaryX]
498+
let secondIndex = secondIndicesBuffer.[boundaryY]
499+
if firstIndex < secondIndex then
500+
allIndicesBuffer.[i] <- secondIndex
501+
allValuesBuffer.[i] <- secondValuesBuffer.[boundaryY]
502+
else
503+
allIndicesBuffer.[i] <- firstIndex
504+
allValuesBuffer.[i] <- firstValuesBuffer.[boundaryX]
498505
@>
499506

500507
let createSortedConcatenation =

0 commit comments

Comments
 (0)