How to use the ones function from mathjs

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

60
61
62
63
64
65
66
67
68
  return math.multiply(G, D);
};

const solver = (M, d, error) => {
  const N = M.size()[1];
  const ones = math.ones(1, N, 'sparse');

  // Vector of ranks for the ith node, scaled between [0, 1]
  let v = math.ones(N, 1);
fork icon4
star icon5
watch icon3

+ 3 other calls in file

1
2
3
4
5
6
7
8
9
10

var _exports = module.exports = {};
var math = require('mathjs');

_exports.colSum = function colSum(A) {
  var ones = math.ones(A.size()[0]);
  return math.multiply(math.transpose(A), ones);
};

_exports.repmat = function repmat(row, n) {
fork icon2
star icon6
watch icon2

58
59
60
61
62
63
64
65
66
}

regression() {
  this.X = math.matrix([
    this.pre_matrix[0],
    math.ones(this.pre_matrix[0].length)._data,
  ]);

  this.Y = math.matrix([this.pre_matrix[1]]);
fork icon0
star icon0
watch icon0

+ 3 other calls in file

61
62
63
64
65
66
67
68
69
70
// compute the PageRank vector iteratively
async function get_PageRank_Vector(GoogleMatrix, epsilon){
  // initialize the PageRank vector
  const dimensions = GoogleMatrix._size;
  const numTags = dimensions[0];
  var PageRankVector = mathjs.ones(numTags);
  // Initialize the PageRank vector to be a vector of 1/numTags
  PageRankVector = mathjs.multiply(PageRankVector, 1/numTags);
  // initialize the previous PageRank vector
  var previousPageRankVector = mathjs.zeros(numTags);
fork icon0
star icon0
watch icon0

+ 3 other calls in file

186
187
188
189
190
191
192
193
194
195
        nu=2;
}
//console.log(X2);
X2_old = X2; // previous value of X2
//console.log(MaxIter+" "+Npar);
var cvg_hst = math.ones(MaxIter,Npar+3);		// initialize convergence history
var h = null;
while ( !stop && iteration <= MaxIter ) {		// --- Main Loop
    iteration = iteration + 1;
    // incremental change in parameters
fork icon0
star icon0
watch icon0

+ 2 other calls in file