-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55a386d
commit c424965
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Manifest.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[deps] | ||
TypedMatrices = "a0429a07-0388-4c37-a18a-23d110f8915c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using BenchmarkTools | ||
|
||
@inline function f1(A, i) | ||
@boundscheck checkbounds(A, i) | ||
return @inbounds g(1:2, -1) | ||
end | ||
|
||
@inline Base.@propagate_inbounds function f2(A, i) | ||
@boundscheck checkbounds(A, i) | ||
return g(1:2, -1) | ||
end | ||
|
||
@inline function g(A, i) | ||
@boundscheck checkbounds(A, i) | ||
return "g: accessing ($A)[$i]" | ||
end | ||
|
||
function test_f1() | ||
for i = 1:100000 | ||
@inbounds f1(1:2, -1) | ||
end | ||
end | ||
|
||
function test_f2() | ||
for i = 1:100000 | ||
@inbounds f2(1:2, -1) | ||
end | ||
end | ||
|
||
function main() | ||
@inbounds f1(1:2, -1) | ||
@inbounds f2(1:2, -1) | ||
|
||
t1 = @benchmark test_f1() | ||
t2 = @benchmark test_f2() | ||
display(t1) | ||
display(t2) | ||
end | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using LinearAlgebra | ||
using MatrixDepot | ||
using TypedMatrices | ||
|
||
function compare(name::String, typedT::Type{T}, args...) where {T<:AbstractMatrix} | ||
depot = matrixdepot(name, args...) | ||
typed = typedT(args...) | ||
# display(depot) | ||
# display(typed) | ||
# @show norm(typed - depot) | ||
return typed ≈ depot | ||
end | ||
|
||
function linearalgebra_is_tests(A::AbstractMatrix) | ||
return Dict( | ||
:diag => isdiag(A), | ||
:hermitian => ishermitian(A), | ||
:posdef => isposdef(A), | ||
:symmetric => issymmetric(A), | ||
) | ||
end | ||
|
||
MT = Clement | ||
name = "clement" | ||
|
||
# linear algebra properties | ||
for i = 1:10 | ||
matrix = MT(i) | ||
test_result_type = linearalgebra_is_tests(matrix) | ||
test_result_matrix = linearalgebra_is_tests(Matrix(matrix)) | ||
if test_result_type != test_result_matrix || true | ||
display(matrix) | ||
@show i, test_result_type, test_result_matrix | ||
end | ||
end | ||
|
||
# compare elements | ||
for i = 1:10 | ||
result = compare(name, MT, i) | ||
if !result || false | ||
@show i, result | ||
end | ||
end |