*******************BEGINNING OF FUNCTION********************//
973758
public static boolean is_vargiya1(String str)
    {

        if (str.equals("k") || str.equals("c") || str.equals("w") || str.equals("t") || str.equals("p")) return true;

        return false;
    }
520258
private void parseNth() {
        // Remove all '+' and spaces.
        String str = argument.replaceAll("\\+|\\s+", "");
        if ("odd".equals(str)) {
            a = 2;
            b = 1;
        } else if ("even".equals(str)) {
            a = 2;
        } else {
            int n = str.indexOf('n');
            if (n != -1) {
                if (n == 0) {
                    a = 1;
                } else if (n == 1 && str.charAt(0) == '-') {
                    a = -1;
                } else {
                    a = Integer.parseInt(str.substring(0, n));
                }

                if ((n + 1) != str.length()) {
                    b = Integer.parseInt(str.substring(n + 1, str.length()));
                }
            } else {
                b = Integer.parseInt(str);
            }
        }
    }
1001974
function init(proto) {
    proto.prototype.flush = function flush(to, axis, mside, wside) {
        return util.flush(this, to, axis, mside, wside);
    };

    proto.prototype.snap = function snap(to, axis, orientation, delta) {
        return util.snap(this, to, axis, orientation, delta);
    };

    proto.prototype.calcSnap = function calcSnap(to, axis, orientation, delta) {
        return util.calcSnap(this, to, axis, orientation, delta);
    };

    proto.prototype.midlineTo = function midlineTo(axis, to) {
        return util.midlineTo(this, axis, to);
    };

    proto.prototype.calcmidlineTo = function midlineTo(axis, to) {
        return util.calcmidlineTo(this, axis, to);
    };

    proto.prototype.centerWith = function centerWith(axis, to) {
        util.depreciated('centerWith', true, 'Use align instead.');
        return util.centerWith(this, axis, to);
    };

    if (proto.center) echo('proto already has .center');
    proto.prototype.center = function center(axis) {
        // console.log('center', axis, this.getBounds());
        return util.centerWith(this, axis || 'xyz', util.unitCube(), 0);
    };

    proto.prototype.calcCenter = function centerWith(axis) {
        return util.calcCenterWith(this, axis || 'xyz', util.unitCube(), 0);
    };

    proto.prototype.align = function align(to, axis) {
        // console.log('align', to.getBounds(), axis);
        return util.centerWith(this, axis, to);
    };

    proto.prototype.calcAlign = function calcAlign(to, axis, delta) {
        return util.calcCenterWith(this, axis, to, delta);
    };

    proto.prototype.enlarge = function enlarge(x, y, z) {
        return util.enlarge(this, x, y, z);
    };

    proto.prototype.fit = function fit(x, y, z, a) {
        return util.fit(this, x, y, z, a);
    };

    if (proto.size) echo('proto already has .size');

    proto.prototype.size = function() {
        return util.size(this.getBounds());
    };

    proto.prototype.centroid = function() {
        return util.centroid(this);
    };

    proto.prototype.Zero = function zero() {
        return util.zero(this);
    };

    proto.prototype.Center = function Center(axes) {
        return this.align(util.unitCube(), axes || 'xy');
    };

    proto.Vector2D.prototype.map = function Vector2D_map(cb) {
        return new proto.Vector2D(cb(this.x), cb(this.y));
    };

    proto.prototype.fillet = function fillet(radius, orientation, options) {
        return util.fillet(this, radius, orientation, options);
    };

    proto.prototype.chamfer = function chamfer(radius, orientation, options) {
        return util.chamfer(this, radius, orientation, options);
    };

    proto.prototype.bisect = function bisect(
        axis,
        offset,
        angle,
        rotateaxis,
        rotateoffset,
        options
    ) {
        return util.bisect(
            this,
            axis,
            offset,
            angle,
            rotateaxis,
            rotateoffset,
            options
        );
    };

    proto.prototype.stretch = function stretch(axis, distance, offset) {
        return util.stretch(this, axis, distance, offset);
    };

    proto.prototype.unionIf = function unionIf(object, condition) {
        return condition ? this.union(util.result(this, object)) : this;
    };

    proto.prototype.subtractIf = function subtractIf(object, condition) {
        return condition ? this.subtract(util.result(this, object)) : this;
    };

    proto.prototype._translate = proto.prototype.translate;

    /**
      * This modifies the normal `proto.translate` method to accept
      * multiple translations, adding the translations together.
      * The original translate is available on `proto._translate` and
      * a short circut is applied when only one parameter is given.
      * @return {proto} The resulting object.
      */
    proto.prototype.translate = function translate() {
        if (arguments.length === 1) {
            return this._translate(arguments[0]);
        } else {
            var t = Array.prototype.slice.call(arguments, 0).reduce(function(
                result,
                arg
            ) {
                // console.log('arg', arg);
                result = util.array.addArray(result, arg);
                return result;
            }, [0, 0, 0]);

            // console.log('translate', t);
            return this._translate(t);
        }
    };
}
1289436
private boolean parseFunction() {
        if (!(curToken instanceof Id) || isELReserved(curToken.toString())) {
            return false;
        }
        String s1 = null; // Function prefix
        String s2 = curToken.toString(); // Function name
        int mark = getIndex();
        if (hasNext()) {
            Token t = nextToken();
            if (t.toChar() == ':') {
                if (hasNext()) {
                    Token t2 = nextToken();
                    if (t2 instanceof Id) {
                        s1 = s2;
                        s2 = t2.toString();
                        if (hasNext()) {
                            t = nextToken();
                        }
                    }
                }
            }
            if (t.toChar() == '(') {
                ELexpr.add(new ELNode.Function(s1, s2));
                return true;
            }
        }
        setIndex(mark);
        return false;
    }
