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 IS_COVARIANT and IS_CONTRAVARIANT properties to continuous dimensions #38

Open
EmilyBourne opened this issue Jan 7, 2025 · 3 comments

Comments

@EmilyBourne
Copy link
Member

EmilyBourne commented Jan 7, 2025

Add IS_COVARIANT, IS_CONTRAVARIANT and dual properties to continuous dimensions. E.g:

class X {
    /**
     * @brief A boolean indicating if the dimension is periodic.
     */
    static bool constexpr PERIODIC = false;

    static bool constexpr IS_COVARIANT = true;
    static bool constexpr IS_CONTRAVARIANT = true;

    using Dual = X;
};

class R;
class R_cov;

class R {
    /**
     * @brief A boolean indicating if the dimension is periodic.
     */
    static bool constexpr PERIODIC = false;

    static bool constexpr IS_COVARIANT = false;
    static bool constexpr IS_CONTRAVARIANT = true;

    using Dual = R_cov;
};

class R_cov {
    /**
     * @brief A boolean indicating if the dimension is periodic.
     */
    static bool constexpr PERIODIC = false;

    static bool constexpr IS_COVARIANT = true;
    static bool constexpr IS_CONTRAVARIANT = false;

    using Dual = R;
};

template<class Dim, typename = std::enable_if_t<Dim::IS_CONTRAVARIANT>>
using to_covariant_t = typename Dim::dual;

template<class Dim, typename = std::enable_if_t<Dim::IS_COVARIANT>>
using to_contravariant_t = typename Dim::dual;
@EmilyBourne
Copy link
Member Author

@gdgirard Do you agree with these names? Specifically Dual to represent the matching covariant/contravariant type?

@gdgirard
Copy link
Member

gdgirard commented Jan 7, 2025

Dual seems fine for me. But maybe R_cov instead of R_co otherwise difficult to remember that _co is for covariant and not for contravariant

@EmilyBourne
Copy link
Member Author

Dual seems fine for me. But maybe R_cov instead of R_co otherwise difficult to remember that _co is for covariant and not for contravariant

Sounds good. I have updated the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants