Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add non pure-multiplicative conversions #1

Closed
5 tasks done
szaghi opened this issue Sep 2, 2016 · 1 comment
Closed
5 tasks done

Add non pure-multiplicative conversions #1

szaghi opened this issue Sep 2, 2016 · 1 comment

Comments

@szaghi
Copy link
Owner

szaghi commented Sep 2, 2016

For example support temperature-like conversions with offset, e.g.

  • celsius = 273.15 + 1 * K
  • fahrenheit = 255.372222 + 1 * K
  • american_wire_gauge = 8.62491 * log(1/mm) + 18.2019 * mm
  • dBm = 10 * log(mW)
  • mW = 10**(dBm / 10)

supported conversions

  • multiplicative-like
    • pure multiplicative: y = f * x
    • fixed_offset + multiplication: y = offset + f * x
  • non multiplicative
    • generic f(x) user provided

how to implement generic f(x) user-provided alias-conversion formula

The current alias-conversion formula is implemented into the most base uom_symbol class that looks like

type :: uom_symbol
    integer :: exponent
    real :: factor
    real :: offset
    type(string) :: symbol
endtype uom_symbol

As a matter of fact, currently only multiplicative-like conversion are supported

direct: f(x) = offset + factor * x
inverse: f(x) = (x - offset) / factor

This should/could be generalized by a procedure pointer attribute customizable by user, e.g.

type :: uom_symbol
    integer :: exponent
    real :: factor
    real :: offset
    type(string) :: symbol
    procedure (generic_conversion_interface), pointer, nopass :: generic_conversion => null()
endtype uom_symbol

interface
    function generic_conversion_interface(x, inverse)
        real, intent (in) :: x
        logical, intent(in), optional :: inverse
        real :: generic_conversion_interface
    end function generic_conversion_interface
end interface

The uom_symbol gramar must be modified to take into account this new scenario, e.g.

grammar: @user A

that means that the symbol A has a conversion(s) formula supplied by user.

The problem is how the user can supply these formula, uom_symbol being the most basic (almost hidden to user) class...

@szaghi
Copy link
Owner Author

szaghi commented Sep 9, 2016

Done in new 0.8.3

@szaghi szaghi closed this as completed Sep 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant