{"size": 10616, "ext": "js", "max_stars_repo_path": "public/js/cljs-runtime/module$node_modules$mathjs$lib$cjs$function$algebra$rationalize.js", "max_stars_repo_name": "hkmin27/contactcalc", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/js/cljs-runtime/module$node_modules$mathjs$lib$cjs$function$algebra$rationalize.js", "max_issues_repo_name": "hkmin27/contactcalc", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/js/cljs-runtime/module$node_modules$mathjs$lib$cjs$function$algebra$rationalize.js", "max_forks_repo_name": "hkmin27/contactcalc", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 461.5652173913, "max_line_length": 563, "alphanum_fraction": 0.7179728711}
shadow$provide.module$node_modules$mathjs$lib$cjs$function$algebra$rationalize=function(global,require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0});exports.createRationalize=void 0;var _number=require("module$node_modules$mathjs$lib$cjs$utils$number");global=require("module$node_modules$mathjs$lib$cjs$utils$factory");var _simplifyConstant=require("module$node_modules$mathjs$lib$cjs$function$algebra$simplify$simplifyConstant"),_simplifyCore=require("module$node_modules$mathjs$lib$cjs$function$algebra$simplify$simplifyCore");
require=(0,global.factory)("rationalize","config typed equal isZero add subtract multiply divide pow parse simplify ?bignumber ?fraction mathWithTransform ConstantNode OperatorNode FunctionNode SymbolNode ParenthesisNode".split(" "),function(_ref){function polynomial(expr,scope,extended,rules){function recPoly(node){var tp=node.type;if("FunctionNode"===tp)throw Error("There is an unsolved function call");if("OperatorNode"===tp)if("^"===node.op)if("ConstantNode"===node.args[1].type&&(0,_number.isInteger)(parseFloat(node.args[1].value)))recPoly(node.args[0]);
else throw Error("There is a non-integer exponent");else{if(-1===oper.indexOf(node.op))throw Error("Operator "+node.op+" invalid in polynomial expression");for(tp=0;tp<node.args.length;tp++)recPoly(node.args[tp])}else if("SymbolNode"===tp)node=node.name,-1===variables.indexOf(node)&&variables.push(node);else if("ParenthesisNode"===tp)recPoly(node.content);else if("ConstantNode"!==tp)throw Error("type "+tp+" is not allowed in polynomial expression");}var variables=[];expr=simplify(expr,rules,scope,
{exactFractions:!1});var oper="+-*"+(extended?"/":"");recPoly(expr);extended={};extended.expression=expr;extended.variables=variables;return extended}function expandPower(node,parent,indParent){var tp=node.type,internal=1<arguments.length;if("OperatorNode"===tp&&node.isBinary()){var does=!1;if("^"===node.op&&("ParenthesisNode"===node.args[0].type||"OperatorNode"===node.args[0].type)&&"ConstantNode"===node.args[1].type){var val=parseFloat(node.args[1].value);does=2<=val&&(0,_number.isInteger)(val)}does&&
(2<val?(does=node.args[0],val=new OperatorNode("^","pow",[node.args[0].cloneDeep(),new ConstantNode(val-1)]),node=new OperatorNode("*","multiply",[does,val])):node=new OperatorNode("*","multiply",[node.args[0],node.args[0].cloneDeep()]),internal&&("content"===indParent?parent.content=node:parent.args[indParent]=node))}if("ParenthesisNode"===tp)expandPower(node.content,node,"content");else if("ConstantNode"!==tp&&"SymbolNode"!==tp)for(tp=0;tp<node.args.length;tp++)expandPower(node.args[tp],node,tp);
if(!internal)return node}function polyToCanonical(node$jscomp$0,coefficients){function recurPol(node,noPai,o){var tp=node.type;if("FunctionNode"===tp)throw Error("There is an unsolved function call");if("OperatorNode"===tp){if(-1==="+-*^".indexOf(node.op))throw Error("Operator "+node.op+" invalid");if(null!==noPai){if(("unaryMinus"===node.fn||"pow"===node.fn)&&"add"!==noPai.fn&&"subtract"!==noPai.fn&&"multiply"!==noPai.fn)throw Error("Invalid "+node.op+" placing");if(("subtract"===node.fn||"add"===
node.fn||"multiply"===node.fn)&&"add"!==noPai.fn&&"subtract"!==noPai.fn)throw Error("Invalid "+node.op+" placing");if(("subtract"===node.fn||"add"===node.fn||"unaryMinus"===node.fn)&&0!==o.noFil)throw Error("Invalid "+node.op+" placing");}if("^"===node.op||"*"===node.op)o.fire=node.op;for(noPai=0;noPai<node.args.length;noPai++){"unaryMinus"===node.fn&&(o.oper="-");if("+"===node.op||"subtract"===node.fn)o.fire="",o.cte=1,o.oper=0===noPai?"+":node.op;o.noFil=noPai;recurPol(node.args[noPai],node,o)}}else if("SymbolNode"===
tp){if(node.name!==varname&&""!==varname)throw Error("There is more than one variable");varname=node.name;if(null===noPai)coefficients[1]=1;else{if("^"===noPai.op&&0!==o.noFil)throw Error("In power the variable should be the first parameter");if("*"===noPai.op&&1!==o.noFil)throw Error("In multiply the variable should be the second parameter");if(""===o.fire||"*"===o.fire)1>maxExpo&&(coefficients[1]=0),coefficients[1]+=o.cte*("+"===o.oper?1:-1),maxExpo=Math.max(1,maxExpo)}}else if("ConstantNode"===
tp)if(node=parseFloat(node.value),null===noPai)coefficients[0]=node;else if("^"===noPai.op){if(1!==o.noFil)throw Error("Constant cannot be powered");if(!(0,_number.isInteger)(node)||0>=node)throw Error("Non-integer exponent is not allowed");for(noPai=maxExpo+1;noPai<node;noPai++)coefficients[noPai]=0;node>maxExpo&&(coefficients[node]=0);coefficients[node]+=o.cte*("+"===o.oper?1:-1);maxExpo=Math.max(node,maxExpo)}else o.cte=node,""===o.fire&&(coefficients[0]+=o.cte*("+"===o.oper?1:-1));else throw Error("Type "+
tp+" is not allowed");}void 0===coefficients&&(coefficients=[]);var maxExpo=coefficients[0]=0,varname="";recurPol(node$jscomp$0,null,{cte:1,oper:"+",fire:""});maxExpo=coefficients.length-1;node$jscomp$0=!0;for(var no,i=maxExpo;0<=i;i--)if(0!==coefficients[i]){var n1=new ConstantNode(node$jscomp$0?coefficients[i]:Math.abs(coefficients[i])),op=0>coefficients[i]?"-":"+";if(0<i){var n2=new SymbolNode(varname);if(1<i){var n3=new ConstantNode(i);n2=new OperatorNode("^","pow",[n2,n3])}n1=-1===coefficients[i]&&
node$jscomp$0?new OperatorNode("-","unaryMinus",[n2]):1===Math.abs(coefficients[i])?n2:new OperatorNode("*","multiply",[n1,n2])}no=node$jscomp$0?n1:"+"===op?new OperatorNode("+","add",[no,n1]):new OperatorNode("-","subtract",[no,n1]);node$jscomp$0=!1}return node$jscomp$0?new ConstantNode(0):no}var config=_ref.config,typed=_ref.typed,equal=_ref.equal,isZero=_ref.isZero,add=_ref.add,subtract=_ref.subtract,multiply=_ref.multiply,divide=_ref.divide,pow=_ref.pow,parse=_ref.parse,simplify=_ref.simplify,
fraction=_ref.fraction,bignumber=_ref.bignumber,mathWithTransform=_ref.mathWithTransform,ConstantNode=_ref.ConstantNode,OperatorNode=_ref.OperatorNode,FunctionNode=_ref.FunctionNode,SymbolNode=_ref.SymbolNode;_ref=_ref.ParenthesisNode;var simplifyConstant=(0,_simplifyConstant.createSimplifyConstant)({typed:typed,config:config,mathWithTransform:mathWithTransform,fraction:fraction,bignumber:bignumber,ConstantNode:ConstantNode,OperatorNode:OperatorNode,FunctionNode:FunctionNode,SymbolNode:SymbolNode}),
simplifyCore=(0,_simplifyCore.createSimplifyCore)({equal:equal,isZero:isZero,add:add,subtract:subtract,multiply:multiply,divide:divide,pow:pow,ConstantNode:ConstantNode,OperatorNode:OperatorNode,FunctionNode:FunctionNode,ParenthesisNode:_ref});return typed("rationalize",{string:function(expr){return this(parse(expr),{},!1)},"string, boolean":function(expr,detailed){return this(parse(expr),{},detailed)},"string, Object":function(expr,scope){return this(parse(expr),scope,!1)},"string, Object, boolean":function(expr,
scope,detailed){return this(parse(expr),scope,detailed)},Node:function(expr){return this(expr,{},!1)},"Node, boolean":function(expr,detailed){return this(expr,{},detailed)},"Node, Object":function(expr,scope){return this(expr,scope,!1)},"Node, Object, boolean":function(expr,scope,detailed){var oldRules=[simplifyCore,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},simplifyConstant,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],rulesFirst=
[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},
{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],rulesSucDiv=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}];var JSCompiler_object_inline_firstRules_2393=oldRules.concat(rulesFirst,rulesSucDiv);var JSCompiler_object_inline_distrDivRules_2394=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}];rulesFirst=oldRules.concat(rulesFirst);
var JSCompiler_object_inline_finalRules_2397=[simplifyCore,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},simplifyConstant,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},
{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}];scope=polynomial(expr,scope,!0,JSCompiler_object_inline_firstRules_2393);oldRules=scope.variables.length;expr=scope.expression;if(1<=oldRules){expr=expandPower(expr);var eDistrDiv=!0,redoInic=!1;for(expr=simplify(expr,JSCompiler_object_inline_firstRules_2393,{},{exactFractions:!1});;){JSCompiler_object_inline_firstRules_2393=eDistrDiv?JSCompiler_object_inline_distrDivRules_2394:rulesSucDiv;expr=simplify(expr,JSCompiler_object_inline_firstRules_2393);
eDistrDiv=!eDistrDiv;JSCompiler_object_inline_firstRules_2393=expr.toString();if(JSCompiler_object_inline_firstRules_2393===sBefore)break;redoInic=!0;var sBefore=JSCompiler_object_inline_firstRules_2393}redoInic&&(expr=simplify(expr,rulesFirst,{},{exactFractions:!1}));expr=simplify(expr,JSCompiler_object_inline_finalRules_2397,{},{exactFractions:!1})}rulesSucDiv=[];JSCompiler_object_inline_distrDivRules_2394={};"OperatorNode"===expr.type&&expr.isBinary()&&"/"===expr.op?(1===oldRules&&(expr.args[0]=
polyToCanonical(expr.args[0],rulesSucDiv),expr.args[1]=polyToCanonical(expr.args[1])),detailed&&(JSCompiler_object_inline_distrDivRules_2394.numerator=expr.args[0],JSCompiler_object_inline_distrDivRules_2394.denominator=expr.args[1])):(1===oldRules&&(expr=polyToCanonical(expr,rulesSucDiv)),detailed&&(JSCompiler_object_inline_distrDivRules_2394.numerator=expr,JSCompiler_object_inline_distrDivRules_2394.denominator=null));if(!detailed)return expr;JSCompiler_object_inline_distrDivRules_2394.coefficients=
rulesSucDiv;JSCompiler_object_inline_distrDivRules_2394.variables=scope.variables;JSCompiler_object_inline_distrDivRules_2394.expression=expr;return JSCompiler_object_inline_distrDivRules_2394}})});exports.createRationalize=require}
//# sourceMappingURL=module$node_modules$mathjs$lib$cjs$function$algebra$rationalize.js.map
