Skip to content

Rework unary ops - #632

Open
arcondello wants to merge 1 commit into
dwavesystems:mainfrom
arcondello:feature/functional-rework
Open

arcondello wants to merge 1 commit into
dwavesystems:mainfrom
arcondello:feature/functional-rework

Conversation

@arcondello

Copy link
Copy Markdown
Member

Rework the ops in functional.hpp to carry more information. This is then used in some bigger changes to:

AI Generation Disclosure

Claude helped a lot with this one. Mostly by catching edge cases in the funcs, implementing a few of them once I showed it the pattern (e.g., rint) and by helping to write the tests. In the end, most of the code was actually written by me once I made all the changes I wanted.

@arcondello arcondello added the enhancement New feature or request label Sep 8, 2026
@arcondello arcondello mentioned this pull request Sep 8, 2026
@arcondello
arcondello marked this pull request as ready for review September 8, 2026 15:58
Comment on lines +42 to +45
assert(
domain <= UnaryOp::template domain<T> and
"input domain must be a subset of the func's domain"
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a HOT minute to realize the two domain here were different 🤦

struct logical : UnaryOpMixin<logical> {
static bool operator()(const DType auto& x) { return x; }

static interval<bool> operator()(const interval<bool>& domain) { return domain; }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming that, the reason we do not need

        if (not static_cast<bool>(domain)) return {};  // op(empty domain) -> empty domain

here is because it is absorbed by returning domain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants