mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-07 12:16:04 +00:00
Add Advanced Mathematics Test
This commit is contained in:
parent
13a8c94bcf
commit
57fbb16bd8
54
app.js
54
app.js
|
@ -45,7 +45,7 @@ var console = {
|
||||||
},
|
},
|
||||||
_echoCallback: null,
|
_echoCallback: null,
|
||||||
_echo: function(args, type) {
|
_echo: function(args, type) {
|
||||||
var message = "";
|
var messages = [];
|
||||||
var params = {
|
var params = {
|
||||||
type: type,
|
type: type,
|
||||||
scope: [],
|
scope: [],
|
||||||
|
@ -53,32 +53,38 @@ var console = {
|
||||||
datetime: new Date().toISOString()
|
datetime: new Date().toISOString()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (args.length > 0) {
|
var argl = args.length;
|
||||||
if (typeof args[0] === "string") {
|
for (var i = 0; i < argl; i++) {
|
||||||
// if not type is "log", then "{type}: {message}"
|
switch (typeof args[i]) {
|
||||||
if (typeof type !== "undefined") {
|
case "string":
|
||||||
message += (type + ": " + this._join(args));
|
messages.push(args[i]);
|
||||||
} else {
|
break;
|
||||||
message += this._join(args);
|
|
||||||
}
|
case "number":
|
||||||
this._echoDefault(message);
|
case "boolean":
|
||||||
this._messages.push(message);
|
messages.push(String(args[i]));
|
||||||
params.message = message;
|
break;
|
||||||
} else if (typeof args[0] === "object") {
|
|
||||||
if ('message' in args[0]) {
|
case "object":
|
||||||
if (typeof type !== "undefined") {
|
if ("message" in args[i]) {
|
||||||
message += (type + ": " + args[0].message);
|
messages.push(args[i].message);
|
||||||
|
for (var k in args[i]) {
|
||||||
|
params[k] = args[i][k];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
message += args[0].message;
|
messages.push("[object Object]");
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
this._echoDefault(message);
|
|
||||||
this._messages.push(args[0].message);
|
case "unknown":
|
||||||
for (var k in args[0]) {
|
messages.push("[unknown]");
|
||||||
params[k] = args[0][k];
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var message = messages.join(' ');
|
||||||
|
this._echoDefault(message);
|
||||||
|
this._messages.push(message);
|
||||||
|
|
||||||
if (params.scope.length > 0 && this._echoCallback != null) {
|
if (params.scope.length > 0 && this._echoCallback != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -646,7 +652,7 @@ var is = require("app/assets/js/is-0.9.0.min");
|
||||||
//console.log(new Intl.NumberFormat().format(1234567890.123456));
|
//console.log(new Intl.NumberFormat().format(1234567890.123456));
|
||||||
|
|
||||||
// numbers.js - Advanced Mathematics Library for Node.js and JavaScript
|
// numbers.js - Advanced Mathematics Library for Node.js and JavaScript
|
||||||
var numbers = require("app/assets/js/numbers-0.7.0.wsh")
|
var numbers = require("app/assets/js/numbers-0.7.0.wsh");
|
||||||
|
|
||||||
// linq.js - LINQ for JavaScript
|
// linq.js - LINQ for JavaScript
|
||||||
var Enumerable = require("app/assets/js/linq-4.0.2.wsh")._default;
|
var Enumerable = require("app/assets/js/linq-4.0.2.wsh")._default;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"description": "WelsonJS test profile (test-misc.json)",
|
"description": "WelsonJS test profile (test-misc.json)",
|
||||||
"released": "2024-09-27",
|
"updated_on": "2024-11-15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"welsonjs": "0.2.7"
|
"welsonjs": "0.2.7"
|
||||||
},
|
},
|
||||||
|
@ -100,6 +100,11 @@
|
||||||
"id": "proxy_serp",
|
"id": "proxy_serp",
|
||||||
"description": "HTTP proxy with a SERP provider",
|
"description": "HTTP proxy with a SERP provider",
|
||||||
"tags": ["Network", "HTTP"]
|
"tags": ["Network", "HTTP"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "numbers_test",
|
||||||
|
"description": "number.js test",
|
||||||
|
"tags": ["Mathematics"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"description": "WelsonJS test profile for Microsoft Office",
|
"description": "WelsonJS test profile for Microsoft Office",
|
||||||
"released": "2024-06-02",
|
"updated_on": "2024-06-02",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"welsonjs": "0.2.7"
|
"welsonjs": "0.2.7"
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
"Namhyeon Go <gnh1201@gmail.com>"
|
"Namhyeon Go <abuse@catswords.net>"
|
||||||
],
|
],
|
||||||
"references": [
|
"references": [
|
||||||
"https://github.com/gnh1201/welsonjs",
|
"https://github.com/gnh1201/welsonjs",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"description": "2023 South Korea OSS Contest Test Profile for WelsonJS",
|
"description": "2023 South Korea OSS Contest Test Profile for WelsonJS",
|
||||||
"released": "2023-10-30",
|
"updated_on": "2023-10-30",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"welsonjs": "0.2.7"
|
"welsonjs": "0.2.7"
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
"Namhyeon Go <gnh1201@gmail.com>"
|
"Namhyeon Go <abuse@catswords.net>"
|
||||||
],
|
],
|
||||||
"references": [
|
"references": [
|
||||||
"https://github.com/gnh1201/welsonjs",
|
"https://github.com/gnh1201/welsonjs",
|
||||||
|
|
|
@ -1043,6 +1043,58 @@ var test_implements = {
|
||||||
.send();
|
.send();
|
||||||
|
|
||||||
console.log("responseBody:", response.responseBody);
|
console.log("responseBody:", response.responseBody);
|
||||||
|
},
|
||||||
|
|
||||||
|
"numbers_test": function() {
|
||||||
|
// Riemann integrals
|
||||||
|
console.log("Test Riemann integrals (with 200 subdivisions)");
|
||||||
|
console.log(numbers.calculus.Riemann(Math.sin, -2, 4, 200));
|
||||||
|
|
||||||
|
// Adaptive simpson quadrature
|
||||||
|
//console.log("Test Adaptive simpson quadrature (with epsilon .0001)");
|
||||||
|
//console.log(numbers.calculus.adaptiveSimpson(Math.sin, -2, 4, .0001));
|
||||||
|
|
||||||
|
// User-defined function
|
||||||
|
console.log("Test User-defined functions");
|
||||||
|
var myFunc = function(x) {
|
||||||
|
return 2*Math.pow(x,2) + 1;
|
||||||
|
}
|
||||||
|
console.log("Test Riemann sum");
|
||||||
|
console.log(numbers.calculus.Riemann(myFunc, -2, 4, 200));
|
||||||
|
console.log("Test Adaptive Simpson's Rule");
|
||||||
|
console.log(numbers.calculus.adaptiveSimpson(myFunc, -2, 4, .0001));
|
||||||
|
|
||||||
|
// example array
|
||||||
|
var array1 = [0, 1, 2];
|
||||||
|
var array2 = [3, 4, 5];
|
||||||
|
var array = array1.concat(array2);
|
||||||
|
|
||||||
|
// add two matrices
|
||||||
|
console.log("Test Add two metrices");
|
||||||
|
console.log(JSON.stringify(numbers.matrix.addition(array1, array2)));
|
||||||
|
|
||||||
|
// transpose a matrix
|
||||||
|
//console.log("Test Transpose a matrix");
|
||||||
|
//console.log(JSON.stringify(numbers.matrix.transpose(array)));
|
||||||
|
|
||||||
|
// basic check
|
||||||
|
var number = 3; // number
|
||||||
|
|
||||||
|
console.log("Test Prime Number Check (Simple test)");
|
||||||
|
console.log(numbers.prime.simple(number));
|
||||||
|
|
||||||
|
// Miller-Rabin primality test
|
||||||
|
console.log("Test Prime Number Check (Miller-Rabin primality test)");
|
||||||
|
console.log(numbers.prime.millerRabin(number));
|
||||||
|
|
||||||
|
// mean, median, mode, standard deviation, random sample generator, correlation, confidence intervals, t-test, chi-square, and more.
|
||||||
|
console.log("Test mean, median, mode, standard deviation, random sample generator, correlation, confidence intervals, t-test, chi-square, and more.");
|
||||||
|
console.log(numbers.statistic.mean(array));
|
||||||
|
console.log(numbers.statistic.median(array));
|
||||||
|
console.log(numbers.statistic.mode(array));
|
||||||
|
console.log(numbers.statistic.standardDev(array));
|
||||||
|
//console.log(numbers.statistic.randomSample(100, 100, 20));
|
||||||
|
console.log(numbers.statistic.correlation(array1, array2));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user