Commit 8894ce2ca25c5c2a82fae3a9686e116b5c96adac
1 parent
fd639bc1
Sub 2 indices function
Showing
2 changed files
with
12 additions
and
0 deletions
openbr/core/common.cpp
| ... | ... | @@ -76,3 +76,11 @@ QList<float> Common::linspace(float start, float stop, int n) { |
| 76 | 76 | spaced.append(stop); |
| 77 | 77 | return spaced; |
| 78 | 78 | } |
| 79 | + | |
| 80 | +QList<int> Common::ind2sub(int dims, int nPerDim, int idx) { | |
| 81 | + QList<int> subIndices; | |
| 82 | + for (int j = 0; j < dims; j++) { | |
| 83 | + subIndices.append(((int)floor( idx / pow((float)nPerDim, j))) % nPerDim); | |
| 84 | + } | |
| 85 | + return subIndices; | |
| 86 | +} | ... | ... |
openbr/core/common.h