1212443
public static void main(String[] args) {
    if (args.length == 0) {
      System.err.println("Usage: java edu.stanford.nlp.math.SloppyMath " + "[-logAdd|-fishers k n r m|-binomial r n p");
    } else if (args[0].equals("-logAdd")) {
      System.out.println("Log adds of neg infinity numbers, etc.");
      System.out.println("(logs) -Inf + -Inf = " + logAdd(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY));
      System.out.println("(logs) -Inf + -7 = " + logAdd(Double.NEGATIVE_INFINITY, -7.0));
      System.out.println("(logs) -7 + -Inf = " + logAdd(-7.0, Double.NEGATIVE_INFINITY));
      System.out.println("(logs) -50 + -7 = " + logAdd(-50.0, -7.0));
      System.out.println("(logs) -11 + -7 = " + logAdd(-11.0, -7.0));
      System.out.println("(logs) -7 + -11 = " + logAdd(-7.0, -11.0));
      System.out.println("real 1/2 + 1/2 = " + logAdd(Math.log(0.5), Math.log(0.5)));
    } else if (args[0].equals("-fishers")) {
      int k = Integer.parseInt(args[1]);
      int n = Integer.parseInt(args[2]);
      int r = Integer.parseInt(args[3]);
      int m = Integer.parseInt(args[4]);
      double ans = SloppyMath.hypergeometric(k, n, r, m);
      System.out.println("hypg(" + k + "; " + n + ", " + r + ", " + m + ") = " + ans);
      ans = SloppyMath.oneTailedFishersExact(k, n, r, m);
      System.out.println("1-tailed Fisher's exact(" + k + "; " + n + ", " + r + ", " + m + ") = " + ans);
      double ansChi = SloppyMath.chiSquare2by2(k, n, r, m);
      System.out.println("chiSquare(" + k + "; " + n + ", " + r + ", " + m + ") = " + ansChi);

      System.out.println("Swapping arguments should give same hypg:");
      ans = SloppyMath.hypergeometric(k, n, r, m);
      System.out.println("hypg(" + k + "; " + n + ", " + m + ", " + r + ") = " + ans);
      int othrow = n - m;
      int othcol = n - r;
      int cell12 = m - k;
      int cell21 = r - k;
      int cell22 = othrow - (r - k);
      ans = SloppyMath.hypergeometric(cell12, n, othcol, m);
      System.out.println("hypg(" + cell12 + "; " + n + ", " + othcol + ", " + m + ") = " + ans);
      ans = SloppyMath.hypergeometric(cell21, n, r, othrow);
      System.out.println("hypg(" + cell21 + "; " + n + ", " + r + ", " + othrow + ") = " + ans);
      ans = SloppyMath.hypergeometric(cell22, n, othcol, othrow);
      System.out.println("hypg(" + cell22 + "; " + n + ", " + othcol + ", " + othrow + ") = " + ans);
    } else if (args[0].equals("-binomial")) {
      int k = Integer.parseInt(args[1]);
      int n = Integer.parseInt(args[2]);
      double p = Double.parseDouble(args[3]);
      double ans = SloppyMath.exactBinomial(k, n, p);
      System.out.println("Binomial p(X >= " + k + "; " + n + ", " + p + ") = " + ans);
    } else {
      System.err.println("Unknown option: " + args[0]);
    }
  }
