# Std methods for ROOT::VecOps::RVec?

**URL:** <https://root-forum.cern.ch/t/std-methods-for-root-rvec/49546>\
**Category:** ROOT\
**Tags:** rdataframe, vecops\
**Created:** [April 11, 2022, 3:39pm UTC](https://root-forum.cern.ch/t/std-methods-for-root-rvec/49546 "2022-04-11T15:39:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FoxWise](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/foxwise/32/37588_2.png) [@FoxWise](https://root-forum.cern.ch/u/FoxWise)\
**Post date:** [April 11, 2022, 3:39pm UTC](https://root-forum.cern.ch/t/std-methods-for-root-rvec/49546/1 "2022-04-11T15:39:22Z")

</div>

Hi all,

I wonder if it would be easy to implement all std methods to be able to run smoothly with `RVec`?  
I would find it very useful.

What I mean is able to run something like this:

```python
import ROOT

df = ROOT.RDataFrame(1)
df = df.Define("x", "ROOT::VecOps::RVec<double> {-2, -1, -0, 1, 2}")

# get the same as df = df.Define("x2", "x*x")
df = df.Define("x2", "std::pow(x)")

# get the same as df = df.Define("x_abs", "x*(x >0)")
df = df.Define("x_abs", "std::abs(x)")

# well, why not this
df = df.Define("x_sin", "std::sin(x)")

# or this
df = df.Define("x_sqrt", "std::sqrt(x)")

# or even this?
df = df.Define("x_do_smart_math_thing", "std::sqrt(x*x) + 3* std::tan(x)*std::tan(x)")

```

These all are rather standard mathematical operations as well as `+`, `-`, `*`, `/`.  
Is it possible to implement something like this for `RVec` as it was done for operator overloading, so user doesn’t create a lambda function for each of these cases?

cheers,  
Bohdan

---

<div class="post-metadata">

**Author:** ![RENATO\_QUAGLIANI](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/renato_quagliani/32/19496_2.png) [@RENATO\_QUAGLIANI](https://root-forum.cern.ch/u/RENATO_QUAGLIANI)\
**Post date:** [April 11, 2022, 5:52pm UTC](https://root-forum.cern.ch/t/std-methods-for-root-rvec/49546/2 "2022-04-11T17:52:10Z")

</div>

Isnt that the case already? [ROOT: math/vecops/inc/ROOT/RVec.hxx Source File](https://root.cern.ch/doc/master/RVec_8hxx_source.html)  
From here i see many STD\_UNARY\_FUNCTION declarations…

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [April 11, 2022, 7:39pm UTC](https://root-forum.cern.ch/t/std-methods-for-root-rvec/49546/3 "2022-04-11T19:39:42Z")

</div>

Hi @FoxWise ,  
for the math functions, just use `sqrt(x)` instead of `std::sqrt(x)` and it should work (same for all other functions you mentioned).

For the STL algorithms, `x.begin()` and `x.end()` can be passed as usual.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [April 25, 2022, 7:40pm UTC](https://root-forum.cern.ch/t/std-methods-for-root-rvec/49546/4 "2022-04-25T19:40:43Z")

</div>

Closed on April 25, 2022, 7:40pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
