{
"cells": [
{
"cell_type": "markdown",
"id": "6f0e983c",
"metadata": {},
"source": [
"# vo005_Combinations\n",
"In this tutorial we learn how combinations of RVecs can be built.\n",
"\n",
"\n",
"\n",
"\n",
"**Author:** Stefan Wunsch \n",
"This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:28 PM."
]
},
{
"cell_type": "markdown",
"id": "42f3ce32",
"metadata": {},
"source": [
"The starting point are two collections and we want to calculate the result\n",
"of combinations of the elements."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "7dc7ec34",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:28:10.806829Z",
"iopub.status.busy": "2026-05-19T20:28:10.806702Z",
"iopub.status.idle": "2026-05-19T20:28:11.130009Z",
"shell.execute_reply": "2026-05-19T20:28:11.129159Z"
}
},
"outputs": [],
"source": [
"ROOT::RVecD v1{1., 2., 3.};\n",
"ROOT::RVecD v2{-4., -5.};"
]
},
{
"cell_type": "markdown",
"id": "7e0fa1ba",
"metadata": {},
"source": [
"To get the indices, which result in all combinations, you can call the\n",
"following helper.\n",
"Note that you can also pass the size of the vectors directly."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2af2f31a",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:28:11.131879Z",
"iopub.status.busy": "2026-05-19T20:28:11.131751Z",
"iopub.status.idle": "2026-05-19T20:28:11.339596Z",
"shell.execute_reply": "2026-05-19T20:28:11.338931Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_53:2:13: error: cannot deduce 'auto' from unknown expression\n",
" auto idx = Combinations(v1, v2);\n",
" ^\n"
]
}
],
"source": [
"auto idx = Combinations(v1, v2);"
]
},
{
"cell_type": "markdown",
"id": "1b4ad431",
"metadata": {},
"source": [
"Next, the respective elements can be taken via the computed indices."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "388c90ee",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:28:11.341081Z",
"iopub.status.busy": "2026-05-19T20:28:11.340963Z",
"iopub.status.idle": "2026-05-19T20:28:11.548728Z",
"shell.execute_reply": "2026-05-19T20:28:11.547993Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_54:2:12: error: cannot deduce 'auto' from unknown expression\n",
" auto c1 = Take(v1, idx[0]);\n",
" ^\n"
]
}
],
"source": [
"auto c1 = Take(v1, idx[0]);\n",
"auto c2 = Take(v2, idx[1]);"
]
},
{
"cell_type": "markdown",
"id": "fb9a8fa3",
"metadata": {},
"source": [
"Finally, you can perform any set of operations conveniently."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "a8a27f76",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:28:11.550205Z",
"iopub.status.busy": "2026-05-19T20:28:11.550086Z",
"iopub.status.idle": "2026-05-19T20:28:11.757779Z",
"shell.execute_reply": "2026-05-19T20:28:11.757098Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_55:2:12: error: cannot deduce 'auto' from unknown expression\n",
" auto v3 = c1 * c2;\n",
" ^\n"
]
}
],
"source": [
"auto v3 = c1 * c2;\n",
"\n",
"std::cout << \"Combinations of \" << v1 << \" and \" << v2 << \":\" << std::endl;\n",
"for(size_t i=0; i