1#ifndef TMVA_RTENSOR_UTILS
2#define TMVA_RTENSOR_UTILS
12namespace Experimental {
19template <
typename T,
typename U>
24 if (columns.size() == 0) {
25 columns = dataframe.GetColumnNames();
30 std::vector<ResultPtr> resultPtrs;
31 for (
auto &col : columns) {
32 resultPtrs.emplace_back(dataframe.template Take<T>(col));
36 const auto numCols = resultPtrs.size();
37 const auto numEntries = resultPtrs[0]->size();
38 RTensor<T>
x({numEntries, numCols}, layout);
39 const auto data =
x.GetData();
40 if (layout == MemoryLayout::RowMajor) {
41 for (std::size_t i = 0; i < numEntries; i++) {
42 const auto entry = data + numCols * i;
43 for (std::size_t j = 0; j < numCols; j++) {
44 entry[j] = resultPtrs[j]->at(i);
47 }
else if (layout == MemoryLayout::ColumnMajor) {
48 for (std::size_t i = 0; i < numCols; i++) {
50 std::memcpy(data + numEntries * i, &resultPtrs[i]->at(0), numEntries *
sizeof(T));
53 throw std::runtime_error(
"Memory layout is not known.");
Smart pointer for the return type of actions.
RTensor< T > AsTensor(U &dataframe, std::vector< std::string > columns={}, MemoryLayout layout=MemoryLayout::RowMajor)
Convert the content of an RDataFrame to an RTensor.
MemoryLayout
Memory layout type (copy from RTensor.hxx)
create variable transformations