1111069
public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while (scan.hasNextLine()) {
            String line = scan.nextLine();

            LogicExpression<String> expr = LogicExpressionParsers.trivial.parse(line);

            System.out.println("string: " + expr.toString());
            System.out.println("value:  " + expr.apply(null));
            System.out.println();
        }

        scan.close();
    }
26559
function() {

      // asinh(c) = log(c + sqrt(c^2 + 1))

      var tmp = this['im'];
      this['im'] = -this['re'];
      this['re'] = tmp;
      var res = this['asin']();

      this['re'] = -this['im'];
      this['im'] = tmp;
      tmp = res['re'];

      res['re'] = -res['im'];
      res['im'] = tmp;
      return res;
    }
182544
public void computeRange( SortableParameter_F32 input[] , int start , int length ) {
		if( length == 0 ) {
			divisor = 0;
			return;
		}

		float min,max;

		min = max = input[start].sortValue;

		for( int i = 1; i < length; i++ ) {
			float val = input[start+i].sortValue;
			if( val < min )
				min = val;
			else if( val > max )
				max = val;
		}

		setRange(min,max);
	}
1349164
@SuppressWarnings({"UnusedDeclaration"})
    public static void main(String[] args){
        Syntax syntax = new Syntax();

        Matcher Q               = syntax.add("Q",              ch('\''));
        Matcher DIGIT           = syntax.add("DIGIT",          range("0-9"));
        Matcher PUBID_CHAR     = syntax.add("PUBID_CHAR",   or(any(" \r\n"), range("A-Z"), range("a-z"), DIGIT, any("-'()+,./:=?;!*#@$_%")));
        Matcher PUBID_CHAR_NQ     = syntax.add("PUBID_CHAR_NQ",   minus(PUBID_CHAR, Q));
        Matcher SPECIAL_CHAR     = syntax.add("SPECIAL_CHAR",   any("^[]-^&\\<"));
        Matcher NON_SPECIAL_CHAR = syntax.add("NON_SPECIAL_CHAR",   not(SPECIAL_CHAR));


//        Matcher GT              = syntax.add("GT",             ch('>'));
//        Matcher BRACKET_CLOSE   = syntax.add("BRACKET_CLOSE",  ch(']'));
//        Matcher DQ              = syntax.add("DQ",             ch('"'));

//        Matcher HEX_DIGIT       = syntax.add("HEX_DIGIT",      or(DIGIT, range("a-f"), range("A-F")));
//        Matcher WS              = syntax.add("WS",             any(" \t\n\r"));
//        Matcher ENCODING_START  = syntax.add("ENCODING_START", or(range("A-Z"), range("a-z")));
//        Matcher ENCODING_PART   = syntax.add("ENCODING_PART",  or(ENCODING_START, DIGIT, any("._-")));
//        Matcher CHAR            = syntax.add("CHAR",           or(any("\t\n\r"), range(" -\uD7FF"), range("\uE000-\uFFFD")/*, range("\u10000-\u10FFFF")*/));
//        Matcher DASH            = syntax.add("DASH",           ch('-'));
//        Matcher NDASH           = syntax.add("NDASH",          minus(CHAR, ch('-')));
//        Matcher NAME_START      = syntax.add("NAME_START",     or(ch(':'), range("A-Z"), ch('_'), range("a-z"), range("\u00C0-\u00D6"), range("\u00D8-\u00F6"), range("\u00F8-\u02FF"), range("\u0370-\u037D"), range("\u037F-\u1FFF"), range("\u200C-\u200D"), range("\u2070-\u218F"), range("\u2C00-\u2FEF"), range("\u3001-\uD7FF"), range("\uF900-\uFDCF"), range("\uFDF0-\uFFFD")/*, range("\u10000-\uEFFFF")*/));
//        Matcher NAME_PART       = syntax.add("NAME_PART",      or(NAME_START, ch('-'), ch('.'), DIGIT,  ch('\u00B7'), range("\u0300-\u036F"), range("\u203F-\u2040")));
//        Matcher NCNAME_START    = syntax.add("NCNAME_START",   minus(NAME_START, ch(':')));
//        Matcher NCNAME_PART     = syntax.add("NCNAME_PART",    minus(NAME_PART, ch(':')));

//        Rule rule = new Rule();
//        rule.node = new Node();
//        syntax.add("Rule1", rule);

        NBLREditor editor = new NBLREditor(syntax);
        editor.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        editor.setVisible(true);
    }
