How to use the index function from mathjs

Find comprehensive JavaScript mathjs.index code examples handpicked from public code repositorys.

13
14
15
16
17
18
19
20
21
22
let index;
let scale;
let col;

for (let j = 0; j < nCols; j += 1) {
  index = math.index(math.range(0, nCols), j);
  col = matrix.subset(index);
  scale = norm(col, p);

  if (scale > 0) {
fork icon4
star icon5
watch icon3

159
160
161
162
163
164
165
166
167
168
  return {"frequencies": frequencies, "spectrum": spectrums};
}

getRelevantIndeces(minFreq, maxFreq, windowSize) {
  // Returns indeces in the frequency array bounded by minFreq and maxFreq
  return math.index(math.range(Math.ceil(minFreq*windowSize/this.SAMPLING_FREQ), Math.floor(maxFreq*windowSize/this.SAMPLING_FREQ), true));
}

getFFTBand(fft, minFreq, maxFreq, windowSize) {
  // get average power in the frequency bands bounded by minFreq and maxFreq
fork icon1
star icon0
watch icon0

85
86
87
88
89
90
91
92
93
94
data["x"].push(
  math.round(
    math.det(
      math.subset(
        a,
        math.index(math.range(0, a.size()[0]), i),
        math.subset(b, math.index(math.range(0, a.size()[0]), 0))
      )
    )
  ) / math.round(math.det(a))
fork icon0
star icon0
watch icon0

11
12
13
14
15
16
17
18
19
* */
_toNormalVector : function(vect) {
    var normalVector = [];
    var size = math.subset(math.size(vect), math.index(1));
    for (var i = 0; i < size; ++i) {
        normalVector.push(math.subset(vect, math.index(0, i)));
    }
    return normalVector;
},
fork icon0
star icon0
watch icon0

+ 4 other calls in file