-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Michael F. Herbst <[email protected]>
- Loading branch information
Showing
6 changed files
with
153 additions
and
36 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
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
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,9 @@ | ||
# Create an array of same type as X filled with zeros, minimizing the number | ||
# of allocations. | ||
function zeros_like(X::AbstractArray, T::Type=eltype(X), dims::Integer...=size(X)...) | ||
Z = similar(X, T, dims...) | ||
Z .= 0 | ||
Z | ||
end | ||
zeros_like(X::AbstractArray, dims::Integer...) = zeros_like(X, eltype(X), dims...) | ||
zeros_like(X::Array, T::Type=eltype(X), dims::Integer...=size(X)...) = zeros(T, dims...) |
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
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,19 @@ | ||
# TODO: remove this when it is implemented in GPUArrays and CUDA | ||
import LinearAlgebra.dot, LinearAlgebra.eigen | ||
using LinearAlgebra | ||
using GPUArraysCore | ||
using CUDA | ||
|
||
# https://github.com/JuliaGPU/CUDA.jl/issues/1565 | ||
LinearAlgebra.dot(x::AbstractGPUArray, D::Diagonal,y::AbstractGPUArray) = x'*(D*y) | ||
|
||
# https://github.com/JuliaGPU/CUDA.jl/issues/1572 | ||
function LinearAlgebra.eigen(A::Hermitian{T,AT}) where {T <: Complex,AT <: CuArray} | ||
vals, vects = CUDA.CUSOLVER.heevd!('V','U', A.data) | ||
(vectors = vects, values = vals) | ||
end | ||
|
||
function LinearAlgebra.eigen(A::Hermitian{T,AT}) where {T <: Real,AT <: CuArray} | ||
vals, vects = CUDA.CUSOLVER.syevd!('V','U', A.data) | ||
(vectors = vects, values = vals) | ||
end |
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