266773
function begins(query, node) {
  var value = node[query.name]

  return (
    typeof value === 'string' &&
    value.slice(0, query.value.length) === query.value
  )
}
257137
function compile1(str) {
  if (!/[{}]/.exec(str)) return [literal(str)];

  var depth = 0;
  var nodes = [];
  var m;
  var buffer = '';

  while ((m = /[{}]/.exec(str)) && str.length > 0) {
    var chunk = str.substring(0, m.index);
    switch (m[0]) {
      case '{':
        depth += 1;
        if (depth === 1) {
          buffer += chunk;
          if (buffer.length > 0) nodes.push(literal(buffer));
          buffer = '';
        } else {
          buffer += chunk + '{';
        }
        break;
      case '}':
        depth -= 1;
        if (depth === 0) {
          buffer += chunk;
          if (buffer.length > 0) nodes.push(utils.parseExpression(buffer));
          buffer = '';
        } else {
          buffer += chunk + '}';
        }
        break;
    }
    str = str.substring(m.index + 1);
  }

  if (str.length > 0)
    nodes.push(literal(str));

  return nodes;
}
1209457
public void print() {
        /*
        System.out.println(m00 + " " + m01 + " " + m02 + " " + m03 + "\n" +
                           m10 + " " + m11 + " " + m12 + " " + m13 + "\n" +
                           m20 + " " + m21 + " " + m22 + " " + m23 + "\n" +
                           m30 + " " + m31 + " " + m32 + " " + m33 + "\n");
         */
        int big = (int) Math.abs(Math.max(Math.max(Math.max(Math.max(Math.abs(m00), Math.abs(m01)),
            Math.max(Math.abs(m02), Math.abs(m03))),
            Math.max(Math.max(Math.abs(m10), Math.abs(m11)),
                Math.max(Math.abs(m12), Math.abs(m13)))),
                Math.max(Math.max(Math.max(Math.abs(m20), Math.abs(m21)),
                    Math.max(Math.abs(m22), Math.abs(m23))),
                    Math.max(Math.max(Math.abs(m30), Math.abs(m31)),
                        Math.max(Math.abs(m32), Math.abs(m33))))));

        int digits = 1;
        if (Double.isNaN(big) || Double.isInfinite(big)) {  // avoid infinite loop
            digits = 5;
        } else {
            while ((big /= 10) != 0) digits++;  // cheap log()
        }

        System.out.println(nfs(m00, digits, 4) + " " +
                           nfs(m01, digits, 4) + " " +
                           nfs(m02, digits, 4) + " " +
                           nfs(m03, digits, 4));

        System.out.println(nfs(m10, digits, 4) + " " +
                           nfs(m11, digits, 4) + " " +
                           nfs(m12, digits, 4) + " " +
                           nfs(m13, digits, 4));

        System.out.println(nfs(m20, digits, 4) + " " +
                           nfs(m21, digits, 4) + " " +
                           nfs(m22, digits, 4) + " " +
                           nfs(m23, digits, 4));

        System.out.println(nfs(m30, digits, 4) + " " +
                           nfs(m31, digits, 4) + " " +
                           nfs(m32, digits, 4) + " " +
                           nfs(m33, digits, 4));

        System.out.println();
    }
1335198
public void init() {
		N = getParameterLength();
		jacR = new DMatrixRMaj[N];
		for (int i = 0; i < N; i++) {
			jacR[i] = new DMatrixRMaj(3,3);
		}
		jacobian = new DMatrixRMaj(N,9);
		paramInternal = new double[N];
		numericalJac = createNumericalAlgorithm(function);
	}
