How to use the range function from mathjs

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

54
55
56
57
58
59
60
61
62
63
var clusters = [];
var n = A.size()[0];

for (var i = 0; i < n; i++) {
  if (A.subset(math.index(i, i)) > 0.0001) {
    var rowMatrix = A.subset(math.index(i, math.range(0, n)));
    var cluster = this.rowMatrixToArray(rowMatrix).map(function (x, index) {
      return x > 0.001 ? index : -1;
    });
    cluster = cluster.filter(function (x) {
fork icon2
star icon6
watch icon2

52
53
54
55
56
57
58
59
60
61
const clusters = [];
const n = A.size()[0];

for (let i = 0; i < n; i++) {
  if (A.subset(math.index(i, i)) > 0.0001) {
    const rowMatrix = A.subset(math.index(i, math.range(0, n)));
    let cluster = this.rowMatrixToArray(rowMatrix).map(
      (x, index) => {return (x > 0.001) ? index : -1;});
    cluster = cluster.filter((x) => x >= 0);
    clusters.push(cluster);
fork icon2
star icon6
watch icon2

106
107
108
109
110
111
112
113
114
115
let coords = math.matrix([[-W2, W2, W2, -W2], [H2, H2, -H2, -H2]])

let res = math.multiply(rot, coords);

let X = res.subset(math.index(0, math.range(0, 4)));
let Y = res.subset(math.index(1, math.range(0, 4)));

return {
    w: Math.round(math.max(X) - math.min(X)),
    h: Math.round(math.max(Y) - math.min(Y))
fork icon0
star icon3
watch icon1

+ 27 other calls in file

284
285
286
287
288
289
290
291
292
293
  Math.pow(start.j - end.j, 2) +
  Math.pow(start.k - end.k, 2))) + 1;

// 构造轨迹的坐标路径
let xList = mathjs.range(start.i, end.i, (end.i - start.i) / inter)._data;
let yList = mathjs.range(start.j, end.j, (end.j - start.j) / inter)._data;
let zList = mathjs.range(start.k, end.k, (end.k - start.k) / inter)._data;

if (!xList.length) {
  xList = Array.apply(undefined, Array(inter)).map(item => start.i);
fork icon0
star icon0
watch icon1

+ 14 other calls in file