Skip to content

Commit

Permalink
Merge pull request #8 from afossa/main
Browse files Browse the repository at this point in the history
invert and eval functions with Julia Vector{}
  • Loading branch information
afossa authored May 9, 2024
2 parents 5531671 + e3e2dd9 commit 5d55f02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Manifest.toml
docs/build/
docs/src/generated/
.vscode
*.pdf
11 changes: 9 additions & 2 deletions src/DACE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,17 @@ module DACE
@eval Base.setindex!(v::AlgebraicVector{<:DA}, x::Real, i::Integer) = v[i] = convert(DA, x)
@eval Base.setindex!(m::AlgebraicMatrix{<:DA}, x::Real, i::Integer, j::Integer) = m[i,j] = convert(DA, x)

# wrappers for map inversion
invert(v::Vector{<:DA}) = Vector{DA}(invert(AlgebraicVector(v)))

# wrappers for compilation and evaluation of DA objects
compile(v::Vector{<:DA}) = compile(StdVector{DA}(v))
eval(cda::compiledDA, v::Vector{<:DA}) = eval(cda, StdVector{DA}(v))
eval(cda::compiledDA, v::Vector{Float64}) = eval(cda, StdVector{Float64}(v))
for R in (DA, Float64)
@eval eval(cda::compiledDA, v::Vector{<:$R}) = Vector{$R}(eval(cda, AlgebraicVector(v)))
@eval eval(da::DA, v::Vector{<:$R}) = eval(da, AlgebraicVector(v))
@eval eval(a::Vector{<:DA}, v::Vector{<:$R}) = Vector{$R}(eval(AlgebraicVector(a), AlgebraicVector(v)))
@eval eval(a::AlgebraicVector{DA}, v::Vector{<:$R}) = Vector{$R}(eval(a, AlgebraicVector(v)))
end

# define some exports
export DA, AlgebraicVector, AlgebraicMatrix, compiledDA
Expand Down

0 comments on commit 5d55f02

Please sign in to comment.