Returns the one-dim index for the multi-dimensional indexes. Compatible with matlab multi-dimensional indexing. Note: this performs the same logical function as getIndex, but the indices are computed in column major order for compatibility with .mat files generated by Matlab. @param indexes Lengt
(int... indexes)
| 80 | * @return The linear index |
| 81 | */ |
| 82 | public int getIndex(int... indexes) { |
| 83 | if (indexes.length != dims.length) { |
| 84 | throw new IllegalArgumentException("Cannot use " + indexes.length + " indexes for " + dims.length + " dimensions."); |
| 85 | } |
| 86 | int ix = 0; |
| 87 | for (int dimIx = 0; dimIx < indexes.length; dimIx++) { |
| 88 | ix += dimStrides[dimIx] * validateDimSize(dimIx, indexes[dimIx]); |
| 89 | } |
| 90 | return ix; |
| 91 | } |
| 92 | |
| 93 | private int validateDimSize(int dimIx, int ixInDim) { |
| 94 | if (dims[dimIx] > ixInDim) { |
nothing calls this directly
no test coverage detected