Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/longemen3000/forwarddiffovermeasurements.jl
desambiguation, ForwardDiff over Measurements
https://github.com/longemen3000/forwarddiffovermeasurements.jl
Last synced: about 2 months ago
JSON representation
desambiguation, ForwardDiff over Measurements
- Host: GitHub
- URL: https://github.com/longemen3000/forwarddiffovermeasurements.jl
- Owner: longemen3000
- License: mit
- Created: 2022-03-11T04:17:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-24T00:52:20.000Z (over 1 year ago)
- Last Synced: 2024-10-13T23:32:38.255Z (3 months ago)
- Language: Julia
- Size: 15.6 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://github.com/longemen3000/ForwardDiffOverMeasurements.jl/workflows/CI/badge.svg)](https://github.com/longemen3000/ForwardDiffOverMeasurements.jl/actions)
# ForwardDiffOverMeasurements
## Motivation
starting with:
```julia
f(x,y) = x*y*exp(x+y) + 2x-2y + x/y
```
This is fine:
```julia
using Measurements
f(x,y) = x*y*exp(x+y) + 2x-2y + x/y
x1 = 1.0 ±0.1
y1 = 2.0 ±0.001
f(x1,y1) #fine
```
This is also fine:```julia
using ForwardDiff
x1 = 1.0
y1 = 2.0
dfx(x,y) = ForwardDiff.derivative(_x -> f(_x,y),x)
dfx(x1,y1) #also fine
```But,this combination is **not** fine:
```julia
using ForwardDiff,Measurements
x1 = 1.0 ±0.1
y1 = 2.0 ±0.001
dfx(x,y) = ForwardDiff.derivative(_x -> f(_x,y),x)
dfx(x1,y1) #NOT FINE
```
Solution:```julia
using ForwardDiff,Measurements,ForwardDiffOverMeasurements
x1 = 1.0 ±0.1
y1 = 2.0 ±0.001
dfx(x,y) = ForwardDiff.derivative(_x -> f(_x,y),x)
dfx(x1,y1) #fine again
```## Usage
on the REPL:
```
>julia ]
(@v1.7) pkg> add ForwardDiffOverMeasurements
>julia using ForwardDiffOverMeasurements
```The package loads promote rules and some basic operations that favor a `ForwardDiff.Dual` over a `Measurements.Measurement`, so this holds:
```julia
f(x::Dual,y::Measurement)::Dual
```
The package does not export anything nor does define new functions.At the moment, `+`, `-`, `*`, and `/` are defined. if any Base function is missing, please open an issue.