This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var defint = function(symbol, dx, from, to) { | |
var vars = core.Utils.variables(symbol), | |
integral = __.integrate(symbol, dx), | |
retval; | |
if(!integral.hasIntegral()) { | |
var upper = {}, | |
lower = {}; | |
upper[dx] = to; | |
lower[dx] = from; | |
retval = _.subtract(_.parse(integral, upper), _.parse(integral, lower)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Ported from: http://stackoverflow.com/questions/457408/is-there-an-easily-available-implementation-of-erf-for-python | |
var erf = function(x) { | |
var t = 1/(1+0.5*Math.abs(x)); | |
var result = 1-t*Math.exp( -x*x - 1.26551223 + | |
t * ( 1.00002368 + | |
t * ( 0.37409196 + | |
t * ( 0.09678418 + | |
t * (-0.18628806 + | |
t * ( 0.27886807 + | |
t * (-1.13520398 + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets the intersection of two arrays | |
* @param a An array | |
* @param b An array | |
* @returns {Array} | |
*/ | |
function intersection(a, b) { | |
b = b.slice(); | |
var c = []; | |
if(a.length > b.length) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function min(arr) { | |
var l, a, b; | |
while(true) { | |
l = arr.length; | |
if(l < 2) return arr[0]; | |
a = arr.pop(); | |
b = arr[l-2]; | |
if(a < b) { | |
arr.pop(); | |
arr.push(a); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Inserts an object into an array at a given index or recursively adds items if an array is given. | |
* When inserting another array, passing in false for unpackArray will result in the array being inserted | |
* rather than its items. | |
* @param {Array} arr - The target array | |
* @param {Array} item - The item being inserted | |
* @param {Number} index - Where to place the item | |
* @param {boolean} unpackArray - Will insert the array instead of adding its items | |
*/ | |
insertArray = Utils.insertArray = function( arr, item, index, unpackArray ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var toNumberPlace = function(n) { | |
var number = String(n), | |
l = number.length, | |
zeroes = l-1, | |
places = []; | |
for(var i=0; i<l; i++) { | |
var digit = Number(number.charAt(i)); | |
places.push(digit * Math.pow(10, zeroes--)); | |
} | |
return places; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.fn.circularMeter = function() { | |
var defaults = { | |
dimension: 25, | |
'border-width': 25, | |
color: '#ABABAB', | |
'text-color': '#000', | |
'z-index': 99 | |
}; | |
var userOptions = typeof arguments[0] === 'object' ? [].shift.apply(arguments) : defaults; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function factors(num, unique) { | |
var l = num, i=1, factors = [], | |
epsilon = 2.2204460492503130808472633361816E-16; | |
while(i<l) { | |
var quotient = num/i; | |
var whole = Math.floor(quotient); | |
var remainder = quotient-whole; | |
if(remainder <= epsilon) { | |
unique && i === whole ? factors.push(i) : factors.push(i, whole); | |
l = whole; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This function searches an array and its sub-arrays. A condition function can be used | |
* to limit the results | |
* @param {Array} arr | |
* @param {Function} condfn A function with extra conditions | |
* @param {String} prop A hashable property to identify the object when found | |
* @param {Object} c A collector object defined by the function | |
* @returns {Object} An object containing the found objects | |
*/ | |
function countFrequency(arr, condfn, prop, c) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nerdamer.register({ | |
parent: 'Helper', | |
name: 'withsteps', | |
visible: false, | |
build: function() { | |
var core = this; | |
var operationLog = []; | |
//write a function which would perform the log | |
var log = function(operator, symbol1, symbol2, result, is_first) { | |
if(!is_first) operationLog.pop(); |