Special functions
Since some atoms are not available in the base language or other packages we have implemented them here.
SymbolicAnalysis.dotsort Method
dotsort(x, y)
Sorts x
and y
and returns the dot product of the sorted vectors.
Arguments
- `x::AbstractVector`: A vector.
- `y::AbstractVector`: A vector.
SymbolicAnalysis.eigsummax Method
eigsummax(m::Symmetric, k)
Returns the sum of the k
largest eigenvalues of m
.
Arguments
- `m::Symmetric`: A symmetric matrix.
- `k::Int`: The Real of largest eigenvalues to sum.
SymbolicAnalysis.eigsummin Method
eigsummin(m::Symmetric, k)
Returns the sum of the k
smallest eigenvalues of m
.
Arguments
- `m::Symmetric`: A symmetric matrix.
- `k::Int`: The Real of smallest eigenvalues to sum.
SymbolicAnalysis.huber Function
huber(x, M=1)
Returns the Huber loss function of x
with threshold M
.
Arguments
- `x::Real`: A Real.
- `M::Real`: The threshold.
SymbolicAnalysis.invprod Method
invprod(x::AbstractVector)
Returns the inverse of the product of the elements of x
.
Arguments
- `x::AbstractVector`: A vector.
SymbolicAnalysis.lognormcdf Method
lognormcdf(x::Real)
Returns the log of the normal cumulative distribution function of x
.
Arguments
- `x::Real`: A Real.
SymbolicAnalysis.matrix_frac Method
matrix_frac(x::AbstractVector, P::AbstractMatrix)
Returns the quadratic form x' * P^{-1} * x
.
Arguments
- `x::AbstractVector`: A vector.
- `P::AbstractMatrix`: A matrix.
SymbolicAnalysis.perspective Method
perspective(f::Function, x, s::Real)
Returns the perspective function s * f(x / s)
.
Arguments
- `f::Function`: A function.
- `x`: A Real.
- `s::Real`: A positive Real.
SymbolicAnalysis.quad_form Method
quad_form(x::AbstractVector, P::AbstractMatrix)
Returns the quadratic form x' * P * x
.
Arguments
- `x::AbstractVector`: A vector.
- `P::AbstractMatrix`: A matrix.
SymbolicAnalysis.quad_over_lin Method
quad_over_lin(x::Real, y::Real)
Returns the quadratic over linear form x^2 / y
.
Arguments
- `x`: A Real or a vector.
- `y::Real`: A positive Real.
SymbolicAnalysis.sum_largest Method
sum_largest(x::AbstractMatrix, k)
Returns the sum of the k
largest elements of x
.
Arguments
- `x::AbstractMatrix`: A matrix.
- `k::Int`: The Real of largest elements to sum.
SymbolicAnalysis.sum_smallest Method
sum_smallest(x::AbstractMatrix, k)
Returns the sum of the k
smallest elements of x
.
Arguments
- `x::AbstractMatrix`: A matrix.
- `k::Int`: The Real of smallest elements to sum.
SymbolicAnalysis.trinv Method
trinv(x::AbstractMatrix)
Returns the trace of the inverse of x
.
Arguments
- `x::AbstractMatrix`: A matrix.
SymbolicAnalysis.tv Method
tv(x::AbstractVector{<:AbstractMatrix})
Returns the total variation of x
, defined as sum_{i,j} |x_{k+1}[i,j] - x_k[i,j]|
.
Arguments
- `x::AbstractVector`: A vector of matrices.
SymbolicAnalysis.tv Method
tv(x::AbstractVector{<:Real})
Returns the total variation of x
, defined as sum_i |x_{i+1} - x_i|
.
Arguments
- `x::AbstractVector`: A vector.
SymbolicAnalysis.affine_map Method
affine_map(f, X, B, Y)
affine_map(f, X, B, Ys)
Affine map, i.e., B + f(X, Y)
or B + sum(f(X, Y) for Y in Ys)
for a function f
where f
is a positive linear operator.
Arguments
- `f::Function`: One of the following functions: `conjugation`, `diag`, `tr` and `hadamard_product`.
- `X::Matrix`: A symmetric positive definite matrix.
- `B::Matrix`: A matrix.
- `Y::Matrix`: A matrix.
- `Ys::Vector{<:Matrix}`: A vector of matrices.
SymbolicAnalysis.conjugation Method
conjugation(X, B)
Conjugation of a matrix X
by a matrix B
is defined as B'X*B
.
Arguments
- `X::Matrix`: A symmetric positive definite matrix.
- `B::Matrix`: A matrix.
SymbolicAnalysis.hadamard_product Method
hadamard_product(X, B)
Hadamard product or element-wise multiplication of a symmetric positive definite matrix X
by a positive semi-definite matrix B
.
Arguments
- `X::Matrix`: A symmetric positive definite matrix.
- `B::Matrix`: A positive semi-definite matrix.
SymbolicAnalysis.log_quad_form Method
log_quad_form(y, X)
log_quad_form(ys, X)
Log of the quadratic form of a symmetric positive definite matrix X
and a vector y
is defined as log(y'*X*y)
or for a vector of vectors ys
as log(sum(y'*X*y for y in ys))
.
Arguments
- `y::Vector`: A vector of `Number`s or a `Vector` of `Vector`s.
- `X::Matrix`: A symmetric positive definite matrix.
SymbolicAnalysis.scalar_mat Function
scalar_mat(X, k=size(X, 1))
Scalar matrix of a symmetric positive definite matrix X
is defined as tr(X)*I(k)
.
Arguments
- `X::Matrix`: A symmetric positive definite matrix.
- `k::Int`: The size of the identity matrix.
SymbolicAnalysis.schatten_norm Function
schatten_norm(X, p=2)
Schatten norm of a symmetric positive definite matrix X
.
Arguments
- `X::Matrix`: A symmetric positive definite matrix.
- `p::Int`: The p-norm.
SymbolicAnalysis.sdivergence Method
sdivergence(X, Y)
Symmetric divergence of two symmetric positive definite matrices X
and Y
is defined as logdet((X+Y)/2) - 1/2*logdet(X*Y)
.
Arguments
- `X::Matrix`: A symmetric positive definite matrix.
- `Y::Matrix`: A symmetric positive definite matrix.
SymbolicAnalysis.sum_log_eigmax Method
sum_log_eigmax(X, k)
sum_log_eigmax(f, X, k)
Sum of the log of the maximum eigenvalues of a symmetric positive definite matrix X
. If a function f
is provided, the sum is over f
applied to the log of the eigenvalues.
Arguments
- `f::Function`: A function.
- `X::Matrix`: A symmetric positive definite matrix.
- `k::Int`: The number of eigenvalues to consider.