Skip to content

Commit

Permalink
Merge pull request #148 from baggepinnen/cache
Browse files Browse the repository at this point in the history
Cache
  • Loading branch information
baggepinnen committed Feb 1, 2024
2 parents a03ba25 + 695bdb0 commit 8ef33cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/cache@v1
- uses: julia-actions/setup-julia@latest
with:
version: '1'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- uses: julia-actions/cache@v1
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}
Expand Down
15 changes: 13 additions & 2 deletions src/basis_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ end
"""
kautz(a::Vector, h)
Construct a discrete-time Kautz basis with poles at `a` amd sample time `h`.
Construct a discrete-time Kautz basis with poles at `a` and sample time `h`.
"""
function kautz(a::AbstractVector, h)
if maximum(abs, a) > 1
if all(>(0) real, a)
a = -a
end
a = exp.(h .* a)
@assert all(<(1) abs, a) "Including ustable poles does not make sense"
@assert all(<(1) abs, a) "Including unstable poles does not make sense"
end
factors = basis_factor.(a)
Q = factors[1]
Expand All @@ -54,6 +54,7 @@ end
Construct an output orthogonalized Laguerre basis of length `Nq` with poles at `-a`.
"""
function laguerre_oo(a::Number, Nq)
# Ref: "Laguerre Bases for Youla-Parametrized Optimal-Controller Design: Numerical Issues and Solutions" Olle Kjellqvist
A = diagm(fill(-a, Nq))
for i = 2:Nq
A[diagind(A, i-1)] .+= 2a*(-1)^i
Expand Down Expand Up @@ -193,6 +194,12 @@ function ControlSystemsBase.freqresp(P::LTISystem, basis::SomeBasis, ω::Abstrac
Gmat*p
end


"""
sum_basis(basis, p::AbstractVector)
Form a linear combination of the systems in `basis` with coefficients `p`.
"""
function sum_basis(basis::AbstractVector, p::AbstractVector)
out = ss(p[1]*basis[1])
for i in 2:length(p)
Expand All @@ -211,7 +218,11 @@ function sum_basis(basis::AbstractStateSpace, p::AbstractVector)
end
end

"""
basis_responses(basis::AbstractVector, ω; inverse = false)
Compute the frequency-response of each system in an LTI-system basis.
"""
function basis_responses(basis::AbstractVector, ω; inverse=false)
inverse && (basis = inv.(basis))
Gs = freqresp.(basis, Ref(ω))
Expand Down

0 comments on commit 8ef33cc

Please sign in to comment.