-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix type instabilities for almost all functions (#221)
* Improve c_ops handling * Format code * Fix ptrace and operators * Make states stable * Fix type instabilities for qobj methods * FIx eigenvalues * Other fixes and format * Minor changes to dfd_mesolve * Fix typo * Remove version condition of runtest
- Loading branch information
1 parent
d736766
commit 6add50d
Showing
25 changed files
with
641 additions
and
170 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
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,54 @@ | ||
export AbstractLinearMap | ||
|
||
@doc raw""" | ||
AbstractLinearMap{T, TS} | ||
Represents a general linear map with element type `T` and size `TS`. | ||
## Overview | ||
A **linear map** is a transformation `L` that satisfies: | ||
- **Additivity**: | ||
```math | ||
L(u + v) = L(u) + L(v) | ||
``` | ||
- **Homogeneity**: | ||
```math | ||
L(cu) = cL(u) | ||
``` | ||
It is typically represented as a matrix with dimensions given by `size`, and this abtract type helps to define this map when the matrix is not explicitly available. | ||
## Methods | ||
- `Base.eltype(A)`: Returns the element type `T`. | ||
- `Base.size(A)`: Returns the size `A.size`. | ||
- `Base.size(A, i)`: Returns the `i`-th dimension. | ||
## Example | ||
As an example, we now define the linear map used in the [`eigsolve_al`](@ref) function for Arnoldi-Lindblad eigenvalue solver: | ||
```julia-repl | ||
struct ArnoldiLindbladIntegratorMap{T,TS,TI} <: AbstractLinearMap{T,TS} | ||
elty::Type{T} | ||
size::TS | ||
integrator::TI | ||
end | ||
function LinearAlgebra.mul!(y::AbstractVector, A::ArnoldiLindbladIntegratorMap, x::AbstractVector) | ||
reinit!(A.integrator, x) | ||
solve!(A.integrator) | ||
return copyto!(y, A.integrator.u) | ||
end | ||
``` | ||
where `integrator` is the ODE integrator for the time-evolution. In this way, we can diagonalize this linear map using the [`eigsolve`](@ref) function. | ||
""" | ||
abstract type AbstractLinearMap{T,TS} end | ||
|
||
Base.eltype(A::AbstractLinearMap{T}) where {T} = T | ||
|
||
Base.size(A::AbstractLinearMap) = A.size | ||
Base.size(A::AbstractLinearMap, i::Int) = A.size[i] |
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
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
Oops, something went wrong.