Skip to content

Commit

Permalink
Merge pull request #228 from jdrugo/master
Browse files Browse the repository at this point in the history
Add Gram-Schmidt orthonormalization to test view speed
  • Loading branch information
andreasnoack authored Sep 7, 2018
2 parents f2ca653 + cc77f64 commit 67af382
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/array/ArrayBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,21 @@ include("subarray.jl")

n = samerand()

g = addgroup!(SUITE, "subarray", ["lucompletepiv"])
g = addgroup!(SUITE, "subarray", ["lucompletepiv", "gramschmidt"])

for s in (100, 250, 500, 1000)
m = samerand(s, s)
g["lucompletepivCopy!", s] = @benchmarkable perf_lucompletepivCopy!(fill!($m, $n))
g["lucompletepivSub!", s] = @benchmarkable perf_lucompletepivSub!(fill!($m, $n))
end

# Gram-Schmidt orthonormalization, using views to operate on matrix slices.

for s in (100, 250, 500, 1000)
m = samerand(s, s)
g["gramschmidt!", s] = @benchmarkable perf_gramschmidt!(fill!($m, $n))
end

#################
# concatenation #
#################
Expand Down
12 changes: 12 additions & 0 deletions src/array/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,15 @@ function perf_lucompletepivSub!(A)
end
return (A, rowpiv, colpiv)
end

function perf_gramschmidt!(U)
m = size(U, 2)
@inbounds for k = 1:m
uk = view(U,:,k)
for j = 1:k-1
uj = view(U,:,j)
uk .-= (uj uk) .* uj
end
uk ./= norm(uk)
end
end

0 comments on commit 67af382

Please sign in to comment.