How to use the mathjs.round function in mathjs

To help you get started, we’ve selected a few mathjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github firepick1 / firenodejs / js / firestep-driver.js View on Github external
var pulses = {
                p1: mpo["1"],
                p2: mpo["2"],
                p3: mpo["3"]
            };
            var xyz = that.delta.calcXYZ(pulses);
            that.mpoPlanSetPulses(mpo["1"], mpo["2"], mpo["3"], {
                log: "FireStepDriver.onIdle(initialized)"
            });
        } else {
            console.log("TTY\t: FireStepDriver.onIdle(waiting) ...");
        }
        if (that.mpoPlan) {
            that.model.mpo = JSON.parse(JSON.stringify(that.mpoPlan));
            // round for archival
            that.model.mpo.x = math.round(that.model.mpo.x, 3);
            that.model.mpo.y = math.round(that.model.mpo.y, 3);
            that.model.mpo.z = math.round(that.model.mpo.z, 3);
        }
        return that;
    };
github camelaissani / loca / test / businesslogic_FR / computeRent.js View on Github external
exitDate: '31/08/2017',
            property: {
                name: 'mon bureau',
                price: 300,
                expense: 10
            }
        };
        const contract = {
            begin: '01/01/2017',
            end: '31/01/2017',
            discount: 10,
            vatRate: 0.2,
            properties: [property]
        };

        const grandTotal = math.round((property.property.price + property.property.expense - contract.discount) * (1+contract.vatRate), 2);

        it('check rent object structure', () => {
            const computedRent = BL.computeRent(contract, '01/01/2017');
            const rentMoment = moment('01/01/2017', 'DD/MM/YYYY HH:mm');
            assert.strictEqual(computedRent.term, Number(rentMoment.format('YYYYMMDDHH')));
            assert.strictEqual(computedRent.month, rentMoment.month()+1);
            assert.strictEqual(computedRent.year, rentMoment.year());
        });

        it('compute one rent', () => {
            const computedRent = BL.computeRent(contract, '01/01/2017');
            assert.strictEqual(computedRent.total.grandTotal, grandTotal);
        });

        it('compute two rents and check balance', () => {
            const rentOne = BL.computeRent(contract, '01/01/2017');
github googleapis / nodejs-automl / samples / language / sentiment-analysis / display-evaluation.v1beta1.js View on Github external
)} %`
          );
          console.log(
            `Model mean squared error: ${math.round(
              sentimentMetrics.meanSquaredError * 100,
              2
            )} %`
          );
          console.log(
            `Model linear kappa: ${math.round(
              sentimentMetrics.linearKappa * 100,
              2
            )} %`
          );
          console.log(
            `Model quadratic kappa: ${math.round(
              sentimentMetrics.quadraticKappa * 100,
              2
            )} %`
          );

          console.log(`Model confusion matrix:`);
          const annotationSpecIdList = confusionMatrix.annotationSpecId;

          for (const annotationSpecId of annotationSpecIdList) {
            console.log(`\tAnnotation spec Id: ${annotationSpecId}`);
          }
          const rowList = confusionMatrix.row;

          for (const row of rowList) {
            console.log(`\tRow:`);
            const exampleCountList = row.exampleCount;
github googleapis / nodejs-automl / samples / language / entity-extraction / list-model-evaluations.v1beta1.js View on Github external
.pop()}`
        );
        console.log(
          `Model evaluation annotation spec Id: ${element[i].annotationSpecId}`
        );
        console.log(`Model evaluation display name: ${element[i].displayName}`);
        console.log(
          `Model evaluation example count: ${element[i].evaluatedExampleCount}`
        );
        console.log(`Text extraction evaluation metrics:`);
        console.log(`\tModel AuPrc: ${math.round(extractMetrics.auPrc, 2)}`);
        console.log(`\tConfidence metrics entries:`);

        for (const confidenceMetricsEntry of confidenceMetricsEntries) {
          console.log(
            `\t\tModel confidence threshold: ${math.round(
              confidenceMetricsEntry.confidenceThreshold,
              2
            )}`
          );
          console.log(
            `\t\tModel recall: ${math.round(
              confidenceMetricsEntry.recall * 100,
              2
            )} %`
          );
          console.log(
            `\t\tModel precision: ${math.round(
              confidenceMetricsEntry.precision * 100,
              2
            )} %`
          );
github quantastica / quantum-circuit / lib / quantum-circuit.js View on Github external
QuantumCircuit.prototype.measureAll = function(force) {
	if(this.collapsed && this.collapsed.length == this.numQubits && !force) {
		return this.collapsed;
	}

	this.collapsed = [];
	var randomRange = 0;
	var maxChance = 0;
	for(var is in this.state) {
		var state = math.round(this.state[is], 14);
		var chance = 0;
		if(state.re || state.im) {
			chance = math.round(math.pow(math.abs(state), 2), 7);

			if(chance == maxChance) {
				randomRange++;
			} else {
				randomRange = 1;
			}
		}

		if(chance > maxChance || (chance == maxChance && (!this.collapsed.length || !Math.floor(Math.random() * (randomRange + 1)) ))) {
			var i = parseInt(is);
			maxChance = chance;
			this.collapsed = [];
			for(var q = this.numQubits - 1; q >= 0; q--) {
github quantastica / quantum-circuit / lib / quantum-circuit.js View on Github external
for(var is in this.state) {
		var i = parseInt(is);

		for(var wire = 0; wire < this.numQubits; wire++) {
			var bit = math.pow(2, (this.numQubits - 1) - wire);
			if(i & bit) {
				var state = this.state[is];
				if(state.re || state.im) {
					this.prob[wire] += math.pow(math.abs(state), 2);
				}
			}
		}
	}

	for(var wire = 0; wire < this.numQubits; wire++) {
		this.prob[wire] = math.round(this.prob[wire], 14);
	}
	return this.prob;
};
github firepick1 / firenodejs / js / firestep / mto-fpd.js View on Github external
MTO_FPD.prototype.calcXYZ = function(pulses) {
        var that = this;
        var xyz = that.delta.calcXYZ(pulses);
        return {
            x: math.round(xyz.x, 3),
            y: math.round(xyz.y, 3),
            z: math.round(xyz.z, 3),
        };
    }
github SouthEugeneRoboticsTeam / robot-analytics / src / app / data / calculations.ts View on Github external
invoke: (...metrics: Array>) => ({
            type: ScoutMetricType.NUMBER,
            value: round(mean(metrics.filter((metric) => !!metric).map((metric) => metric.value)), 2),
            category: metrics[0].category,
        }),
    },
github Hiswe / gulp-svg-symbols / lib / format-svg-data.js View on Github external
function formatEm(px, baseFont) {
  var emSize = px / baseFont;
  math.round(emSize, 3);
  return emSize + 'em';
}

mathjs

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif

Apache-2.0
Latest version published 8 days ago

Package Health Score

92 / 100
Full package analysis