You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix type instabilities for almost all functions (qutip#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
Qobj(M, dims = SVector(2, 2)) # dims as StaticArrays.SVector (recommended)
46
46
```
47
47
48
-
> [!IMPORTANT]
49
-
>Please note that here we put the `dims` as a tuple `(2, 2)`. Although it supports also `Vector` type (`dims = [2, 2]`), it is recommended to use `Tuple` or `SVector` from [`StaticArrays.jl`](https://github.com/JuliaArrays/StaticArrays.jl) to improve performance. For a brief explanation on the impact of the type of `dims`, see the Section [The Importance of Type-Stability](@ref doc:Type-Stability).
48
+
!!! warning "Beware of type-stability!"
49
+
Please note that here we put the `dims` as a tuple `(2, 2)`. Although it supports also `Vector` type (`dims = [2, 2]`), it is recommended to use `Tuple` or `SVector` from [`StaticArrays.jl`](https://github.com/JuliaArrays/StaticArrays.jl) to improve performance. For a brief explanation on the impact of the type of `dims`, see the Section [The Importance of Type-Stability](@ref doc:Type-Stability).
Represents a general linear map with element type `T` and size `TS`.
7
+
8
+
## Overview
9
+
10
+
A **linear map** is a transformation `L` that satisfies:
11
+
12
+
- **Additivity**:
13
+
```math
14
+
L(u + v) = L(u) + L(v)
15
+
```
16
+
- **Homogeneity**:
17
+
```math
18
+
L(cu) = cL(u)
19
+
```
20
+
21
+
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.
22
+
23
+
## Methods
24
+
25
+
- `Base.eltype(A)`: Returns the element type `T`.
26
+
- `Base.size(A)`: Returns the size `A.size`.
27
+
- `Base.size(A, i)`: Returns the `i`-th dimension.
28
+
29
+
## Example
30
+
31
+
As an example, we now define the linear map used in the [`eigsolve_al`](@ref) function for Arnoldi-Lindblad eigenvalue solver:
function LinearAlgebra.mul!(y::AbstractVector, A::ArnoldiLindbladIntegratorMap, x::AbstractVector)
41
+
reinit!(A.integrator, x)
42
+
solve!(A.integrator)
43
+
return copyto!(y, A.integrator.u)
44
+
end
45
+
```
46
+
47
+
where `integrator` is the ODE integrator for the time-evolution. In this way, we can diagonalize this linear map using the [`eigsolve`](@ref) function.
48
+
"""
49
+
abstract type AbstractLinearMap{T,TS} end
50
+
51
+
Base.eltype(A::AbstractLinearMap{T}) where {T} = T
It is highly recommended to use `permute(A, order)` with `order` as `Tuple` or `SVector` to keep type stability. See the [related Section](@ref doc:Type-Stability) about type stability for more details.
Copy file name to clipboardExpand all lines: src/qobj/functions.jl
+27-10Lines changed: 27 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ If `ψ` is a [`Ket`](@ref) or [`Bra`](@ref), the function calculates ``\langle\p
25
25
26
26
If `ψ` is a density matrix ([`Operator`](@ref)), the function calculates ``\textrm{Tr} \left[ \hat{O} \hat{\psi} \right]``
27
27
28
-
The function returns a real number if `O` is hermitian, and returns a complex number otherwise.
28
+
The function returns a real number if `O` is of `Hermitian` type or `Symmetric` type, and returns a complex number otherwise. You can make an operator `O` hermitian by using `Hermitian(O)`.
0 commit comments