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

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:

``````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

Isnt that the case already? ROOT: math/vecops/inc/ROOT/RVec.hxx Source File
From here i see many STD_UNARY_FUNCTION declarations…

1 Like

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

1 Like

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