Skip to content

Add .approximates. / .within. for complex #137

@bonachea

Description

@bonachea

Copied from BerkeleyLab/caffeine#251 :

      real(c_double), parameter :: tolerance = 0_c_double
      complex(c_double), dimension(size(values,1)) :: my_val, expected
      ...

      diag = &
        .all. (real(my_val, c_double) .approximates. real(expected, c_double) .within. tolerance) &
        .also. (.all. (real(aimag(my_val), c_double) .approximates. real(aimag(expected), c_double) .within. tolerance))

It would be nice if Julienne's .approximates. had direct support for complex types, so that the user doesn't have to write awkward expressions like the one above; I'd rather be able to write simply:

my_val .approximates. expected .within. tolerance

where my_val and expected have type complex(rkind) and tolerance has type real(rkind) and is applied independently to each component as shown above.

The current code above presumably also generates a less helpful error message when only one of the components is outside tolerance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions