Skip to content

Commit

Permalink
add description
Browse files Browse the repository at this point in the history
  • Loading branch information
xquan818 committed Sep 12, 2024
1 parent b41f246 commit 640db66
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/finitedual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ for pred in [:>, :<, :(==), :>=, :<=]
build_pred_table(y, $pred.(x, values(y)))
end

# The prediction function `f` acts on a matrix `A` could be computed by
# solving the Sylvester equation for a 2×2 block matrix.
# Compute `f(A)` by the Schur decomposition `f(A) = Z*f(T)*Z'`.
# First, reorder and divide `T` into a 2×2 matrix of upper triangular blocks,
# where one of the diagonal blocks has all eigenvalues meeting the prediction
# and the other does not. The corresponding diagonal parts of `F := f(T)` are
# the unit and zero matrices. By the commutativity relation FT = TF,
# there is the Sylvester equation: `T11*F12 - F12*T22 + (T12*F22-F11*T12) = 0`.
@inline function build_pred_table(x::FiniteDual{Tx,N}, pred_val) where {Tx,N}
S = schur(table(x))
block_size = pred_val[1] ? [sum(pred_val), N] : [N - sum(pred_val), N]
Expand All @@ -235,11 +243,11 @@ end
F = diagm(fx)
i = 1:block_size[1]
j = block_size[1]+1:block_size[2]
Y = F[i, i] * T[i, j] - T[i, j] * F[j, j]
Y = T[i, j] * F[j, j] - F[i, i] * T[i, j]

# solve Tii*Fij + Fij*(-Tjj) + (-Y) = 0
# solve Tii*Fij - Fij*Tjj + Y = 0
if length(i) > 1 || length(j) > 1
F[i, j] = sylvester(T[i, i], -T[j, j], -Y)
F[i, j] = sylvester(T[i, i], -T[j, j], Y)
else
F[i, j] = Y ./ (T[i, i] - T[j, j])
end
Expand Down

4 comments on commit 640db66

@xuequan818
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/115060

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.0 -m "<description of version>" 640db6648dd59c3019746d43787689401484954c
git push origin v1.1.0

@xuequan818
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: Version 1.1.0 already exists

Please sign in to comment.