I can’t reproduce the difference, and my printed values are close to but not exactly either of your results. Save those 2 vectors to y and z then check all(iszero, y .- z) in case it’s just some odd display rounding. If it’s some platform-specific issue, share your full versioninfo().
Here’s what I see:
julia> versioninfo()
Julia Version 1.12.6
Commit 15346901f0 (2026-04-09 19:20 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 8 × Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, icelake-client)
GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)
julia> using Random; Random.seed!(1);
julia> y = [sum(xhmat[d, :]) for d in 1:10];
julia> z = [sum(view(xhmat, d, :)) for d in 1:10];
julia> all(iszero, y .- z)
true
julia> y # z prints the same thing
10-element Vector{Float32}:
6.143616
31.913727
9.005218
-40.030968
-48.173264
-6.9555407
35.577076
-33.41585
12.131446
-22.086918
julia> y = [sum(xhmat[d, :]) for d in 1:10];
julia> z = [sum(view(xhmat, d, :)) for d in 1:10];
julia> all(iszero, y .- z)
false
julia> any(iszero, y .- z)
false
julia> versioninfo()
Julia Version 1.12.6
Commit 15346901f00 (2026-04-09 19:20 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: macOS (arm64-apple-darwin24.0.0)
CPU: 24 × Apple M2 Ultra
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, apple-m2)
GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 16 virtual cores)
Environment:
DYLD_LIBRARY_PATH = /Developer/NVIDIA/CUDA-9.1/lib:
JULIA_EDITOR = Atom