MCPcopy Create free account
hub / github.com/diffplug/matfilerw / getIndex

Method getIndex

src/main/java/com/jmatio/types/MLArray.java:82–91  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 2

validateDimSizeMethod · 0.95
getMMethod · 0.95

Tested by

no test coverage detected