diff --git a/src/arrays/skew_symmetric.jl b/src/arrays/skew_symmetric.jl index 3c14b9e45..058345ab3 100644 --- a/src/arrays/skew_symmetric.jl +++ b/src/arrays/skew_symmetric.jl @@ -1,16 +1,12 @@ -""" -A `SkewSymMatrix` is a matrix -| 0 -S | -| S 0 | - +@doc raw""" +A `SkewSymMatrix` is a matrix ``A`` s.t. ``A^T = -A``. -If the constructor is called with a matrix as input it returns a symmetric matrix via the projection -A ↦ .5*(A - Aᵀ). -This is a projection defined via the canonical metric (A,B) ↦ tr(AᵀB). +If the constructor is called with a matrix as input it returns a symmetric matrix via the projection ``A \mapsto \frac{1}{2}(A - A^T)``. +This is a projection defined via the canonical metric ``\mathbb{R}^{n\times{}n}\times\mathbb{R}^{n\times{}n}\to\mathbb{R}, (A,B) \mapsto \mathrm{Tr}(A^TB)``. The first index is the row index, the second one the column index. -TODO: Check how LinearAlgebra implements matrix multiplication! +The struct two fields: `S` and `n`. The first stores all the entries of the matrix in a sparse fashion (in a vector) and the second is the dimension ``n`` for ``A\in\mathbb{R}^{n\times{}n}``. """ mutable struct SkewSymMatrix{T, AT <: AbstractVector{T}} <: AbstractMatrix{T} @@ -171,11 +167,6 @@ function Base.:*(A::SkewSymMatrix, b::AbstractVector{T}) where T A*reshape(b, size(b), 1) end -@kernel function write_ones_kernel!(unit_matrix::AbstractMatrix{T}) where T - i = @index(Global) - unit_matrix[i, i] = one(T) -end - function Base.one(A::SkewSymMatrix{T}) where T backend = KernelAbstractions.get_backend(A.S) unit_matrix = KernelAbstractions.zeros(backend, T, A.n, A.n) diff --git a/src/arrays/symmetric.jl b/src/arrays/symmetric.jl index 761e8dd72..0fcd7b506 100644 --- a/src/arrays/symmetric.jl +++ b/src/arrays/symmetric.jl @@ -1,9 +1,5 @@ @doc raw""" -A `SymmetricMatrix` is a matrix -| a S | -| S b | - -The first index is the row index, the second one the column index. +A `SymmetricMatrix` ``A`` is a matrix ``A^T = A``. If the constructor is called with a matrix as input it returns a symmetric matrix via the projection: ```math @@ -17,7 +13,7 @@ Internally the `struct` saves a vector $S$ of size $n(n+1)\div2$. The conversion S[( (j-1) j ) \div 2 + i] & \text{else}. \end{cases} ``` -So $S$ stores a string of vectors taken from $A$: $S = [\tilde{a}_1, \tilde{a}_2, \ldots, \tilde{a}_n]$ with $\tilde{a}_i = [[A]_{i1},[A]_{i2},\ldots,[A]_{ii}]$. +So ``S`` stores a string of vectors taken from $A$: $S = [\tilde{a}_1, \tilde{a}_2, \ldots, \tilde{a}_n]$ with $\tilde{a}_i = [[A]_{i1},[A]_{i2},\ldots,[A]_{ii}]$. TODO: - [x] Overload Adjoint operation for SymmetricMatrix!! (Aᵀ = A) diff --git a/src/utils.jl b/src/utils.jl index cfe00ba08..16f447f53 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -63,6 +63,13 @@ function Base.:+(a::Vector{Float64}, b::Tuple{Float64}) return y+x end +""" +Kernel that is needed for functions relating to `SymmetricMatrix` and `SkewSymMatrix` +""" +@kernel function write_ones_kernel!(unit_matrix::AbstractMatrix{T}) where T + i = @index(Global) + unit_matrix[i, i] = one(T) +end # overloaded similar operation to work with NamedTuples _similar(x) = similar(x) @@ -76,7 +83,6 @@ function _similar(x::NamedTuple) end # utils functions on string - function type_without_brace(var) type_str = string(typeof(var)) replace(type_str, r"\{.*\}"=>"") @@ -91,8 +97,7 @@ function center_align_text(text,width) end -#The following are fallback functions - maybe you want to put them into a separate file - +# The following are fallback functions - maybe you want to put them into a separate file function global_section(::AbstractVecOrMat) nothing end \ No newline at end of file