572770
def is_start_of_function(text):
    """"""
    if isinstance(text, str) or isinstance(text, unicode):
        function_prefix = ['def', 'async def']
        text = text.lstrip()

        for prefix in function_prefix:
            if text.startswith(prefix):
                return True

    return False
928537
private function _initialize()
    {
        $params = $this->getParameters();
        if ($params !== null) {
            for ($i = 0, $_i = count($params); $i < $_i; $i++) {
                if (self::FUNCTION_KEY == $params[$i]->getName()) {
                    $this->function = (string) $params[$i]->getValue();
                    break;
                }
            }
        }
    }
554103
void init() {
    numnegative = new int[numSamples() + 1];
    numpositive = new int[numSamples() + 1];
    numnegative[0] = 0;
    numpositive[0] = 0;
    int num = numSamples();
    for (int i = 1; i <= num; i++) {
      numnegative[i] = numnegative[i - 1] + (classes[i - 1] == 0 ? 1 : 0);
    }
    for (int i = 1; i <= num; i++) {
      numpositive[i] = numpositive[i - 1] + (classes[num - i] == 0 ? 0 : 1);
    }
    System.err.println("total positive " + numpositive[num] + " total negative " + numnegative[num] + " total " + num);
    for (int i = 1; i < numpositive.length; i++) {
      //System.out.println(i + " positive " + numpositive[i] + " negative " + numnegative[i] + " classes " + classes[i - 1] + " " + classes[num - i]);
    }
  }
1249588
function queryfn(query, oldscope, cb, A, B) {
	var aaa = query.sources.length;

	var ms;
	query.sourceslen = query.sources.length;
	var slen = query.sourceslen;
	query.query = query; // TODO Remove to prevent memory leaks
	query.A = A;
	query.B = B;
	query.cb = cb;
	query.oldscope = oldscope;

	// Run all subqueries before main statement
	if (query.queriesfn) {
		query.sourceslen += query.queriesfn.length;
		slen += query.queriesfn.length;

		query.queriesdata = [];

		//		console.log(8);
		query.queriesfn.forEach(function(q, idx) {
			//			if(query.explain) ms = Date.now();
			//console.log(18,idx);
			//			var res = flatArray(q(query.params,null,queryfn2,(-idx-1),query));

			//			var res = flatArray(queryfn(q.query,null,queryfn2,(-idx-1),query));
			//			console.log(A,B);
			// console.log(q);
			q.query.params = query.params;
			//			query.queriesdata[idx] =

			//	if(false) {
			//			queryfn(q.query,query.oldscope,queryfn2,(-idx-1),query);
			//	} else {
			queryfn2([], -idx - 1, query);
			//	}

			//			console.log(27,q);

			//			query.explaination.push({explid: query.explid++, description:'Query '+idx,ms:Date.now()-ms});
			//			query.queriesdata[idx] = res;
			//			return res;
		});
		//		console.log(9,query.queriesdata.length);
		//		console.log(query.queriesdata[0]);
	}

	var scope;
	if (!oldscope) scope = {};
	else scope = cloneDeep(oldscope);
	query.scope = scope;

	// First - refresh data sources

	var result;
	query.sources.forEach(function(source, idx) {
		//		source.data = query.database.tables[source.tableid].data;
		//		console.log(666,idx);
		source.query = query;
		var rs = source.datafn(query, query.params, queryfn2, idx, alasql);
		//		console.log(333,rs);
		if (typeof rs !== 'undefined') {
			// TODO - this is a hack: check if result is array - check all cases and
			// make it more logical
			if ((query.intofn || query.intoallfn) && Array.isArray(rs)) rs = rs.length;
			result = rs;
		}
		//
		// Ugly hack to use in query.wherefn and source.srcwherefns functions
		// constructions like this.queriesdata['test'].
		// I can elimite it with source.srcwherefn.bind(this)()
		// but it may be slow.
		//
		source.queriesdata = query.queriesdata;
	});
	if (query.sources.length == 0 || 0 === slen) result = queryfn3(query);
	//	console.log(82,aaa,slen,query.sourceslen, query.sources.length);
	return result;
}