Skip to content
Snippets Groups Projects

[WIP] Add applyEntrywise method

Open lh1887 requested to merge feature/inplace_binary into master
1 unresolved thread

With this tool, one can write quite general code to apply x = op(y) entrywise for vectors x, y (where y can indeed be a pack of vectors).

Edited by lh1887

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
44 45 Impl::ScalarSwitch<Vector>::truncate(v, tr);
45 46 }
46 47
48 /**! For a given operator "op", compute x = op(x,y) ENTRYWISE.
49 *
50 * If the op is not defined for the given types,
51 * the operator is recursively applied to subblocks
52 * until it can be used.
53 */
54 template<typename X, typename Y, typename BinaryOp>
55 void inplaceBinary(X&& x, Y&& y, BinaryOp&& op) {
56 if constexpr(Concept::isLegalBinaryOperator(x,y,op)) {
  • I'm not sure if this does what you want (leaving the constexpr issue aside): For vectors x and x x * y may be the defined to be inner product which is not what is claimed here.

  • Please register or sign in to reply
Please register or sign in to reply
Loading